Areso
Areso

Reputation: 97

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

I have successfully installed Composer in the root directory (that was the default choice) on my Linux/Apache server using their installation 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 top of their's page) using the notepad and filezilla to download the file to my application's root directory.

Then I open Putty and type: cd /var/www/websocket (application directory, where already was placed json file)

Then I run Composer using:

php ~/composer.phar install

and get following error:

[Seld\JsonLint\ParsingException] "./composer.json" does not contain valid JSON Parse error on line 1: php ~/composer.phar ^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

My composer.json file contains, in accordance to instructions,

php ~/composer.phar require cboden/ratchet

What I should to do to install it properly?

Upvotes: 1

Views: 13341

Answers (2)

opia austin
opia austin

Reputation: 74

i know i am late but just incase someone runs into this error

if you are using brew , all you need to do is brew install composer

if its already installed it will update it and set it all up for you

hope this helps someone.

Upvotes: 0

pinkal vansia
pinkal vansia

Reputation: 10310

composer.json should only contain valid json string. Following is not a json

php ~/composer.phar require cboden/ratchet

Replace composer.json content with the following,

{
  "require" : {
     "php": ">=5.4.2",
     "cboden/Ratchet": "dev-master"
  }
}

And then run following command from the same directory that contains composer.json

php ~/composer.phar update

For detailed schema of composer.json read this.

Upvotes: 3

Related Questions