Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The requested package ... could not be found in any version

Tags:

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"     } } 
like image 620
yooouuri Avatar asked Oct 18 '16 22:10

yooouuri


Video Answer


2 Answers

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/"         }     } } 
like image 82
Jeff Puckett Avatar answered Sep 18 '22 23:09

Jeff Puckett


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.

Example

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'.

Troubleshooting

To troubleshoot the issue, run:

composer install -vvv 

Also consider running: composer diagnose to identify common Composer errors.

like image 42
kenorb Avatar answered Sep 21 '22 23:09

kenorb