Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nix-community/composer-local-repo-plugin
A plugin for Composer that creates local repository of type `composer`. [maintainer=@drupol]
https://github.com/nix-community/composer-local-repo-plugin
composer deployment plugin repository reproducibility
Last synced: 2 days ago
JSON representation
A plugin for Composer that creates local repository of type `composer`. [maintainer=@drupol]
- Host: GitHub
- URL: https://github.com/nix-community/composer-local-repo-plugin
- Owner: nix-community
- License: mit
- Created: 2023-09-10T12:59:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-05T12:27:27.000Z (8 months ago)
- Last Synced: 2024-10-29T16:08:05.334Z (8 days ago)
- Topics: composer, deployment, plugin, repository, reproducibility
- Language: PHP
- Homepage: https://github.com/nix-community/composer-local-repo-plugin/
- Size: 125 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Composer Local Repo Plugin
This plugin, built for [Composer][composer website], facilitates the creation of
a local `composer` type repository ([refer to
documentation][composer repository]) from an existing package. Basically, this
plugin let you use Composer in "offline" mode.The repository type `composer` is identical to the format used by
[Packagist][composer website]. It uses a specific structure, featuring a
manifest file named `packages.json` and a unique directory structure. Each
version of the package within the repository has its own corresponding source.Created with the goal of installing a PHP package in a repeatable manner, this
plugin eliminates the need for network access post repository creation.The plugin is currently used within Nix. More information can be found in the
[corresponding PR][php builder pr], marking the project's inception.This project has been heavily inspired of
[`fossar/composition-c4`][fossar/composition-c4] from [Jan Tojnar][Jan Tojnar].## Requirements
- Composer 2
## Installation
Install the plugin globally once:
```
composer global require nix-community/composer-local-repo-plugin
```## Usage
### Using an updated `composer.lock` file (recommended)
1. Navigate to the package directory, or use the `--working-dir` option.
2. Make sure the `composer.json` and `composer.lock` files are present.
3. Generate the local repository using the command:
`composer build-local-repo-lock /path/to/local/repository`. This will create
a local `composer` repository in the specified directory and generate an
updated file `composer.lock` in the same location. Use the `-r` or `-m`
options to generate only a repository or the `composer.lock`, respectively.
For more details, refer to the command help:
`composer build-local-repo-lock --help`.
4. The combination of the package sources and the local repository we just
created are now strictly enough to build the `vendor` directory necessary for
the package to work. Therefore at this stage, we can disable the network as
no further network access is required or you can use the environment variable
`COMPOSER_DISABLE_NETWORK` set to `1` to do so.
5. Copy the updated `composer.lock` file in the package directory:
`cp /path/to/local/reposity/composer.lock .`
6. Finally, install the package by entering the command: `composer install`.### Using a Composer repository type (deprecated since Composer 2.7)
Note: Since Composer 2.7, this method is deprecated since it doesn't work any
more. More info at https://github.com/composer/composer/pull/118501. Navigate to the package directory, or use the `--working-dir` option.
2. Make sure the `composer.json` and `composer.lock` files are present.
3. Generate the local repository using the command:
`composer build-local-repo /path/to/local/repository`. This will create a
local `composer` repository in the specified directory and generate a
manifest file `packages.json` in the same location. Use the `-r` or `-m`
options to generate only a repository or a manifest file, respectively. For
more details, refer to the command help: `composer build-local-repo --help`.
4. The combination of the package sources and the local repository we just
created are now strictly enough to build the `vendor` directory necessary for
the package to work. Therefore at this stage, we can disable the network as
no further network access is required or you can use the environment variable
`COMPOSER_DISABLE_NETWORK` set to `1` to do so.
5. Disable Packagist by entering the command:
`composer config repo.packagist false`.
6. Integrate the newly created local `composer` repository into the
`composer.json` file using the command:
`composer config repo.local composer file:///path/to/local/reposity/packages.json`.
7. Refresh the lock file using the command:
`composer update --lock --no-install --no-scripts --no-plugins --no-interaction`.
8. Finally, install the package by entering the command: `composer install`.## In Nix
The plugin is used in Nix to build Composer based PHP packages. The combination
of the source package and the local repository built with this plugin is unique
and Nix uses that for ensuring reproducibility.### Note
By default, Composer will create symbolic links to the packages, if you want to
copy the packages instead, set the environment variable
`COMPOSER_MIRROR_PATH_REPOS` to 1[composer website]: https://getcomposer.org/
[fossar/composition-c4]: https://github.com/fossar/composition-c4/
[Jan Tojnar]: https://github.com/jtojnar
[composer repository]: https://getcomposer.org/doc/05-repositories.md#composer
[php builder pr]: https://github.com/NixOS/nixpkgs/pull/225401