DataTables / Editor-PHP

PHP server-side libraries for Editor
Other
35 stars 22 forks source link

Composer 2.0: non psr-4 class DataTables\Vendor\htmLawed #3

Closed FGIKCM closed 4 years ago

FGIKCM commented 4 years ago

With latest versions of Composer, a warning appears when getting the library:

Deprecation Notice: Class DataTables\Vendor\htmLawed located in hidden/vendor/datatables.net/editor-php\Vendor\htmLawed\htmLawed.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://hidden/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201

As htmLawed.php is in Vendor/htmLawed folder, it should be in a namespace DataTables\Vendor\htmLawed, I think. Or be in the parent folder?

Best regards

DataTables commented 4 years ago

Thank you - we'll get this sorted for the next release!

DataTables commented 4 years ago

I've just been looking into this, and I'm not seeing that notice pop up:

$ php ../composer.phar -vv install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Dependency resolution completed in 0.000 seconds
Analyzed 49 packages to resolve dependencies
Analyzed 71 rules to resolve dependencies
Package operations: 1 install, 0 updates, 0 removals
Installs: datatables.net/editor-php:1.9.4
  - Installing datatables.net/editor-php (1.9.4): Loading from cache
 Extracting archive    REASON: Required by the root package: Install command rule (install datatables.net/editor-php 1.8.0|install datatables.net/editor-php 1.8.1|install datatables.net/editor-php 1.9.0|install datatables.net/editor-php 1.9.1|install datatables.net/editor-php 1.9.2|install datatables.net/editor-php 1.9.3|install datatables.net/editor-php 1.9.4)

Writing lock file
Generating autoload files
$ php ../composer.phar --version
Composer version 1.10.13 2020-09-09 11:46:34

Is there something I need to do to get that error to show?

FGIKCM commented 4 years ago

I just tried to update to the same Composer version as yours, and I can still reproduce this:

D:\xxx>composer -V
Composer version 1.10.13 2020-09-09 11:46:34

D:\xxx>composer dump-autoload
Generating optimized autoload files
Deprecation Notice: Class DataTables\Vendor\htmLawed located in D:/xxx/vendor/datatables.net/editor-php\Vendor\htmLawed\htmLawed.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/xxx/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Generated optimized autoload files containing 2082 classes

But in my composer.json file, I see that I have optimize-autoloader enabled, (the doc says it should be the default value for production env.)

{
    ...
    "require" : {
        ...
    },
    "config" : {
        "optimize-autoloader": true
    }
}

So, perhaps this would do the trick?

composer dump-autoload --optimize
DataTables commented 4 years ago

That'll do it - thanks! I've just committed a fix to address this and will push it out shortly.