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"
}
}
}
Related
For some reason I'm unable to install Predis package in my project via composer require predis/predis, I have manually downloaded Predis package from https://php-download.com and moved predis folder to the vendor and then updated files inside vendor/composer, it works fine.
However, the problem is when I run composer dump-autoload, this command removes all references of this package from vendor/composer/autoload_psr4.php and autoload_static.php files.
Can someone please help me how can I prevent composer dump-autoload to remove references of this package?
Instead of copying your package to the vendor directory, you can use "repositories" in install a local package:
{
"repositories": [
{
"type": "path",
"url": "../../packages/my-package"
}
],
"require": {
"my/package": "*"
}
}
I fixed it by adding following code in vendor/composer/installed.json , I forgot to add it.
{
"name": "predis/predis",
"version": "v1.1.1",
"version_normalized": "1.1.1.0",
"source": {
"type": "git",
"url": "https://github.com/nrk/predis.git",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"suggest": {
"ext-curl": "Allows access to Webdis when paired with phpiredis",
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
},
"time": "2016-06-16T16:22:20+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Predis\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniele Alessandri",
"email": "suppakilla#gmail.com",
"homepage": "http://clorophilla.net"
}
],
"description": "Flexible and feature-complete Redis client for PHP and HHVM",
"homepage": "http://github.com/nrk/predis",
"keywords": [
"nosql",
"predis",
"redis"
]
}
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?
When pointing satis to a Gitlab repo, it chooses a dist url that mirrors the source url instead of finding the Gitlab Release and using the dist zip artifact.
Let's say your satis.json looks like this:
{
"repositories": [
{ "type": "vcs", "url": "git#gitlab.com:group-name/project-name.git" },
],
"require-all": true
}
When you run satis build satis.json, satis will create a packages.json that looks like this:
{
"packages": {
"group-name/project-name": {
"v1.0.1": {
"name": "group-name/project-name",
"version": "v1.0.1",
"version_normalized": "1.0.1.0",
"source": {
"type": "git",
"url": "git#gitlab.com:group-name/project-name.git",
"reference": "68da091ec3d6891e8519095a8066b28eb2261c20"
},
"dist": {
"type": "zip",
"url": "https://gitlab.com/api/v4/projects/group-name%2Fproject-name/repository/archive.zip?sha=68da091ec3d6891e8519095a8066b28eb2261c20",
"reference": "68da091ec3d6891e8519095a8066b28eb2261c20",
"shasum": ""
},
"require": {
"composer/installers": "v1.0.6"
},
"require-dev": {
"wp-coding-standards/wpcs": "^2.2"
},
"time": "2020-01-13T04:39:57+00:00",
"type": "wordpress-plugin"
}
}
}
The problem
The dist.url is simply an API call to Gitlab to generate a zip of the files as they appear within the git repo.
But I'm carefully constructing a zip distributable as part of my CI builds that contains minified javascript, generated css, etc. This zip distributable is then attached to a Gitlab Release as an artifact.
I want satis to find my GitLab Release and use the zip artifact in the dist.url. In my case, it would look something like this:
"dist": {
"type": "zip",
"url": "https://gitlab.com/api/v4/projects/11301246/jobs/400678589/artifacts/project-name-1.0.1.zip",
},
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
}
]
}
I have a own TYPO3 extension hosted on bitbucket. Getting this via composer works (see here for input). The extension is downloaded into my vendor folder. Being there i cannot install the extension via extension-manager.
How can I getting my ext into typo3conf/ext (ensuring autoloading will work)?
The extensions coming via
{
"type": "composer",
"url": "http://composer.typo3.org/"
}
are going to (as expected):
web/typo3config/ext
here is my project composer.json:
{
"repositories": [
{
"type": "composer",
"url": "http://composer.typo3.org/"
},
{
"type": "package",
"package": {
"name": "metaxos/exaibbrplus",
"version": "dev-2016",
"source": {
"url": "https://metaxos#bitbucket.org/metaxos/exaibbrplus.git",
"type": "git",
"reference": "release/2016"
}
}
}
],
"name": "Metaxos/ibbrating2016",
"require": {
"typo3/cms": "7.6.2",
"bk2k/bootstrap-package" : "dev-master",
"typo3-ter/compatibility6" : "7.6.0",
"typo3-ter/extension-builder" : "7.6.0",
"metaxos/exaibbrplus": "dev-2016"
},
"extra": {
"typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"web-dir": "web"
}
}
}
here is my extension composer.json:
{
"name": "metaxos/exaibbrplus",
"description": "custom ext for typo3",
"type": "typo3-cms-extension",
"version": "0.0.1",
"require": {
"typo3/cms-core": ">=7.6.0,<8.0"
},
"replace": {
"extkey": "self.version",
"typo3-ter/extkey": "self.version"
},
"autoload": {
"psr-4": {
"Metaxos\\Exaibbrplus\\": "Classes/"
}
},
"keywords": ["custom", "ext"],
"homepage": "http://www.blah.ch"
}
For Composer to install the package in web/typo3conf/ext, the package needs to have the type typo3-cms-extension. In your extension's composer.json this type is actually declared, however Composer will not respect it because you explicitly declare the package configuration in your project-level composer.json:
"repositories": [
# ...
{
"type": "package",
"package": {
"name": "metaxos/exaibbrplus",
"version": "dev-2016",
"source": {
"url": "https://metaxos#bitbucket.org/metaxos/exaibbrplus.git",
"type": "git",
"reference": "release/2016"
}
}
}
]
As you're using "type": "package" for your own repository, I suspect that Composer ignores the composer.json from that package. As you already have a Git repository that contains a composer.json, I'd suggest adding the repository using the vcs type instead:
"repositories": [
{
"type": "vcs",
"url": "https://metaxos#bitbucket.org/metaxos/exaibbrplus.git"
}
]
When doing that, Composer should use the composer.json from that repository, recognize the correct package type (typo3-cms-extension) and install the package in the correct directory.
You need to add the type key with the value typo3-cms-extension to the root composer.json. This will place your extension in web/typo3conf/ext instead of vendor/$vendor/$package which in turn will make it available to the cms.
It is important, to know that if you redefine the package in the root composer.json as repository type package, nothing from the extensions' composer.json file will be taken into account and you need to define any concerns about that package in the root composer.json.
So-applying the rules I mentioned above, your root composer.json will look like that:
{
"repositories": [
{
"type": "composer",
"url": "http://composer.typo3.org/"
},
{
"type": "package",
"package": {
"name": "metaxos/exaibbrplus",
"version": "dev-2016",
"type": "typo3-cms-extension",
"source": {
"url": "https://metaxos#bitbucket.org/metaxos/exaibbrplus.git",
"type": "git",
"reference": "release/2016"
},
"autoload": {
"psr-4": {
"Metaxos\\Exaibbrplus\\": "Classes/"
}
},
}
}
],
"name": "Metaxos/ibbrating2016",
"require": {
"typo3/cms": "7.6.2",
"bk2k/bootstrap-package" : "dev-master",
"typo3-ter/compatibility6" : "7.6.0",
"typo3-ter/extension-builder" : "7.6.0",
"metaxos/exaibbrplus": "dev-2016"
},
"extra": {
"typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"web-dir": "web"
}
}
}
As mentioned above by #helmbert, you are either left with completely redefining the package or using another repository type. You may want to consider using satis or a URL repository.
try to add
"replace": {
"exaibbrplus": "self.version",
"typo3-ter/exaibbrplus": "self.version"
},
And use only "Metaxos\\Exaibbrplus\\": "Classes/" in the autoloader.