jeudi 23 juin 2016

Composer: What's The Difference Between Require and Autoloader?

I'm just getting started with Composer. I want to make sure I correctly understand what Composer does when it downloads and installs packages from Packagist using Composer's defaults. Is this correct:

  1. The "Require" section of the composer.json file specifies the packages that will be downloaded and installed from Packagist. Only those packages listed in the "Require" section will be downloaded and installed.
  2. During the download and install process in Step #1, an autoload_namespaces.php file is created within the default vendor folder (which is created in the root of the project during downloading and installation). This file contains a namespace definition for each downloaded and installed package which is mapped to a folder on the file system
  3. The classes contained within the files downloaded in Step #1 are only accessible via autoload_namespaces.php's namespaces IF EACH DOWNLOADED FILE CONTAINS A NAMESPACE DEFINITION THAT MATCHES ONE OF autoload_namespaces.php's NAMESPACES. If no namespace definition is present within a downloaded file the classes within the file are assigned to the GLOBAL namespace.
  4. The "Autoloader" section of the composer.json file is ONLY used to define custom namespaces and map those custom namespaces to a folder on the file system. Downloaded and installed package namespaces are defined only in the autoload_namespaces.php file AND ARE NOT AFFECTED IN ANY WAY BY THE "Autoloader" SECTION of composer.json, ASSUMING THAT A NAMESPACE PRESENT WITHIN THE autoload_namespaces.php FILE IS NOT DUPLICATED IN THE composer.json "Autoloader" SECTION.

Is my understanding about the above items correct? If not, would you please correct me?

Thanks In Advance -

Aucun commentaire:

Enregistrer un commentaire