I use the command composer require otra/otra:dev-develop --no-update --no-cache && composer update --no-autoloader
to install my own framework.
I have put this section in my composer.json
from my framework :
"scripts": {
"pre-install-cmd": "@composer config bin-dir bin/"
}
But Composer does not run it. Is this normal, does Composer consider this as a dependency and not the root package so it does not allow my script to run?
If this is the case, how can I have the same behaviour?
I want to :
- have my binary in the
bin
folder, notvendor/bin
without having to ask the user to do a symlink manually (or another solution) - copy a
web
folder from my framework to the root of the project.
Edit : with create-project
command
If I type composer create-project otra/otra:dev-develop crashtest --remove-vcs
, I get this composer.json
:
{
"name": "otra/otra",
"type": "library",
"description": "The OTRA PHP framework",
"keywords": ["framework"],
"homepage": "https://github.com/lperamo/otra",
"license": "X11",
"authors": [
{
"name": "Lionel Péramo",
"email": "contact@lionel-peramo.com",
"homepage": "https://wexample.com"
}
],
"bin" : ["otra.php"],
"config": {
"bin-dir" : "bin/",
"sort-packages": true
},
"require": {
"ext-mbstring": "*",
"php": ">=7.4.0",
"symfony/yaml": "^4.0"
},
"require-dev": {
"ext-pdo": "*",
"ext-pdo_mysql": "*"
},
"scripts": {
"pre-install-cmd": "@composer config bin-dir bin/"
}
}
which is exactly the same as my framework so I cannot update it via Composer. I could with git if I do not use --remove-vcs
but it is not the goal.
The output of the composer
command is :
Installing otra/otra (dev-develop ab37237565155dab11812a7b2982d30ee240f051)
- Installing otra/otra (dev-develop ab37237): Cloning ab37237565 from cache
Created project in crashtest
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file