PHP Composer: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
|||
Line 8: | Line 8: | ||
* the Packagist, the default package repository. | * the Packagist, the default package repository. | ||
== Tutorial Remarks == | |||
Install faker: | |||
<pre> | |||
$ mkdir /Users/Shared/Sources/Tutorials/Composer | |||
$ cd /Users/Shared/Sources/Tutorials/Composer | |||
$ composer require fzaninotto/faker | |||
</pre> | |||
Under the hood, Composer downloads the zip file of Faker from Github. | |||
Besides downloading the required package, Composer will also create some internal files. | |||
The structure look like: | |||
<pre> | |||
Composer | |||
-rw-r--r-- 1 xxxx yyyy 62B May 15 12:09 composer.json | |||
-rw-r--r-- 1 xxxx yyyy 2.1K May 15 12:09 composer.lock | |||
drwxr-xr-x 5 xxxx yyyy 160B May 15 12:09 vendor | |||
-rw-r--r-- 1 xxxx yyyy 178B May 15 12:09 autoload.php | |||
drwxr-xr-x 10 xxxx yyyy 320B May 15 12:09 composer | |||
-rw-r--r-- 1 xxxx yyyy 13K May 15 12:09 ClassLoader.php | |||
-rw-r--r-- 1 xxxx yyyy 1.0K May 15 12:09 LICENSE | |||
-rw-r--r-- 1 xxxx yyyy 147B May 15 12:09 autoload_classmap.php | |||
-rw-r--r-- 1 xxxx yyyy 149B May 15 12:09 autoload_namespaces.php | |||
-rw-r--r-- 1 xxxx yyyy 211B May 15 12:09 autoload_psr4.php | |||
-rw-r--r-- 1 xxxx yyyy 1.7K May 15 12:09 autoload_real.php | |||
-rw-r--r-- 1 xxxx yyyy 830B May 15 12:09 autoload_static.php | |||
-rw-r--r-- 1 xxxx yyyy 1.5K May 15 12:09 installed.json | |||
drwxr-xr-x 3 xxxx yyyy 96B May 15 12:09 fzaninotto | |||
drwxr-xr-x 9 xxxx yyyy 288B May 15 12:09 faker | |||
... | |||
</pre> | |||
Revision as of 12:43, 15 May 2020
Composer
is a tool for dependency management in PHP.
It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
Composer is an application-level package manager for PHP.
It is inspired by NodeJs's NPM and Ruby's Bundler, and is currently the recognized package manager by the community.
The Composer ecosystem consists of two parts:
- the Composer, which is the command-line utility for installing packages,
- the Packagist, the default package repository.
Tutorial Remarks
Install faker:
$ mkdir /Users/Shared/Sources/Tutorials/Composer $ cd /Users/Shared/Sources/Tutorials/Composer $ composer require fzaninotto/faker
Under the hood, Composer downloads the zip file of Faker from Github. Besides downloading the required package, Composer will also create some internal files. The structure look like:
Composer -rw-r--r-- 1 xxxx yyyy 62B May 15 12:09 composer.json -rw-r--r-- 1 xxxx yyyy 2.1K May 15 12:09 composer.lock drwxr-xr-x 5 xxxx yyyy 160B May 15 12:09 vendor -rw-r--r-- 1 xxxx yyyy 178B May 15 12:09 autoload.php drwxr-xr-x 10 xxxx yyyy 320B May 15 12:09 composer -rw-r--r-- 1 xxxx yyyy 13K May 15 12:09 ClassLoader.php -rw-r--r-- 1 xxxx yyyy 1.0K May 15 12:09 LICENSE -rw-r--r-- 1 xxxx yyyy 147B May 15 12:09 autoload_classmap.php -rw-r--r-- 1 xxxx yyyy 149B May 15 12:09 autoload_namespaces.php -rw-r--r-- 1 xxxx yyyy 211B May 15 12:09 autoload_psr4.php -rw-r--r-- 1 xxxx yyyy 1.7K May 15 12:09 autoload_real.php -rw-r--r-- 1 xxxx yyyy 830B May 15 12:09 autoload_static.php -rw-r--r-- 1 xxxx yyyy 1.5K May 15 12:09 installed.json drwxr-xr-x 3 xxxx yyyy 96B May 15 12:09 fzaninotto drwxr-xr-x 9 xxxx yyyy 288B May 15 12:09 faker ...
See also
Internal
External
- Get Composer, Home page.
- Composer Documentation, Composer Home page Documentation.
- Composer Packgist, Packagist is the main Composer Repository.
Tutorial
- Star Tutorial, Modern PHP Developer Composer.
Creates the test composer projectfzaninotto/faker
. See the directory /Users/Shared/Sources/Tutorials/Composer.