symplify / package-scoper
Scope package in unique namespace to prevent composer install conflicts - with 1 click
Fund package maintenance!
tomasvotruba
www.paypal.me/rectorphp
Requires
- php: >=7.3
- symfony/console: ^4.4|^5.2
- symfony/dependency-injection: ^5.2
- symfony/http-kernel: ^4.4|^5.2
- symplify/composer-json-manipulator: ^9.3.1
- symplify/symplify-kernel: ^9.3.1
Requires (Dev)
- phpunit/phpunit: ^9.5
- dev-main / 9.4.x-dev
- v9.3.1
- v9.3.0
- v9.2.24
- v9.2.23
- v9.2.22
- v9.2.21
- v9.2.20
- v9.2.19
- v9.2.18
- v9.2.17
- v9.2.16
- v9.2.15
- v9.2.14
- v9.2.13
- v9.2.12
- v9.2.11
- v9.2.10
- v9.2.9
- v9.2.8
- v9.2.7
- v9.2.6
- v9.2.5
- v9.2.4
- v9.2.3
- v9.2.2
- 9.2.1
- 9.2.0
- 9.1.9
- 9.1.8
- 9.1.7
- 9.1.6
- 9.1.5
- 9.1.4
- 9.1.3
- 9.1.1
- 9.1.0
- 9.0.50
- 9.0.49
- 9.0.48
- 9.0.47
- 9.0.46
- 9.0.45
- 9.0.44
- 9.0.43
- 9.0.42
- 9.0.41
- 9.0.40
- 9.0.39
- 9.0.38
- 9.0.37
- 9.0.36
- 9.0.35
- 9.0.34
- 9.0.33
- 9.0.32
- 9.0.31
- 9.0.30
- 9.0.29
- 9.0.28
- 9.0.27
- 9.0.26
- 9.0.25
- 9.0.24
- 9.0.23
- 9.0.22
- 9.0.21
- 9.0.20
- 9.0.19
- 9.0.18
- 9.0.17
- 9.0.16
- 9.0.15
- 9.0.14
- 9.0.13
- 9.0.12
- 9.0.11
- 9.0.10
- 9.0.9
- 9.0.8
- 9.0.7
- 9.0.6
- 9.0.5
- 9.0.4
- 9.0.3
- 9.0.2
- 9.0.1
- 9.0.0
- 9.0.0-rc1
- 9.0.0-BETA9
- 9.0.0-BETA8
- 9.0.0-BETA7
- 9.0.0-BETA6
- 9.0.0-BETA5
- 9.0.0-BETA4
- 9.0.0-BETA3
- 9.0.0-BETA2
- 9.0.0-BETA1
- 8.3.48
This package is auto-updated.
Last update: 2021-05-07 00:36:45 UTC
README
- Does your package require Symfony 5, but developers want to use it on Symfony 3?
- Do you want to scope your package dependencies with unique namespace, but don't know how?
- Do you want to skip learning of PhpScoper, PHAR packing, Box and GitHub Actions automated deploy?
You're in the right place!
Install
composer require symplify/package-scoper symplify/monorepo-builder --dev
We also need symplify/monorepo-builder
, so we can work with relative paths of local packages.
Usage
1. Generate php-scoper Config
php-scoper is a package that prefixes classes and functions, so they're unique and don't conflict with same-named class in a different version. You can read the documentation, or you can generate the config with sane defaults:
vendor/bin/package-scoper generate-php-scoper
It will create scoper.inc.php
right in the root of the package. That's the best location, because php-scoper works with path relative to its location.
2. Scope Composer Json
Scoping PHP code with php-scoper is just the first step. The second is making a composer.json
with a different name than the original package. We got you covered! The following command will:
- update package name to
<original>-prefixed
- keep PHP version in
require
section, license and bin files - drop the rest
It must be run on the scoped package composer.json
, not the original one:
vendor/bin/package-scoper scope-composer-json <path-to-composer-json> vendor/bin/package-scoper scope-composer-json packages-scoped/some-package/composer.json
3. Generate GitHub Action Workflow
The process without automatization would not be much helpful. That's why we have GitHub Action to automate it.
vendor/bin/package-scoper generate-workflow
Go to your .github/workflows
folder, update packages names manually and you're ready to go.
Convention over Configuration in GitHub Action
In the GitHub Workflow you only define package names. To make the whole process work, the <package-name>
must be used in:
- directory name
/package/<package-name>
- binary file name:
/package/<package-name>/bin/<package-name>
As the file is defined in the composer.json
:
{ "bin": [ "bin/<package-name>" ] }