phpjsoncomposer-phpratchet

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?


Solution

  • 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.