Autoloading issue after updating from 7.3 to 8.0

dear all,

what is the correct workflow to upgrade an existing project/site from version 7.3.18 to 8.0 ???

i did:

  • modify composer.json (from ~7.3.0 to ~8.0.0 for neos/flow, welcome, behat, kickstarter and buildessentials)
  • composer update
  • ./flow flow:cache:flush --force
  • ./flow flow:core:migrate My.Package

this works fine, but then a

  • ./flow database:setcharset

results in

Exception #1355480641 in line 392 of /var/www/…/Quickstart/Packages/Framework/Neos.Flow/Classes/Core/Booting/Scripts.php: Required class “My\Package\Command\Test2CommandController” could not be loaded properly for reflection from “My\Package\Command\Test2CommandController”.

<?php
namespace My\Package\Command;

/*
 * This file is part of the My.Package package.
 */

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;

/**
 * @Flow\Scope("singleton")
 */
class Test2CommandController extends CommandController
{

    /**
     * An example command
     *
     * The comment of this command method is also used for Flow's help screens. The first line should give a very short
     * summary about what the command does. Then, after an empty line, you should explain in more detail what the command
     * does. You might also give some usage example.
     *
     * It is important to document the parameters with param tags, because that information will also appear in the help
     * screen.
     *
     * @param string $requiredArgument This argument is required
     * @param string $optionalArgument This argument is optional
     * @return void
     */
    public function exampleCommand($requiredArgument, $optionalArgument = null)
    {
        $this->outputLine('You called the example command and passed "%s" as the first argument.', array($requiredArgument));
    }
}

am i missing a step???

ciao
H.

Hi @hkrebs,

after updating composer dependencies a

./flow flow:package:rescan

might help to address this hiccup.

Also:

./flow flow:cache:flush

(without --force)

Hi @hkrebs

we have a upgrade instructions for each major release. Please have a look at Upgrade Instructions 7.3 → 8.0 - Version 7.x - Neos Upgrade Instructions - API - Neos Docs if the suggestions above don’t help.

dear wilhelm,

:((

does not help. the system.log tells:
“Reflected class names did not match class names to reflect”
and
"Exception in line 31 of /var/www/…/Quickstart/Packages/Framework/Neos.Flow/Classes/Reflection/ClassReflection.php: Required class “My\Package\Command\Test2CommandController” could not be loaded properly for reflection from “My\Package\Command\Test2CommandController”.

and if i remove the file Test2CommandController.php, then the next class generates this error (and so on), so maybe there is some basic setting wrong within my project?!?

ciao
H.

Hi @hkrebs,

so maybe there is some basic setting wrong within my project?!?

I’m sure your setup is fine if it ran under 7.3 :slight_smile:

Those reflection-related errors have a habit to appear after structural changes (like updating dependencies) due to stale cached data.

Last resort would be to run:

rm -rf Data/Temporary

which should remove everything that might have become stale. (see also: Upgrade Instructions 7.3 → 8.0 - Version 7.x - Neos Upgrade Instructions - API - Neos Docs)

Running any flow command afterwards recreates those caches and the hiccup may disappear.

hi @wbehncke,

already removed the temporary files many times, no changes …

ciao
H.

dear @wbehncke,

UPDATE: NO, this is not the problem, i check by moving files around …

if i check the docu at Controller — Flow Framework 8.3.x documentation the file schould be Classes/Acme/Blog/Command/BlogCommandController.php, but my file is at Packages/Application/My.Project/Classes/Controller/Command/XYZCommandController.php

could this be the problem??

caio
H.

Hi to me it seems this error is not caused from an update but rather from trying to follow the guide at Controller — Flow Framework 8.3.x documentation and creating new php classes?

If youre new to php i would strongly suggest to play around with a plain composer project (composer init) and understand how autoloading via psr4 standard works.
Neos / Flow doesnt provide any own helping resources about this as this knowledge is implied.

dear marc,

well, the project is running with framework 7.3 during the last year, and i just tried to update the framework, and did not change the source. autoload might be the problem, but the logfiles do not help that much :(((

ciao
H.

In that case maybe composer is buggy.

composer update or composer install
composer dump-autoload

And via composer show your/package
you can debug if the psr autloading is picked up correctly (please send the output ^^)

The paths in the documentation are outdated but ultimately not important to the example there. You should follow PSR guidelines for class loading depending on how you configured it in your packages composer.json.

I would check if your autoloading configuration is correct and uses PSR-4 autoloading standard, which would put your class in

Your.Package/Class/Command/Test2CommandController.php

Additionally I find this path suspicious /var/www/…/Quickstart/Packages/Framework/Neos.Flow/Classes/Core/Booting/Scripts.php
So your installation resides in /var/Quickstart/ ? That seems off.

Finally this error can happen if development happened on case insensitive filesystems and the Filename case does not exactly match the classname case, this can go unnoticed on the case insensitive filesystem would fails on a case sensitive filesystem likely on the linux I assume from the path above.

@christianm
/var/www/…/Quickstart/packages is correctly
/var/www/ANYDOMAINNAME/Quickstart/Packages (3 dots)

@Marc
composer show my/package resulted in
Package “my/package” not found …

finally i decided to reinstall the environment,
composer create-project --keep-vcs neos/flow-base-distribution MyDirectory 8.0.0
and copied over the source code of my project, and with minor adjustments the project is running again :))))

so the good news are: project running
and the bad news are: no idea what caused the problem, and hopefully an update to the next versions will run smoothly now.

thanks for all your help!

ciao
H.

1 Like

That sounds as if your package is not installed via composer, it should, we do not support just copying source code into an installation anymore. If this works right now that might be more luck than anything. Make sure you setup a project with DistributionPackages folder with your source in, and requiring those packages in the root composer.json if that is not the case yet.

1 Like

my/package was just the example ofc … you have to replace it with your package name ^^