I have a project I created with composer create-project
command, but before running composer install
, I added one more package to project composer.json
file.
After installing the packages, I correctly have all the dependencies including the one newly added in the vendor directory. What I want now is to run the tests of the package that I manually added to composer.json. I tried the below, but doesn't seem to run the tests of the said package
./vendor/bin/phpunit
You can run composer show -i (short for --installed ). In the latest version just use composer show .
Create a folder to run this from ideally in the parent folder so both the project folder and the package folder are on the same level. Next create a composer.json file, add the vendor/package name to require and autoload it, to make it work add a repositories array and pass in the local path to the package.
By setting the "type": "path" composer knows that you would like to reference a local repository and the url defines the package location (the path can be relative or absolute). With this two settings you are good to go, but composer will copy the package code into the vendor folder and you need to call composer update on every package change.
With this two settings you are good to go, but composer will copy the package code into the vendor folder and you need to call composer update on every package change. To prevent composer from doing so you need to specify the symlink option and composer will create a symlink to the package folder.
It instructs Composer to install the package's binaries to vendor/bin for any project that depends on that project. This is a convenient way to expose useful scripts that would otherwise be hidden deep in the vendor/ directory. What happens when Composer is run on a composer.json that defines vendor binaries? #
I was having a similar problem, we have separate private packages in vendor folder that needed to be tested. By default composer autoload-dev
includes only root package as mentioned here https://getcomposer.org/doc/04-schema.md#root-package
To include your forked package just add an entry in your root composer.json file under autoload-dev
"autoload-dev": {
"psr-4": {
"Company\\Package\\Tests\\": "vendor/package/tests/"
}
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With