mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-17 03:03:57 +02:00
Update Composer install section, let links use https
This commit is contained in:
@@ -6,20 +6,20 @@ anchor: composer_and_packagist
|
||||
|
||||
## Composer and Packagist {#composer_and_packagist_title}
|
||||
|
||||
Composer is a **brilliant** dependency manager for PHP. List your project's dependencies in a `composer.json` file and,
|
||||
Composer is the recommended dependency manager for PHP. List your project's dependencies in a `composer.json` file and,
|
||||
with a few simple commands, Composer will automatically download your project's dependencies and setup autoloading for
|
||||
you. Composer is analogous to NPM in the node.js world, or Bundler in the Ruby world.
|
||||
|
||||
There are already a lot of PHP libraries that are compatible with Composer, ready to be used in your project. These
|
||||
There is a plethora of PHP libraries that are compatible with Composer and ready to be used in your project. These
|
||||
"packages" are listed on [Packagist], the official repository for Composer-compatible PHP libraries.
|
||||
|
||||
### How to Install Composer
|
||||
|
||||
The safest way to download composer is by [following the official instructions](https://getcomposer.org/download/).
|
||||
This will verify the installer is not corrupt or tampered with.
|
||||
The installer installs Composer *locally*, in your current working directory.
|
||||
The installer installs a `composer.phar` binary in your _current working directory_.
|
||||
|
||||
We recommend installing it *globally* (e.g. a single copy in /usr/local/bin) - to do so, run this afterwards:
|
||||
We recommend installing Composer *globally* (e.g. a single copy in `/usr/local/bin`). To do so, run this command next:
|
||||
|
||||
{% highlight console %}
|
||||
mv composer.phar /usr/local/bin/composer
|
||||
@@ -35,38 +35,6 @@ For Windows users the easiest way to get up and running is to use the [ComposerS
|
||||
performs a global install and sets up your `$PATH` so that you can just call `composer` from any
|
||||
directory in your command line.
|
||||
|
||||
### How to Install Composer (manually)
|
||||
|
||||
Manually installing Composer is an advanced technique; however, there are various reasons why a
|
||||
developer might prefer this method vs. using the interactive installation routine. The interactive
|
||||
installation checks your PHP installation to ensure that:
|
||||
|
||||
- a sufficient version of PHP is being used
|
||||
- `.phar` files can be executed correctly
|
||||
- certain directory permissions are sufficient
|
||||
- certain problematic extensions are not loaded
|
||||
- certain `php.ini` settings are set
|
||||
|
||||
Since a manual installation performs none of these checks, you have to decide whether the trade-off is
|
||||
worth it for you. As such, below is how to obtain Composer manually:
|
||||
|
||||
{% highlight console %}
|
||||
curl -s https://getcomposer.org/composer.phar -o $HOME/local/bin/composer
|
||||
chmod +x $HOME/local/bin/composer
|
||||
{% endhighlight %}
|
||||
|
||||
The path `$HOME/local/bin` (or a directory of your choice) should be in your `$PATH` environment
|
||||
variable. This will result in a `composer` command being available.
|
||||
|
||||
When you come across documentation that states to run Composer as `php composer.phar install`, you can
|
||||
substitute that with:
|
||||
|
||||
{% highlight console %}
|
||||
composer install
|
||||
{% endhighlight %}
|
||||
|
||||
This section will assume you have installed composer globally.
|
||||
|
||||
### How to Define and Install Dependencies
|
||||
|
||||
Composer keeps track of your project's dependencies in a file called `composer.json`. You can manage it
|
||||
@@ -138,9 +106,9 @@ packages' binaries available everywhere, you'd then add the `~/.composer/vendor/
|
||||
|
||||
* [Learn about Composer]
|
||||
|
||||
[Packagist]: http://packagist.org/
|
||||
[Twig]: http://twig.sensiolabs.org
|
||||
[Packagist]: https://packagist.org/
|
||||
[Twig]: https://twig.symfony.com/
|
||||
[VersionEye]: https://www.versioneye.com/
|
||||
[Security Advisories Checker]: https://security.sensiolabs.org/
|
||||
[Learn about Composer]: http://getcomposer.org/doc/00-intro.md
|
||||
[Learn about Composer]: https://getcomposer.org/doc/00-intro.md
|
||||
[ComposerSetup]: https://getcomposer.org/Composer-Setup.exe
|
||||
|
Reference in New Issue
Block a user