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.
The installation of phpdocx in a project that works with Composer can be manual or using a private repository, e.g., Github or Bitbucket. phpdocx licenses allow code editing but no redistribution.
To perform a manual integration just 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:
In order to run a private repository you have to generate and use an SSH key:
- GitHub: https://stackoverflow.com/questions/40619393/how-to-add-private-github-repository-as-composer-dependency
- GitHub: https://keevitaja.com/posts/using-github-private-repositories-as-composer-dependencies
- Bitbucket: https://dev.to/minompi/using-a-bitbucket-private-repository-in-your-projects-24j9