|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<!-- $Revision$ --> |
| 3 | +<!-- EN-Revision: 3678a6db126048bf052180c85577daab044759aa Maintainer: takaram Status: ready --> |
| 4 | + |
| 5 | +<chapter xml:id="install.composer" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="chunk:false"> |
| 6 | + <title>Installation of Composer and third-party packages</title> |
| 7 | + |
| 8 | + <sect1 xml:id="install.composer.intro"> |
| 9 | + <title>Introduction to Composer</title> |
| 10 | + <simpara> |
| 11 | + &link.composer; is a dependency manager for PHP that makes it possible |
| 12 | + to define third-party code packages used by a project that can |
| 13 | + then be easily installed and updated. It leverages the built-in |
| 14 | + <link linkend="language.oop5.autoload">class autoloading features</link> |
| 15 | + of PHP, repositories of PHP packages such as |
| 16 | + <link xlink:href="&url.packagist;">Packagist</link>, and common project |
| 17 | + layout and coding conventions. |
| 18 | + </simpara> |
| 19 | + <simpara> |
| 20 | + For example, if a PHP application or website needs |
| 21 | + to work with <abbrev>UUID</abbrev> values, |
| 22 | + <link xlink:href="&url.packagist.package;ramsey/uuid">Ben Ramsey's |
| 23 | + <literal>ramsey/uuid</literal> package</link> that implements the |
| 24 | + widely known and used types of UUIDs that are defined by |
| 25 | + <link xlink:href="&url.rfc;4122">RFC 4122</link> could be used. |
| 26 | + </simpara> |
| 27 | + <simpara> |
| 28 | + Briefly, this is done by creating a <literal>composer.json</literal> |
| 29 | + in the project, using Composer to install the latest version of the |
| 30 | + package, and including Composer's autoload script to make it available |
| 31 | + to the code. The <link xlink:href="&url.composer;doc/01-basic-usage.md">Composer |
| 32 | + "Basic Usage" documentation</link> goes into this in more depth. |
| 33 | + </simpara> |
| 34 | + <example> |
| 35 | + <title> |
| 36 | + <literal>composer.json</literal> that requires a single package |
| 37 | + </title> |
| 38 | + <programlisting role="javascript"> |
| 39 | +<![CDATA[ |
| 40 | +{ |
| 41 | + "require": { |
| 42 | + "ramsey/uuid": "^4.7" |
| 43 | + } |
| 44 | +} |
| 45 | +]]> |
| 46 | + </programlisting> |
| 47 | + </example> |
| 48 | + |
| 49 | + </sect1> |
| 50 | +</chapter> |
0 commit comments