I am trying to set up Composer to work without internet access. I have set up a server in the local network with a Satis configured repository with the following configuration file:
{
"name": "private/composer",
"homepage": "http://<some_ip>:9500",
"repositories": [
{"type": "composer", "url": "https://packagist.org"}
],
"require-dependencies": true,
"require": { ... },
"archive": {
"directory": "offline",
"format": "zip"
},
"config": {
"preferred-install": "dist"
}
}
After running
$ ./satis/bin/satis build ./satis.json ./mirror
Everything works, I get my ./satis/mirror/offline directory filled up with .zip files of the packages I am mirroring from packagist.org.
In my Composer, project, I added the following sections to the composer.json configuration:
{
"repositories": [{
"type": "composer",
"url": "http://<some_ip>:9500"
}],
"config": {
"secure-http": false
},
...
}
I tried to run composer install then and I get an error about Composer not begin able to access https://packagist.org/packages.json. Why is it trying to do that? How can I make this process work without internet access?
Thank you!
By default Composer does not disable access to packagist.org when you add custom repos. You can disable it with the following config:
{
"repositories": [
{
"packagist.org": false
}
]
}
Related
I am new in laravel 7. i want ask how to install github package into my laravel project.
(https://github.com/lomotech/jajahan) this package i want to install to my laravel but not instruction in this package.
If a package is missing a composer.json, you can add the following to your project's composer.json:
"repositories": [
{
"type": "package",
"package": {
"name": "lomotech/jajahan",
"version": "v2.2018.01",
"source": {
"url": "https://github.com/lomotech/jajahan",
"type": "git",
"reference": "master"
}
}
}
],
"require": {
"lomotech/jajahan": "*"
},
"autoload": {
"psr-4": {
"Lomotech\\Jajahan\\": "vendor/lomotech/jajahan/"
}
},
The autoload entry allows composer to generate the vendor classmaps so you can use the package in your code by:
use Lomotech\Jajahan\SomeClassFile;
Finally, run composer install/update.
I have a global composer file for my user which contains references to local packages like:
{
"repositories": [
{
"type": "path",
"url": "/vendorA/projectA",
"options": {
"symlink": true
}
},
{
"type": "path",
"url": "/vendorA/projectB",
"options": {
"symlink": true
}
},
{
"type": "path",
"url": "/vendorA/projectC",
"options": {
"symlink": true
}
}
]
}
In project C, I have a composer.json file similar to:
{
"name": "Project C"
"require": {},
"require-dev": {
"vendorA/projectA": "#dev",
"vendorA/projectB": "#dev"
},
"prefer-stable": true
}
When I composer require --dev vendorA/projectC, it symlinks Project C's folder under the vendor folder but not the requirements defined in Project C's composer.json file. I tested installing Project A and B and they work fine so it is not a situation where composer is not able to find the packages, but Projects A and B don't install as well when project C is installed as a dependency of another project.
I also tried "minimum-stability": "dev" which did not work either.
Anyone know if I am missing something?
We've started to use Satis for a private composer repository.
All is going well - except something which we cannot figure out.
--
When we run the satis build - it generates the json and the zips to download.
Our config resembles something like
{
"name": "Premium Repositories",
"homepage": "https://some-website.com",
"require-all": false,
"repositories": [
{
"type": "vcs",
"url": "git#bitbucket.org:our-repo.git"
}
],
"archive": {
"directory": "dist"
}
}
The json it then generates contains something like
"some/package": {
"dev-master": {
"name": "some/package",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "git#bitbucket.org:selesti/some-package.git",
"reference": "db0abb6a6983738d768b64684f82d178059b85b4"
},
"dist": {
"type": "zip",
"url": "https://some-domain/dist/some/package/some-package-dev-master-ec67bc.zip",
"reference": "db0abb6a6983738d768b64684f82d178059b85b4",
"shasum": "f04821a159f6f19ea6e5be8624d88f32b168e205"
},
"require": {
"magento/framework": ">=100.0.0",
"php": "~5.5.0|~5.6.0|>=7.0.0",
"some/core": ">=3.0.0"
},
"time": "2018-02-16T09:00:56+00:00",
"type": "magento2-module"
}
}
We can clearly see from this it contains both the zip and the source.
This seems to mean that when we run composer install it tries to install the source version first - which fails as it doesn't have read-access - then it falls back to the dist, which works.
Is this the natural behaviour of composer if there is a source field within the composer.lock ? - And if so, is it possible for satis to not generate the source object, so it automatically goes straight to the dist key?
Thanks
I'm not sure if you can exclude source repos from Satis output, but as an alternative, you can tell Composer to use dist repos by default with configuration similar to:
{
"config": {
"preferred-install": "dist"
}
}
You can also specify preferred-install config on package by package basis, as per docs:
{
"config": {
"preferred-install": {
"my-organization/stable-package": "dist",
"my-organization/*": "source",
"partner-organization/*": "auto",
"*": "dist"
}
}
}
I want to create package and I following this tutorial https://devdojo.com/blog/tutorials/how-to-create-a-laravel-package
I want to use auto discover the new feature of L5.5, how step-3 should be? (what I need to write on laravel's composer.json)
Laravel’s custom package’s providers will be auto-discovered only if the package present in vendor folder, So for that we need to make our package installable via composer itself.
So we need to make our custom package should be installable via composer, for that set your applications composer file with minimum-stability as dev is must and we have to configure custom packages path.
"minimum-stability" : "dev",
"repositories": [
{
"type": "path",
"url": "./packages/suresh/calc/"
}
]
once you done that your package can be installed using composer require <vendor/package>, then it will configure auto discover as per your packages settings. Get the sample configurations for your package,
{
"name": "suresh/calc",
"description": "This demo for auto discover providers in laravel with custom package",
"authors": [
{
"name": "Suresh Veluamy",
"email": "sureshamk#gmail.com"
}
],
"minimum-stability": "stable",
"require": {},
"autoload": {
"psr-4": {
"Suresh\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Suresh\\Calc\\CalcServiceProvider"
]
}
}
}
For more information, i wrote a post, check it out here
I've successfully set up Satis on my own server and am able to pull in packages from it.
However, dependencies that are required in those private packages are constantly being cloned at their bleeding edge version instead of the specified version constraint. I think that Satis is creating a local mirror of the latest dev-version. However I do not want to have a local mirror, I just need them to install directly from Packagist.
So how do I need to setup the project / package / Satis to have the dependencies in those private packages installed from Packagist?
Thanks.
This is my Satis build file:
{
"name": "Package Server",
"homepage": "http://packages.URL",
"repositories": [
{
"type": "vcs",
"url": "git#bitbucket.org:USERNAME/REPO.git",
"options": {
"ssh2": {
"username": "USERNAME",
"pubkey_file": "PUBFILE",
"privkey_file": "PRIVATEFILE"
}
}
}
],
"require-all": true
}
And this is the composer.json file of the project requiring the private package (package has no tagged releases):
{
"name": "Test Project",
"description": "",
"require": {
"php": ">=5.4.0",
"USERNAME/REPO": "*"
},
"repositories": [
{
"type": "composer",
"url": "http://packages.URL"
}
],
"minimum-stability": "dev"
}
And this is the private package's composer.json:
{
"name": "USERNAME/RPO",
"description": "",
"require": {
"php": ">=5.4.0",
"illuminate/support": "5.0.*",
"vinkla/hashids": "~1.0"
},
"minimum-stability": "dev"
}
In your Satis config you defined "require-all": true.
This is default and selects all versions of all packages in the repository you defined.
You could try to remove "require-all": true in favor of a require section.
This means that Satis will only contain these specific packages and their versions, like so:
"require": {
"company/packageA": "*",
"company/packageB": "1.2.3",
"company/packageC": "2.0.0"
}
It's package cherry picking on Satis
So if I understand correctly I need to add the private packages that are available in the specified private repository in the require key and their own dependencies will then install from Packagist?
Add require-dependencies - this tells Satis to mirror not only the packages specified in the "require" section, but also all their dependencies.
See https://getcomposer.org/doc/articles/handling-private-packages-with-satis.md#resolving-dependencies
Is it possible to have multiple packages resided in one defined repository or does every single package need their own repository url entry in Satis?
I think it's not possible to have multiple packages in one "type": "vcs" repository.
With "type": "composer" and a cloned packagist you can store multiple repos.
Think of http://drupal-composer.org with http://packagist.drupal-composer.org/.
{
"repositories": [
{ "type": "vcs", "url": "https://github.com/somewhere/packageA" },
{ "type": "composer", "url": "https://packagist.org" }
],
"require": {
"package/packageA": "somewhere-dev",
"phpunit/phpunit": "*"
},
"require-dependencies": true
}