I tried to install composer via brew per:
In usr/local/bin
(which was not on Mavricks and I had to make personally) I did.
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 the https://getcomposer.org/doc/00-intro.md
. CTRL+F ".json" and nothing's there. Seriously composer?
EDIT:
What I was trying to do was to have composer
executable vs php composer.phar
. This works at this point from this now.
This question is related to
php
json
composer-php
osx-mavericks
In my case, I am using homestead.
cd ~/Homestead
and run composer install
.
If you forget to run:
php artisan key:generate
You would be face this error : Composer could not find a composer.json
In my case I'm in wrong directory,
My directory Path
eCommerce-shop/eCommerce
I am in inside eCommerce-shop and executing this command composer intsall so that't it throwing this error.
You are in wrong directory. cd to your project directory then run composer update.
I encountered the same error, and was able to solve it as follows:
composer diagnose
to see if something is wrong with the version of composer installedcomposer self-update
to install the latest version composer update
to update your composer.json
file. To install composer and add to your global path:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
run these in terminal. It does say if you get an error that usr doesn't exist, you do need to manually make it. I know an answer was selected, so this is for anyone who may see this in the future, as i am sometimes, and don't want to be advised to visit yet another site. Its simple just two lines, might have to be in sudo if you have permission error
You could try updating the composer:
sudo composer self-update
If that doest works remove composer files & then use: SSH into terminal & type :
$ cd ~
$ sudo curl -sS https://getcomposer.org/installer | sudo php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer
If you face an error that says: PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1
To install package use:
composer global require "package-name"
Simple solution is install via this command :
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
To install package it's very simple :
composer global require "phpunit/php-invoker=1.1.*"
In my case, I did not copy all project files to the folder where I was running composer install
. So do:
composer.json
) to foldercomposer install
from thereIf you just want to make composer run, create a new composer.json
file with for example:
{
"require": {
"php": ">=5.3.2"
}
}
Then run composer install
.
Source: Stackoverflow.com