From 7befd9af043386158ef9080723eb18e03f0625c7 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Mon, 25 Nov 2024 12:51:59 -0800 Subject: [PATCH] Add information about Composer and example of using its autoloader (#3677) Co-authored-by: Theodore Brown --- install/composer.xml | 49 ++++++++++++++++++++++++++++++++++++++ language/oop5/autoload.xml | 20 ++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 install/composer.xml diff --git a/install/composer.xml b/install/composer.xml new file mode 100644 index 000000000000..dcb953436ecf --- /dev/null +++ b/install/composer.xml @@ -0,0 +1,49 @@ + + + + + Installation of Composer and third-party packages + + + Introduction to Composer + + &link.composer; is a dependency manager for PHP that makes it possible + to define third-party code packages used by a project that can + then be easily installed and updated. It leverages the built-in + class autoloading features + of PHP, repositories of PHP packages such as + Packagist, and common project + layout and coding conventions. + + + For example, if a PHP application or website needs + to work with UUID values, + Ben Ramsey's + ramsey/uuid package that implements the + widely known and used types of UUIDs that are defined by + RFC 4122 could be used. + + + Briefly, this is done by creating a composer.json + in the project, using Composer to install the latest version of the + package, and including Composer's autoload script to make it available + to the code. The Composer + "Basic Usage" documentation goes into this in more depth. + + + + <literal>composer.json</literal> that requires a single package + + + + + + + + diff --git a/language/oop5/autoload.xml b/language/oop5/autoload.xml index 91f8b902f0aa..41c4d6a9211a 100644 --- a/language/oop5/autoload.xml +++ b/language/oop5/autoload.xml @@ -79,6 +79,26 @@ string(5) "ITest" Fatal error: Interface 'ITest' not found in ... */ ?> +]]> + + + + Using Composer's autoloader + + &link.composer; generates a vendor/autoload.php + which is set up to automatically load packages that are being managed + by Composer. By including this file, those packages can be used without + any additional work. + + + ", $uuid->toString(), "\n"; +?> ]]>