mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-13 09:13:58 +02:00
Add Windows installer
This commit is contained in:
@@ -9,12 +9,39 @@ Composer is a **brilliant** dependency manager for PHP. List your project's depe
|
||||
|
||||
There are already a lot of PHP libraries that are compatible with Composer, ready to be used in your project. These "packages" are listed on [Packagist][1], the official repository for Composer-compatible PHP libraries.
|
||||
|
||||
### Installing Composer
|
||||
Composer is a single file called `composer.phar`, which is a PHP binary archive. It can either be installed locally in each of your project directories or in a single global location that is in your `$PATH` environment variable. The global method is recommended because it enables you to run it from your current working directory with the command `composer`. So when you come across documentation that states to run Composer as `php composer.phar install`, you can substitute that with:
|
||||
### How to Install Composer
|
||||
|
||||
You can install Composer locally (in your current working directory; though this is no longer recommended) or globally (e.g. /usr/local/bin). Let's assume you want to install Composer locally. From your project's root directory:
|
||||
|
||||
curl -s https://getcomposer.org/installer | php
|
||||
|
||||
This will download `composer.phar` (a PHP binary archive). You can run this with `php` to manage your project dependencies. <strong>Please Note:</strong> If you pipe downloaded code directly into an interpreter, please read the code online first to confirm it is safe.
|
||||
|
||||
#### Installing on Windows
|
||||
For Windows users the easiest way to get up and running is to use the [ComposerSetup][6] installer, which 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:
|
||||
|
||||
curl -s https://getcomposer.org/composer.phar -o $HOME/local/bin/composer
|
||||
chmod +x $HOME/local/bin/composer
|
||||
|
||||
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:
|
||||
|
||||
composer install
|
||||
|
||||
Detailed [installation instructions][5] can be found in the Composer documentation. For Windows users the easiest way to get up and running is to use the [ComposerSetup][6] installer. This section will assume you have installed Composer globally.
|
||||
This section will assume you have installed composer globally.
|
||||
|
||||
### How to Define and Install Dependencies
|
||||
|
||||
|
Reference in New Issue
Block a user