mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Improved module installation docs for composer.
This commit is contained in:
parent
6a4b8cb6ef
commit
3f6740f185
@ -1,9 +1,9 @@
|
||||
# Installing and Upgrading with Composer
|
||||
|
||||
<div markdown='1' style="float: right; margin-left: 20px">
|
||||
![](../_images/composer.png)
|
||||
</div>
|
||||
|
||||
# Installing and Upgrading SilverStipe with Composer
|
||||
|
||||
Composer is a package management tool for PHP that lets you install and upgrade SilverStripe and its modules. Although installing Composer is one extra step, it will give you much more flexibility than just downloading the file from silverstripe.org. This is our recommended way of downloading SilverStripe and managing your code.
|
||||
|
||||
For more information about Composer, visit [its website](http://getcomposer.org/).
|
||||
@ -37,6 +37,24 @@ browser, and the installation process will be completed.
|
||||
|
||||
Composer isn't only used to download SilverStripe CMS: it can also be used to manage all the modules. In the root of your project, there will be a file called `composer.json`. If you open it up, the contents will look something like this:
|
||||
|
||||
Adding modules
|
||||
|
||||
Installing a module can be done with the following command
|
||||
|
||||
php composer.phar require silverstripe/forum:*
|
||||
|
||||
This command has two parts. First is `silverstripe/forum`. This is the name of the package. You can find other packages with the following command:
|
||||
|
||||
php composer.phar search silverstripe
|
||||
|
||||
This will return a list of package names of the forum `vendor/package`. If you prefer, you can search for pacakges on [packagist.org](https://packagist.org/search/?q=silverstripe).
|
||||
|
||||
The second part, `*`, is a version string. `*` is a good default: it will give you the latest version that works with the other modules you have installed. Alternatively, you can specificy a specific version, or a constraint such as `>=3.0`.
|
||||
|
||||
## Manually editing composer.json
|
||||
|
||||
To remove dependencies, or if you prefer seeing all your dependencies in a text file, you can edit the composer.json file. By default, it will look like this:
|
||||
|
||||
{
|
||||
"name": "silverstripe/installer",
|
||||
"description": "The SilverStripe Framework Installer",
|
||||
@ -52,7 +70,6 @@ Composer isn't only used to download SilverStripe CMS: it can also be used to ma
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
To add modules, you should add more entries into the `"require"` section. For example, we might add the blog and forum modules. Be careful with the commas at the end of the lines!
|
||||
|
||||
{
|
||||
@ -77,8 +94,6 @@ Save your file, and then run the following command:
|
||||
|
||||
php composer.phar update
|
||||
|
||||
We currently use [Packagist](https://packagist.org/) to download manage modules, as this is Composer's default repository. You can find other modules by searching for "SilverStripe" on Packagist.
|
||||
|
||||
## Preparing your project for working on SilverStripe
|
||||
|
||||
So you want to contribute to SilverStripe? Fantastic! There are a couple modules that are helpful
|
||||
@ -89,3 +104,25 @@ So you want to contribute to SilverStripe? Fantastic! There are a couple modules
|
||||
By default, these modules aren't installed, but you can install them with a special version of composer's update command:
|
||||
|
||||
php composer.phar update --dev
|
||||
|
||||
## Creating a 'composer' binary
|
||||
|
||||
Composer is designed to be portable and not require installation in special locations of your computer. This is
|
||||
useful in certain circumstances, but sometimes it's helpful simply to have composer installed in the path of your workstation.
|
||||
|
||||
To do this, we can set up a simple wrapper script in your path. Go to a directory in your path that you can write to. I have `~/bin` set up for this purpose. You could also go to `/usr/bin/` and log in as root.
|
||||
|
||||
cd ~/bin
|
||||
|
||||
Then download composer.phar to this directory and create a 1 line binary file
|
||||
|
||||
curl -s https://getcomposer.org/installer | php
|
||||
echo "php `dirname \`pwd\``/composer.phar \$*" > composer
|
||||
chmod +x composer
|
||||
|
||||
Now check that it works:
|
||||
|
||||
composer help
|
||||
composer list
|
||||
|
||||
In other words, in any of the commands above, replace `php composer.phar` with `composer`.
|
Loading…
Reference in New Issue
Block a user