woocommerce/plugins/woocommerce/lib
Néstor Soriano c06ae5d903
Add a namespace prefix to the Psr/Container package (#33703)
Remove the explicit dependency from the psr/container package

* Prepend the psr/container package classes with a namespace using Mozart. This is done to prevent conflicts with other versions of the package used by other packages or plugins.
* Add changelog file
* Minor documentation/indentation updates
2022-08-02 09:59:32 -07:00
..
packages Add a namespace prefix to the Psr/Container package (#33703) 2022-08-02 09:59:32 -07:00
README.md git mv a few folders 2021-10-19 10:35:45 +13:00
composer.json Add a namespace prefix to the Psr/Container package (#33703) 2022-08-02 09:59:32 -07:00
composer.lock Add a namespace prefix to the Psr/Container package (#33703) 2022-08-02 09:59:32 -07:00

README.md

WooCommerce Lib Directory

This directory contains a dummy package responsible for managing WooCommerce dependencies that require conflict avoidance. The contents of the packages and classes directories get automatically generated by composer install and composer update.

This allows us to prefix namespaces and classmap classes to avoid conflicts with plugins that include the same package. All namespaces are prefixed with Automattic\WooCommerce\Vendor and classmap classes prefixed with WC_Vendor_.

Do not make direct changes in the files contained in packages or classes! Any changes will be lost!

Adding Packages

In order to avoid including the original dependencies in the root autoloader we must utilize require-dev for them. Composer treats require dependencies as transitive while require-dev dependencies get ignored by consumers.

  1. Add package to require-dev section of composer.json
  2. Add package slug to extra/mozart/packages section of composer.json
  3. Run composer run-script build-lib from the root directory (You should now see the package in packages/VendorName/PackageName or classes)

Updating Packages

Updating a package is as easy as changing the version in composer.json and then running composer run-script build-lib from the root directory.

Ignoring Packages

If you would like to add a package which does not undergo conflict avoidance you must take steps to ensure it appears in the root autoloader.

  1. Add package to the require section of both the lib/composer.json and root composer.json file instead of require-dev
  2. Add package slug to extra/mozart/excluded-packages section of composer.json
  3. Run composer run-script build-lib from the root directory (You should not see the package in packages/VendorName/PackageName or classes)