PHP namespaces in phpxlsx

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 phpxlsx packages of Basic license and the Trial version don't support namespaces. Advanced and Premium licenses include two packages: one without namespaces and the other with 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 phpxlsx package.


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

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 XLSX with the package with namespaces:

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