Integrate phpdocx with Composer projects
To run phpdocx with Composer it is mandatory to use the package that supports namespaces. This package is available for Advanced and Premium licenses.
Composer has become the default dependency manager for PHP. It has simplified the creation of new projects thanks to its automatic download of dependencies and a thorough version control of packages.
The type of licenses of phpdocx disallow the existence of a package in public repositories, like Packagist (https://packagist.org/).
The installation of phpdocx in a project that works with Composer must be manual and should follow these three easy steps:
- 1- Download the package with support for namespaces from the MY PHPDOCX page. Unzip the complete package in a subfolder inside vendor or the route you use for third parties libraries, e.g., vendor/phpdocx.
- 2- Open the file composer.json and add the following classmap in the autoload section:
- 3- Go to the root of the project and update the Composer autoloader:
That's all you need to have your library fresh and ready to use it from your project, for example, creating a document with text: