Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Composer can't find composer.json file for my project

Tags:

composer-php

I have successfully installed Composer in the root directory (that was the default choice) on my Linux/Apache server using their installation guide. It's all been very simple so far, except for one php.ini tweak I've had to make (detect_unicode = Off) but now I'm stuck.

I'm trying to install Ratchet using Composer, with the use of this guide:

http://socketo.me/docs/install

It says I need to "create a file called composer.json in your project folder". So I created that file (with the contents they gave on their page) using the cPanel file manager, in my application's root directory. However, when I run Composer using:

php composer.phar install

PuTTy gives the following error message:

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

But this doesn't seem to make sense, why would I place the JSON file in the server's root if the documentation says to place it in the project folder? What am I missing?

like image 854
sveti petar Avatar asked Nov 20 '13 20:11

sveti petar


People also ask

Where is my composer json file?

composer. json is a JSON file placed in the root folder of PHP project.

How do I add a composer to a project?

To install Composer in your project, you need an important file called “composer. json”. This file is where you define all the dependencies/packages needed in your project. So quickly create a project folder, open it in any editor of your choice and create this file “composer.

Why is my composer not working?

Double-check you don't have typos in your composer. json or repository branches and tag names. Be sure to set the right minimum-stability. To get started or be sure this is no issue, set minimum-stability to "dev".

How do I check if Composer is installed in PHP?

Updating and Uninstalling Composer From there, you can verify Composer's installation by running --version command from the terminal. If the command returns the version code, it means the Composer is installed, and you are ready for the next steps.


2 Answers

I just found on other topic that you can use :

php composer.phar --working-dir=/home/user/folder/ update
like image 105
Charly Avatar answered Oct 18 '22 01:10

Charly


It looks like you're executing php composer.phar install in /root path.

like image 42
Eduardo Casas Avatar answered Oct 18 '22 02:10

Eduardo Casas