This error occurs due to 3 possible factors:
Typing error
Package is not available
You are trying to use a dev
package%
The first error is easy to understand, the problem is the second one, it is not very clear what "package" is or where we should leave it available, at first I thought that the composer consults github and / or bitbucket, but in fact this is not how it works, you can use any repository other than github, but you will have to make the .git
available as a package and this.
On the link site, there is a link called Browse Packages this is where magic happens:
Whenaccessingwearetakentothe link , then you just have to sign in with your account by clicking use github (if it is another repository like bitbucket will have create an account manually, click Create One Now for this):
Afterthishewillaskforthenecessarypermissions,justaccept,readandthenaccept.
Theninthetopmenuclick Submit , in the "Repository URL (Git / Svn / Hg)" field, you must paste the githube%% (supports other formats), to get the .git go to your repository and at the top you will have the link, for example:
Thenjustpasteitintothe Submit field and then click Check:
Iftheerroroccurs:
TheCSRFtokenisinvalid.Pleasetrytoresubmittheform.
It'sbecausethepagehasexpired,justclickthe Submit link at the top and try again. You may see other repositories (of others) with similar names, it is the opportunity to think of a more creative name for yours, but it is totally optional, just click the Submit button to confirm.
It should look something like this:
YouneedtocreateaReleaseingithub(ifyouareusinggithub),gotoReleasesinyourrepository:
ThenclicktheCreateanewreleasebutton,fillouttheformandclickthePublishrelease
HoweversomerepositoriesdonothaveReleases(thisisthethirdproblemImentionedatthebeginning)eventhoughitisinPackgist,thisisbecausetheprojectisstillunderdevelopment,soitisnecessarytomodifyyour.git
ofyourprojectandaddthis:
"minimum-stability": "dev",
"prefer-stable": true,
It should look like this:
{
"name": "foo/bar",
"description": "Framwork foo",
"type": "project",
"authors": [
{
"name": "Foo bar",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.3.0",
"[vendor]/[nome do repositorio]": "*"
},
"minimum-stability": "dev",
"prefer-stable": true
}
After this, just test your repository in your project that is in your machine:
cd c:\wamp\projeto1
composer update
The result must be something like this:
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing brcontainer/composer-test-2 (v1.0.0)
Downloading: 100%
Installing by command line to your project
After preparing everything, note that it is possible to download the package without adding to your project composer.json, like this:
composer require [vendor]/[nome do repositorio]
Or:
php composer.phar require [vendor]/[nome do repositorio]
However if the project does not have a Release it is necessary to execute the command like this:
composer require [vendor]/[nome do repositorio]:dev-master
Or:
php composer.phar require [vendor]/[nome do repositorio]:dev-master