Skip to content

Commit c65f6f3

Browse files
committed
英語版のComposer関連ドキュメントをコピー
1 parent 7351578 commit c65f6f3

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

install/composer.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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>

language/oop5/autoload.xml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: ce3a2d381693ccbc10cc4a808c3eb853f3c85c9e Maintainer: hirokawa Status: ready -->
3+
<!-- EN-Revision: 7befd9af043386158ef9080723eb18e03f0625c7 Maintainer: hirokawa Status: ready -->
44
<!-- Credits: mumumu -->
55

66
<sect1 xml:id="language.oop5.autoload" xmlns="http://docbook.org/ns/docbook">
@@ -89,6 +89,26 @@ string(5) "ITest"
8989
Fatal error: Interface 'ITest' not found in ...
9090
*/
9191
?>
92+
]]>
93+
</programlisting>
94+
</example>
95+
<example>
96+
<title>Using Composer's autoloader</title>
97+
<simpara>
98+
&link.composer; generates a <literal>vendor/autoload.php</literal>
99+
which is set up to automatically load packages that are being managed
100+
by Composer. By including this file, those packages can be used without
101+
any additional work.
102+
</simpara>
103+
<programlisting role="php">
104+
<![CDATA[
105+
<?php
106+
require __DIR__ . '/vendor/autoload.php';
107+
108+
$uuid = new Ramsey\Uuid\Uuid::uuid7();
109+
110+
echo "Generated new UUID -> ", $uuid->toString(), "\n";
111+
?>
92112
]]>
93113
</programlisting>
94114
</example>

0 commit comments

Comments
 (0)