where do I put composer.json

Angad Dubey

I have installed composer.

My project dir tree looks something like this

/home/myproject/public_html/myproject.com

I initially installed it in:

/home/myproject/public_html/myproject.com/bin/composer/

But later moved it to:

/home/myproject/usr/local/bin/composer

Questions:

  1. Where to I create composer.json ?
  2. In the official docs they mention that in order to install new packages I need to write a require key in the json format in that file, does this mean that I dont have to upload the package through ftp?
  3. The docs further say that I can simply install dependencies like ths:

    php composer.phar install

I dont understand the workflow of this process (im fairly new).. what exactly do I need to do to get some packages going (like Respect)

BillyBigPotatoes

Composer has 2 basic elements for you to consider:

  1. The composer.php file itself - this can be located anywhere on your system - usually it is convenient to have it in you search path so you can invoke it by name (no path) from the command line.

  2. Composer.json - this file is the configuration for your project. This is usually best located at the top level of your project. Ideally this is a directory outside the scope of your web server - so that it will never be exposed or served.

Symfony2 has some great documentation and examples of composer in use.

Also be aware that some packages you reference via composer will themselves have composer files - to ensure they match your required dependancies - and they may also have their own dependancies that need to be considered.

I would install composer.json in the following

/home/myproject/composer.json

It would be out of scope of the web server and could be used to manage many assets e.g.

  public_html/
  libs/
  config/
  docs/
  vendor/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related