Not Find composer.json
Composer could not find a composer.json – Composer is a tool that works for PHP dependency management. To get complete knowledge about composer, you can read in full here.
Composer is very widely used because of the convenience it provides. so do I. but in some conditions, there are errors that make us frustrated.
This is the condition when I have downloaded the project from the server to local in mycomputer vscode.
But when I want to update composer, my visual studio code can’t find the composer.json file, so I get the error “Composer could not find a composer.json“.
Therefore, in this article I want to share with you if you get the error and how to fix it.
How to Fix this Error
Now, create a file with the name format and extension “composer.json”. then fill it with the following line of code:
{
"name": "codeigniter4/appstarter",
"type": "project",
"description": "CodeIgniter4 starter app",
"homepage": "https://codeigniter.com",
"license": "MIT",
"require": {
"php": "^7.3 || ^8.0",
"codeigniter4/framework": "^4"
},
"require-dev": {
"fakerphp/faker": "^1.9",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^9.1"
},
"suggest": {
"ext-fileinfo": "Improves mime type detection for files"
},
"autoload": {
"psr-4": {
"App\\": "app",
"Config\\": "app/Config"
},
"exclude-from-classmap": [
"**/Database/Migrations/**"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\Support\\": "tests/_support"
}
},
"scripts": {
"test": "phpunit"
},
"support": {
"forum": "http://forum.codeigniter.com/",
"source": "https://github.com/codeigniter4/CodeIgniter4",
"slack": "https://codeigniterchat.slack.com"
}
}
Save it.
Now, you have a composer.json file. You can do a composer update.
Hopefully this article is useful for you.