Use an old non PSR-0 library with Symfony2 and integrate it with composer (using gitlab)
Since the title summarize enough the content, here there are the steps!
Create the Git repo and format it in a way compatible with composer
example:
root
lib
YourPackageName
src
[your stuff]
composer.json
Fill the composer.json file with some info about your library
{
"name": "yourpackagename",
"description": "PHP library for...",
"license": "",
"authors": [{
"name": "aaa",
"email": "bbb"
}],
"require": {
},
"require-dev": {
},
"autoload": {
"psr-0": { "": "src/" },
"classmap": ["lib/"]
}
}
All the magic relies on the autoload section. Composer will generate a map of your non PSL-0 compliant library and will push it into the autoload process of your Symfony2 application.
Add your repository to Symfony2 composer.json file
"repositories": [
{
"type": "vcs",
"url": "git@gitlab.com:[your account]/[your repo].git",
"options": {
"ssh2": {
"user": "git",
"pubkey_file": "~/.ssh/id_rsa.pub",
"privkey_file": "~/.ssh/id_rsa"
}
}
}
],
Always remember to add the key for the user which will launch the composer.phar
script (so we are assuming that the repository is private!).
Require your package, maybe the dev-master (in case you are still developing it)
"require": {
[other stuff],
"psl":"dev-master"
},