Namespaces in phpdocx

Since the release of version 5.3, PHP counts with namespaces support ( Thanks to those namespaces, libraries developed in PHP have their own scope of execution and do not generate conflicts due to several files with the same class name.

The phpdocx Trial package doesn't support namespaces. Advanced and Premium licenses include two packages: one without namespaces and the other with PHP namespaces.

To work with the namespaces packages is directly related to the project a user can develop, nor is it the PHP version used for it.

For example, if you are going to start a development from scratch, you're free to choose either phpdocx package.


Anyway, the package with namespaces is the most advisable choice, as it will elude conflicts with libraries or classes external to phpdocx.

If you are going to work with a CMS or a framework, find first if it uses namespaces or not, e.g., Wordpress and Drupal 7 don't require namespaces, but others like Drupal 8, Symfony, Laravel or Yii do.

This is the simplest possible code that shows how to generate a DOCX with the package with namespaces:

All the examples included in the packages that support namespaces in the Advanced and Premium licenses make use of these namespaces.