I developed a portable WebServer and I'm creating a portable console too, to use Composer.
I have a problem. I need to create a plugin to add additional behavior to Composer.
I need that when downloading any package with Composer, it edits the composer.json "scripts" of that package, so that it works on the portable console.
When downloading Laravel, for example:
Original composer.json:
{
"name": "laravel/laravel",
...
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
...
},
...
}
composer.json edited by the plugin:
{
"name": "laravel/laravel",
...
"scripts": {
"post-root-package-install": [
"F:/portable_php_path/php.exe -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
...
},
...
}
- Note that a physical path has been generated for php.exe, because in the portable version it can be in any path.
(My question is for the creation of the composer plugin. I have no problem editing the composer.json with PHP.)
I read the tutorial for creating a plugin on the composer site, but I was confused. (https://getcomposer.org/doc/articles/plugins.md)
If there is another way to do that, it's also interesting. I accept other suggestions and ideas.
Thanks to anyone who can help.
[Sorry my bad english]