升级到稳定版后,CakePHP3 MissingControllerException

This morning I read that CakePHP 3 has been released. I ran a composer update and was greeted with a MissingControllerException. I am pretty sure I did nothing else but updating via composer (I wanted to add the BootstrapUI plugin but reverted all of the changes later). The error message tells me to create a file which is already present (src\Controller\IndexController.php).

I have not changed routes but also tried to use the routes.php from the skeleton app (stripped the comments, only used the default path / which should lead to the index action of the index controller):

Router::defaultRouteClass('Route');

Router::scope('/', function ($routes) {
    $routes->connect('/', ['controller' => 'Index', 'action' => 'display', 'home']);
    $routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
    $routes->fallbacks('InflectedRoute');
});
Plugin::routes(); 

I have also checked the autoloading from composer. It seems to be the identical to the one from the skeleton app. At this point I have no clue what else to look for or what other data I could provide you. Maybe the composer.json will help:

{
    "name": "xyz/appname",
    "description": "",
    "type": "project",
    "keywords": [""],
    "license": "GPL-3.0",
    "authors": [
        {
            "name": "xyz"
        }
    ],
    "require": {
        "php": ">=5.4.16",
        "cakephp/cakephp": "~3.0",
        "mobiledetect/mobiledetectlib": "2.*",
        "cakephp/migrations": "~1.0",
        "cakephp/plugin-installer": "*"
    },
    "require-dev": {
        "phpunit/phpunit": "4.*",
        "cakephp/debug_kit": "~3.0",
        "cakephp/bake": "~1.0"
    },
    "config": {
        "vendor-dir": "vendor/"
    },
    "autoload": {
        "psr-4": {
            "appname\\": "src"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "appname\\Test\\": "tests",
            "Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
        }
    },
    "scripts": {
        "post-install-cmd": "App\\Console\\Installer::postInstall",
        "post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump"
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

I have solved it D'OH. I checked the autoload_psr4.php from composer and found the error. My app is called 4Hoarders. But namespaces and classnames are not allowed to start with a number. So I changed the namespace to Hoarders. The composer.json had the full name 4Hoarders and thus generated the class loading like this:

...
'4Hoarders\\Test\\' => array($baseDir . '/tests'),
'4Hoarders\\' => array($baseDir . '/src'),
...

The solution was changing the composer.json from this:

"autoload": {
    "psr-4": {
        "4Hoarders\\": "src"
    }
},
"autoload-dev": {
    "psr-4": {
        "4Hoarders\\Test\\": "tests",
        "Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
    }
},

to that:

"autoload": {
    "psr-4": {
        "Hoarders\\": "src"
    }
},
"autoload-dev": {
    "psr-4": {
        "Hoarders\\Test\\": "tests",
        "Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
    }
},