Reputation: 2658
When I want to require my project, the following errors shows up:
The requested package mvc-php/framework could not be found in any version, there may be a typo in the package name.
The "mvc-php/framework" is a git folder.
{
"name": "mvc-php/app",
"repositories": [
{
"type": "path",
"url": "/Users/youri/Documents/Github/framework"
}
],
"require": {
"php": ">=7.0",
"mvc-php/framework": "master"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
}
}
Project i want to require:
{
"name": "mvc-php/framework",
"description": "PHP MVC framework",
"autoload": {
"psr-4": {
"Mvc\\" : "src/"
}
},
"require": {
"php": ">=7.0"
}
}
Upvotes: 26
Views: 41925
Reputation: 17
It is important to note that if you do not add your own mirror source to the global variable, an error will occur where the sub-scene is not found. You can add this in composer.json:
"repositories":[
{
"type":"composer",
"url":"https://packag"
}
],
Upvotes: 2
Reputation: 4305
I changed the name of a package I developed and was just testing a branch on it. I had followed all the correct naming conventions mentioned above but was still getting the given error.
It turns out that for the name change to be picked up, you have to update the package name in composer.json
on the main branch of the package repo (Master
for me) even if you are not using that branch within your project.
Upvotes: 13
Reputation: 166319
The requested package X/Y could not be found in any version.
The requested package needs to be a git folder with the committed and existing composer.json
file. Then to reference specific branch, you need to add the dev-
prefix, so dev-master
, not master
.
Here is the minimal working example:
File: composer.json
{
"require": {
"local/my_package": "dev-master"
},
"repositories": [
{
"packagist.org": false
},
{
"type": "path",
"url": "my_package/"
}
]
}
File: my_package/composer.json
{
"name": "local/my_package",
"require-dev": {
"symfony/console": "*"
}
}
Note: Above file is under local Git repository. To create one, run: git init && git commit -am 'Files'
.
To troubleshoot the issue, run:
composer install -vvv
Also consider running: composer diagnose
to identify common Composer errors.
Upvotes: 16
Reputation: 4103
As this is the first response when searching the error text on Google, I will also put my fix here, despite not being 100% relevant to the OP.
When you are requiring the repo, you need to make sure that your requires statement matches the name of the project in the composer.json of the project.
So if the name had been "name": "mvc-php/app-framework",
in the framework project, then the require would need to be:
"require": {
"mvc-php/app-framework": "dev-master"
},
This is more applicable when you are adding a git repo. Especially when forking, as sometimes the git url might be different from the composer.json name.
Additionally (and this is the part relevant to OP), you now need to do dev-branch_name
instead of branch_name@dev
when requiring. I don't know when this changed, or if the old method is unusable. But this is what the current composer docs now say.
If you want Composer to check out a branch instead of a tag, you need to point it to the branch using the special
dev-*
prefix
Composer Documentation - Versions and Constraints - Branches
Upvotes: 15
Reputation: 40841
Instead of just the branch name, you must require branchName@dev
https://getcomposer.org/doc/articles/versions.md#branches
{
"name": "mvc-php/app",
"repositories": [
{
"type": "path",
"url": "/Users/youri/Documents/Github/framework"
}
],
"require": {
"php": ">=7.0",
"mvc-php/framework": "master@dev"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
}
}
Upvotes: 22