Composer can't access local Satis server - laravel

I am hosting a Satis Private Repository currently on my local machine while I do some debugging and testing. I have added a repository too which currently just contains a project on GitLab which included a composer package.
Currently it is being pulled from a docker image, and is hosted at localhost:8002.
My repository is setup in my Laravel project as follows:
"repositories": [
{ "packagist": false },
{
"type": "composer",
"url": "http://localhost:8002/packages.json"
}],
And if I navigate to that URL in my browser I get the following output:
{
"packages": [],
"includes": {
"include/all$949e06d91b8be4b54109a0b06c31805a5735a1ba.json": {
"sha1": "949e06d91b8be4b54109a0b06c31805a5735a1ba"
}
}
}
However, if I try to composer update the Laravel project, I get the following errors depending on if I execute it from within the container.
The "http://localhost:8002/packages.json" file could not be downloaded (HTTP/1.1 504 Gateway Timeout)
[Composer\Downloader\TransportException]
The "http://localhost:8002/packages.json" file could not be downloaded: failed to open stream: Address not available
If anyone would be able to point me in the right direction at all I would really appreciate it, as I am scratching my head here.

Related

Laravel installation problem (by using composer on windows)

I am trying to install laravel on windows by using composer, and got this error:
"[Composer\Downloader\TransportException]
curl error 7 while downloading https://repo.packagist.org/p2/laravel/laravel.json: Failed to connect to 127.0.0.1 port 9999: Connection refused"
You could also run this command on the CLI before installing any dependencies. It forces the composer to use HTTPS to download all resources:
composer config -g repo.packagist composer https://packagist.org
Or if your problem is not resolved:
The issue could be caused by the redirect from http to https. (or your firewall blocking the call)
According to this article, the problem could be solved by adding the following to your composer.json:
"repositories": [
{
"type": "composer",
"url": "https://packagist.org"
},
{ "packagist": false }
]
FMI: http://codinginharmony.blogspot.com/2012/10/forcing-composer-to-use-https.html#comment-form

How to deploy to GitHub pages with Web Components Dependencies in Node Modules

I am trying to host my web site using Github Pages. I am currently using Web Components and Lit-HTML (No Lit Element). No server side code. Just using NPM and Node Modules. I am wanting to build the site and publish to my git branch gh-pages but I am not quite sure what steps I need to take as currently the page error as it can not find the dependencies.
I am currently running the site locally using WAMP on my Windows Machine. Works perfectly here. Not sure if its possible to compile the code so that its in a Jekyll format
EDIT: I know how to push the code to Github. Just not sure how Github uses Node Modules to build the site.
Here is my Package.json
{
"name": "Repo",
"version": "1.0.0",
"description": "Description",
"dependencies": {
"#webcomponents/webcomponentsjs": "^2.2.1",
"lit-html": "^1.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/username/Repo.git"
},
"author": "ME",
"license": "ISC",
"bugs": {
"url": "https://github.com/username/Repo/issues"
},
"homepage": "https://homepage.com"
}
It depends from where you want to get the dependencies.
Do you want to host them yourself on your own site? Maybe it's not necessary. Instead you could get them directly from their original CDN.
For webcomponentsjs, according to their website, it's on the unpkg.com CDN.
<script src="https://unpkg.com/#webcomponents/webcomponentsjs#^2/webcomponents-bundle.js"></script>
For lit-html, according to the doc, it's on the unpkg.com CDN too:
import {html, render} from 'https://unpkg.com/lit-html?module'

Configure composer to get data from packagist.org via https

When building files in an environment that blocks outbound http requests, I get an error like:
Updating dependencies (including require-dev)
The "http://packagist.org/p/provider-2013%ahash.json" file could not be downloaded: failed to open stream: Connection timed out
http://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
Is there some way to instruct composer to use https connection to packagist?
I've experienced the issue with both 1.2.0 and 1.6.5 versions of composer.
You can either force composer to use https by:
composer config -g repo.packagist composer https://packagist.org
Or you could set in your composer.json file:
"repositories": [
{
"type": "composer",
"url": "https://packagist.org"
},
{ "packagist": false }
]
Source: issue #5656 on composer's github repository.

composer create-project without the need to have internet access

From my understanding, the following command will go to internet to download some files (such as the https://packageist.org/packages.json).
composer create-project laravel/laravel MyProject --prefer-dist
Is it possible to download all the required files so that the above command do not require internet access? (meaning that it will use local drive for to create the project.)
You can setup local mirror for any packages you want. Alternatively, you could just create batch script (shell script) which would copy whole project from any local computer or from local directory on the same machine.
"repositories": [
{
"type": "composer",
"url": "http://localhost:4680"
}
],
You won't require internet connection only if requested package is available in your local cache.
Despite of that, offline mode is something that was requested some time ago.
https://github.com/composer/composer/issues/2244
You can use the repositories key in your composer.json file -
{
"name": "atefth/project",
"description": "Test project",
"license": "MIT",
"authors": [
{
"name": "Atef Haque",
"email": "atefth#gmail.com"
}
],
"minimum-stability": "dev",
"repositories": [
{
"type": "vcs",
"url": "../package"
}
],
"require": {
"atefth/package": "*"
}
}
You need to download all your dependencies inside the ../package directory

Symfony2 and Google API integration

I am going to use Google API located on http://google-api-php-client.googlecode.com/svn/trunk/ with my Symfony2 application.
Is it possible to import this API with composer ?
What is the best practice to use this API with my application ?
It's probably too late, but there is no need to use forked git repos, you can refer to Google's "native" svn directly.
Add the following section to your composer.json:
"repositories": [
{
"type": "package",
"package": {
"name": "project/google-api-php-client",
"version": "1.0.0",
"source": {
"type": "svn",
"url": "http://google-api-php-client.googlecode.com/svn",
"reference": "trunk"
}
}
}
]
Notes:
"project/google-api-php-client" name there can be any of your choice
If you need a particular revision, use "trunk#revision-number-here" format in "reference" entry
Then add the following line to your "require" section:
"require": {
...
"project/google-api-php-client": "1.0.0"
}
That'll make composer to checkout the repo on the next update/install.
If you want Google API classes to be autoloaded, add the following line to your "autoload" section:
"autoload": {
...
"classmap": ["vendor/project/google-api-php-client/src"]
}
It doesn't seem very neat to put the full path into the global "autoload" section, but I didn't manage to make it work with "autoload" section under `repository/package" yet :(
Google have now started using github and have added a composer.json file.
Github: https://github.com/google/google-api-php-client
Packagist: https://packagist.org/packages/google/apiclient
"require": {
...
"google/apiclient": "dev-master"
}
It's a shame there is no namespaces, but they are closer than before by having a composer file.
There is a Symfony2 bundle wrapping the official Google API library published by Google on Github in 2014. That way, the API client is available as a service and you can store your configuration in the Symfony2 config file.
Symfony2 Bundle: https://github.com/Happyr/GoogleApiBundle
$ composer require happyr/google-api-bundle
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new HappyR\Google\ApiBundle\HappyRGoogleApiBundle(),
);
}
There github repository for Google API https://github.com/evert/google-api-php-client with composer.
You can add to your composer.json file: "evert/google-api-php-client"

Resources