Composer could not find composer .json

I tried installing the composer via brew for:

In usr/local/bin (which Maurice did not have, and I had to do it personally).

brew tap josegonzalez/homebrew-php brew install josegonzalez/php/composer

I can run php composer.phar , but when I do php composer.phar install , I get the error:

Composer could not find a composer.json file in /usr/local/bin To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section

So, I go to https://getcomposer.org/doc/00-intro.md . CTRL + F ".json" and there is nothing there. Seriously composer?

EDIT: What I was trying to do was to have the composer executable vs php composer.phar . Now it works.

+11
source share
9 answers

The Getting Started page is an introduction to the documentation. Most documentation begins with installation instructions, as Composer does.

The page that contains information about the composer.json file is located here - in the "Basic Use" section, second page.

I would recommend reading the entire documentation so that you better understand how to use Composer. I also recommend that you remove what you have and follow the installation instructions in the documentation.

+6
source

To install the composer and add to your global path:

 curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer 

run them in the terminal. He says that if you get an error that usr does not exist, you need to do this manually. I know that an answer has been chosen, so this is for those who can see it in the future, as sometimes happens, and I do not want to be advised to visit another site. Its just two lines, maybe should be in sudo if you have permission error

+10
source

A simple solution is installed using this command:

 curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer 

To install the package, it is very simple:

  composer global require "phpunit/php-invoker=1.1.*" 

Link: Author’s website .

+6
source

In my case, I did not copy all the project files to the folder where I ran composer install . So:

  • Copy the project files (including composer.json ) to the folder
  • open CMD (I use ConEmu ), go to the new folder, run composer install from there
  • It should work or throw errors if the json file is incorrect.

If you want to just execute the composer, create a new composer.json file, for example:

 { "require": { "php": ">=5.3.2" } } 

Then run composer install .

+4
source

I encountered the same error and was able to solve it as follows:

  1. composer diagnose to see if something is wrong with the installed composer version
  2. composer self-update to install the latest version
  3. composer update to update your composer.json file.
+2
source

In my case, I use the estate.
cd ~/Homestead and run composer install .

0
source

You are in the wrong directory. Go to your project directory and start composer update.

0
source

Simply, if you use xampp and your project is not placed in the xampp htdocs folder, move it and go to C: \ xampp \ htdocs \ YOURPROJECTNAME, then write this command, composer install

0
source
  • Create a file called composer.json
  • Make sure Composer can write in the directory you are looking for.
  • Update composer.

    It worked for me.
-2
source

All Articles