Add to the Laravel application the ability to plug and play packages that are build with package discover without necessarily installing a new dependency on composer.json
.
This package uses the great plugin Composer Merge Plugin which allows you to merge multiple composer.json
files into the Composer runtime.
Laravel Plug and Play requires Composer 1.0.0 or newer.
composer require edersoares/laravel-plug-and-play
php artisan package:install
The composer.json
file needs to be updated to something like:
{
"require": {
"edersoares/laravel-plug-and-play": "^1.0"
},
"extra": {
"merge-plugin": {
"include": [
"packages/*/*/composer.json"
]
}
}
}
This package is a Composer Merge Plugin extension and its features can be used usually. See more in plugin configuration.
Move or clone the package to packages/<vendor>/<name>
folder and runs:
composer update --lock
Whenever package dependencies are updated, this command must be executed.
This will instruct Composer to recalculate the file hash for the top-level composer.json thus triggering composer-merge-plugin to look for the sub-level configuration files and update your dependencies.
https://github.com/wikimedia/composer-merge-plugin#updating-sub-levels-composerjson-files
To create a package execute:
php artisan package:create <vendor>/<name>
This will create a package in packages
folder:
packages
\_ <vendor>
\_ <name>
\_ src
\_ Providers
\_ ServiceProvider.php
\_ composer.json
See the official documentation about package discover.
Just only remove the package folder and runs:
composer update --lock
Laravel Plug and Play is licensed under the MIT license. See the license file for more details.