Help:Composer

From semantic-mediawiki.org
Jump to: navigation, search
Table of Contents

Composer is a dependency manager for PHP. For a more in-depth understanding on how Composer works and how to interpret the composer.json file, see Composer net.tuts tutorial.

Usage

Adding packages

Installing a package can be done by running composer require "PackageNameIs:ForVersion".

The require command consists of two parts, the name of the package and second devided by a colon represents the version to be installed.

Remove packages

Remove the PackageNameIs from the composer.json repositories section and run composer update.

Update packages and dependencies

If a new release is available run composer update and if for some reason you need to pull directly from master (using git pull/git fetch) it is recommended that after executing git you run composer dump-autoload from the MW root directory.

Using development versions

!! Add something here !!

Improve autoloader

Composer recommends to use dump-autoload together with option -o to get a faster autoloader especially for production environments. dump-autoload will convert PSR-0/4 packages into a classmap in order to optimize the loading of classes.

Shared hosting

Download composer.phar using curl -s http://getcomposer.org/installer | php into the same folder where the composer.json file is located.

The next step is to run php composer.phar install in order to download all necessary libraries (into the extension/ or vendor/ directory).

Related links

Individual file release

Note Note: Access to a server is needed for this to work, so you might have to ask somebody to do this.

If the above steps didn't work (due to configuration restrictions on part of the hosting company or missing CLI access), it it is suggested to run a local copy and upload the generated files together with the /vendor directory to the target destination:

  1. Create a directory on your server which is able to handle Composer:
    mkdir w
    Change "w" to the name of the script path you are using for your wiki.
  2. Change into the newly created directory:
    cd w
  3. Place your "composer.json" file in this directory.
  4. Run Composer to generate the necessary directories and files either with
    php composer.phar update
    if Composer was installed locally (see above) in this directory or
    composer update
    if Composer was installed globally. You will get the new subdirectories called /extensions/ and /vendor/.
  5. Copy the contents of the "/w/" directory and its subdirectories to the destination on the server which cannot handle Composer.
  6. Do the rest of the installation of SMW and enjoy!

FAQ

!! Add something here !!

See also