Class loading issues?

Flow currently uses two different class loading mechanisms, our custom Flow ClassLoader for Neos packages and the composer autoloader as fallback.

If your files follow the PSR-0 or (preferably) PSR-4 scheme, and you specified so in your composer manifest autoloading of these classes should work out of the box.

If that’s not the case, try running the ./flow package:rescan CLI command to make sure that your PackageStates file is up to date.

When running (unit) tests, only the composer autoloader is used. So running tests only work with packages that are installed via composer (which is recommended anyways).
If you get an error

Error: Class '<Some\Class>' not found

the reason is probably that the package is not loaded via composer.

Solution:
Install the package via composer require <the/package>
If that’s not an option, you can also duplicate the autoload instructions to your global composer manifest, for example:

// ...
"autoload": {
    "psr-4": {
        "<Your\\Namespace>\\": "Packages\\Application\\<Your.PackageKey>\\Classes"
    }
},
// ...

Afterwards make sure to re-generate the composer autoload files via

composer dumpautoload

or

composer install -o
2 Likes