jjudge's avatar

jjudge wrote a comment+100 XP

2mos ago

@jjudge Found the answer:

{
    "autoload": {
        "exclude-from-classmap": [ "**/*.test.php"]
    }
}

Using a consistent filename pattern means they can be filtered out when the classmap is generated. PSR-4 classes would only be locaed in the classmap when optimising for production:

composer dump-autoload -o

The concensus is it's not worth the effort, but it probably will depend on the project.

jjudge's avatar

jjudge wrote a comment+100 XP

2mos ago

So presumably the co-located tests will be pulled into the composer optimised autoload cache in production. Is there a way to filter them out, to tell composer not to index the tests? And the other question is whether that impacts the performance anway. I'm guessing the autoload cache will be bigger, so will it eat more into memory?