codezero-be / laravel-localized-routes

⭐️ A convenient way to set up and use localized routes in a Laravel app.
MIT License
491 stars 45 forks source link

composer-include-files dependency breaks autoload-dev files #66

Closed stevethomas closed 1 year ago

stevethomas commented 1 year ago

Kind of surprised the only reference to this I can is here: https://github.com/funkjedi/composer-include-files/issues/7

Given this composer.json:

    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        },
        "files": [
            "tests/macros.php"
        ]
    },

The tests/macros.php file has stopped autoloading after installing this package and the 0.0.0/composer-include-files dependency.

I understand this is not an issue with this package per se, just wondering whether anyone is aware of a workaround? Seems like something that would break plenty of Laravel app test suites where files are autoloaded.

I made an attempt at debugging the composer plugin but hit a brick wall as I have close to zero knowledge of how composer plugins actually work, and the plugin appears to be based on something copy and pasted from composer v1.

ivanvermeyen commented 1 year ago

Recently I got prompts from composer (while doing composer update I think) to allow such plugins, maybe this is related?

I had to add it to allow-plugins in composer.json:

    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "0.0.0/composer-include-files": true
        }
    },

Edit: Going through the other issues, there may be a deeper cause to the issue, I'll try and see if I can figure it out... Would be cool if there was another way to force the priority of autoload files...

stevethomas commented 1 year ago

Yep I was prompted to add to allow-plugins and accepted; if I set that to false then my error is resolved (meaning that the helpers file is not overloaded, my autoload-dev files are working again, and route() is back to the framework version), so I think the issue is definitely isolated to 0.0.0/composer-include-files.

FWIW this package still works fine, just that we lose the ability to generated localized routes with route() using the 4th parameter.

ivanvermeyen commented 1 year ago

Using my home made solution for this now, it should be fixed in the 3.0 release. 🎉