I'm a litte confused about the right way to use Composer and Bitbucket regarding the distribution of my libraries, maybe because I'm a newbie both in Composer and Bitbucket.
My problem is: I have two repositories on Bitbucket, the first one is a simple utility library (Utility) and the second one is the main project (MainProject). Both have one single branch, the master one.
I want to use Utility in MainProject, so I wrote two composer.json.
Mainproject composer.json:
{
"require": {
"vendor/utility": "*"
},
"repositories": [
{
"type": "vcs",
"url": "https://MyUsername@bitbucket.org/MyUsername/utility.git"
}
]
}
Utility composer.json:
{
"name": "vendor/utility",
"autoload": {
"psr-4": {
"Vendor\\": "src/"
}
}
}
This configuration works perfectly, I mean, if I launch 'composer install' on MainProject, Utility is correctly cloned. But in the vendor directory in MainProject I get all the Utility files, including test directory and useless files like phpunit.xml.
I've tried to use the solution offered here: https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production/, I created the archive via Sourcetree, but after? How I should use this archive? I suspect I miss some basic knowledge.
If I want to distribute Utility via composer as a package also for other applications, but without its tests and other files, which is the right way? Should I use .gitattribute or is there a simple way to create a dist version? I don't understand how to do with Bitbucket, maybe because I'm a newbie.
A little help?