Forum


Replies: 2   Views: 1923
Psr-4 compliance
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by net7  · 21-12-2020 - 15:33

Hi!

...I've phpdocx 11 installed on a package that I mantain with composer to include it into my projects.
For some reason, when I run "composer update" on my project I get a lot of messages like "Class X located in Y does not comply with psr-4 autoloading standard. Skipping."

Some examples: 
 

Generating optimized autoload files
Class Phpdocx\Crypto\CryptoPHPDOCX located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/Crypto/CryptoPHPDOCX.php does not comply with psr-4 autoloading standard. Skipping.
Class Phpdocx\Logger\PhpdocxLogger located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/Logger/PhpdocxLogger.php does not comply with psr-4 autoloading standard. Skipping.
Class Phpdocx\License\GenerateDocx located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/License/GenerateDocx.php does not comply with psr-4 autoloading standard. Skipping.
Class Phpdocx\Processing\TemplateProcessing located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/Processing/TemplateProcessing.php does not comply with psr-4 autoloading standard. Skipping.
Class Phpdocx\Processing\BatchTemplateProcessing located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/Processing/BatchTemplateProcessing.php does not comply with psr-4 autoloading standard. Skipping.
Class Phpdocx\Resources\OOXMLResources located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/Resources/OOXMLResources.php does not comply with psr-4 autoloading standard. Skipping.
Class Phpdocx\Parse\RepairPDF located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/Parse/RepairPDF.php does not comply with psr-4 autoloading standard. Skipping.
Class Phpdocx\Parse\PrepareTemplate located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/Parse/PrepareTemplate.php does not comply with psr-4 autoloading standard. Skipping.
Class Phpdocx\Parse\Repair located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/Parse/Repair.php does not comply with psr-4 autoloading standard. Skipping.
Class Phpdocx\Charts\CreateChartFactory located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/Charts/CreateChartFactory.php does not comply with psr-4 autoloading standard. Skipping.
Class Phpdocx\Libs\TCPDF_COLORS located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/Libs/TCPDF_lib.php does not comply with psr-4 autoloading standard. Skipping.
Class Phpdocx\Libs\TCPDF_FONT_DATA located in ./vendor/net7/docs-generator/src/lib/phpdocx/Classes/Phpdocx/Libs/TCPDF_lib.php does not comply with psr-4 autoloading standard. Skipping.

 

How can I deal with that?
Thanks!

Posted by admin  · 21-12-2020 - 16:40

Hello,

The most common issue of that warning is using wrong file paths: https://laracasts.com/discuss/channels/laravel/after-upgrade-laravel-6-to-7-why-psr4-composer-warning or some error about how phpdocx has been to composer.json. Please note that we recommend adding phpdocx to classmap (https://getcomposer.org/doc/04-schema.md#classmap) in composer.json (https://www.phpdocx.com/documentation/cookbook/integrate-phpdocx-with-composer).

As you included support tickets with your license, we recommend you to open a support ticket on MY PHPDOCX page and attach the composer.json file you are using and also post in the same ticket the composer version and we'll check them.

Regards.

Posted by net7  · 22-12-2020 - 10:01

Great! Adding the path on "classmap" worked!
Just for information, at first I thought that I could solve that problem in this way:
 

"psr-4": {
    "Phpdocx\\": "src/lib/phpdocx/Classes/"
}

...and it worked so far, to be honest.
But now the "classmap solution" is definitive.
Thanks a lot!