Adding a package with Composer (through SVN)
If you use the officially recommended repository layout with a "project root" (which contains exactly three subdirectories: /trunk
, /branches
, and /tags
) then this should work for you:
For your PHP library create composer.json
in project root in the trunk (and commit it). For example:
{ "name": "myProject/myLibrary", "description": "My Personal Library", "license": "proprietary", "require": { "php": ">=5.3" }, "autoload": { "classmap": ["src/"] }}
Lets say your library repository is available at http://svn.example.com/path/to/myLibrary
. The layout then would be:
/path/to/myLibrary /trunk /composer.json /src ... /branches /tags
Then in you project, where you want to use your library, create composer.json with the following contents:
{ "repositories": [ { "type": "vcs", "url": "http://svn.example.com/path/to/myLibrary" } ], "require": { "nette/nette": "~2.2", "myProject/myLibrary": "@dev" }}
The key is to use @dev
as the required version for your library if you only have composer.json
in trunk yet. Once you create a tag from trunk, you can start using version numbers. For example if you svn copy ^/trunk ^/tags/1.0.0
, then you can use "myProject/myLibrary": "~1.0"
as your version number.
Try to get more information calling composer update -v to get a list of possible version strings you can use.
I for example got the info, that the correct name for fetching the trunk was this config:
{ "name": "sample/test", "type": "library", "version": "0.0.0", "time" : "2013-04-16", "description": "Testing ...", "repositories": [ { "type": "svn", "url": "http://framework.zend.com/svn/framework/standard" } ], "require": { "php": ">=5.3.3", "zendframework/zendframework1" : "dev-trunk" }}
Calling composer with -v as argument, you'll get a list of branches, tags and the trunk, if found. I don't know if false is allowed as path for tags and branches ...
$ composer update -vLoading composer repositories with package informationReading composer.json of zendframework/zendframework1 (release-0.1.1)Skipped tag 0.1.1, no composer file was foundReading composer.json of zendframework/zendframework1 (release-0.1.2)Skipped tag 0.1.2, no composer file was foundReading composer.json of zendframework/zendframework1 (release-0.1.3)Skipped tag 0.1.3, no composer file was found....Reading composer.json of zendframework/zendframework1 (release-1.9.6)Importing tag 1.9.6 (1.9.6.0)Reading composer.json of zendframework/zendframework1 (release-1.9.7)Importing tag 1.9.7 (1.9.7.0)Reading composer.json of zendframework/zendframework1 (release-1.9.8)Importing tag 1.9.8 (1.9.8.0)Reading composer.json of zendframework/zendframework1 (trunk)Importing branch trunk (dev-trunk)Reading composer.json of zendframework/zendframework1 (bughuntday)Skipped branch bughuntday, no composer file was foundReading composer.json of zendframework/zendframework1 (development-2.0)Skipped branch development-2.0, no composer file was foundReading composer.json of zendframework/zendframework1 (pdo_ibm_ids_support)Skipped branch pdo_ibm_ids_support, no composer file was foundReading composer.json of zendframework/zendframework1 (release-1.0)Importing branch release-1.0 (dev-release-1.0)Reading composer.json of zendframework/zendframework1 (release-1.10)Importing branch release-1.10 (dev-release-1.10)....Reading composer.json of zendframework/zendframework1 (release-1.8)Importing branch release-1.8 (dev-release-1.8)Reading composer.json of zendframework/zendframework1 (release-1.9)Importing branch release-1.9 (dev-release-1.9)Reading composer.json of zendframework/zendframework1 (rob_allen)Skipped branch rob_allen, no composer file was foundReading composer.json of zendframework/zendframework1 (user)Skipped branch user, no composer file was foundUpdating dependencies (including require-dev)
You can safely ignore all excepted by this line, which tells you what you have to set as requested version:
Importing branch trunk (dev-trunk)