codezero-be / laravel-localized-routes

⭐️ A convenient way to set up and use localized routes in a Laravel app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

composer-include-files dependency breaks autoload-dev files

stevethomas opened this issue · comments

Kind of surprised the only reference to this I can is here: funkjedi/composer-include-files#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.

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...

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.

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