Uncaught ReflectionException: Class App\Controllers\App does not exist

I read on the PSR4 issue at https://github.com/soberwp/controller/issues/55 . This as I saw these errors on our staging site once I realized it was not loading properly and I checked the logs. So I updated the namespaces locally like so:

<?php

    namespace App\Controllers;

    use Sober\Controller\Controller;

    class App extends Controller
    {
        public function siteName()
        {
            return get_bloginfo('name');
        }
    }

instead of just App;
and tried to deploy. On deploy I got:

PHP Fatal error:  Uncaught ReflectionException: Class App\Controllers\App
does not exist in
/srv/www/staging.example.com/releases/20180226170134/web/app/themes
/uhs-theme/vendor/soberwp/controller/src/Loader.php:74
Stack trace:
#0 /srv/www/staging.example.com/releases/20180226170134/web/app/themes
/uhs-theme/vendor/soberwp/controller/src/Loader.php(74):
ReflectionClass->__construct('App\\Controllers...')
#1 /srv/www/staging.example.com/releases/20180226170134/web/app/themes
/uhs-theme/vendor/soberwp/controller/src/Loader.php(35):
Sober\Controller\Loader->setPath()
#2 /srv/www/staging.example.com/releases/20180226170134/web/app/themes
/uhs-theme/vendor/soberwp/controller/controller.php(22):
Sober\Controller\Loader->__construct(Object(Brain\Hierarchy\Hierarchy))
#3 /srv/www/staging.example.com/releases/20180226170134/web/wp/wp-
includes/class-wp-hook.php(286): Sober\Controller\loader('')
#4 /srv/www/staging.example.com/releases/20180226170134/web/wp/wp-
includes/class-wp-hook.php(310): WP_Hook in
/srv/www/staging.example.com/releases/20180226170134/web/app/themes
/uhs-theme/vendor/soberwp/controller/src/Loader.php on line 74

So I just tried to adjust the release on staging to see if that helped. But I still had issues / these errors. Releases were added, but symlink not changed. I would not know why this interfered with a new release anyways…

How can I get around this now?

Did a

ln -s /srv/www/staging.example.com/releases/20180322072932/ currentnew
mv current current-old
mv currentnew current

and then the site loaded again with the new release using the proper namespaces.

P.S. Did a chown -h web:www-data current to make it web:www-data again

Only on the next deploy I got

TASK [deploy : Get WP theme template and stylesheet roots] **********************************************************************
System info:
  Ansible 2.4.2.0; Darwin
  Trellis at "Update `vagrant_box_version` to `>= 201801.02.0`"
---------------------------------------------------
Error: Could not get 'template_root' option. Does it exist?
Error: Could not get 'template_root' option. Does it exist?
Error: Could not get 'template_root' option. Does it exist?
Error: Could not get 'template_root' option. Does it exist?
failed: [xx.xxxx.xx.xx] (item=template_root) => {"changed": false, "cmd": " wp site list --field=url | xargs -I {} bash -c 'export url=\"{}\"; echo -n \"$url \" && wp option get template_root --skip-plugins --skip-themes --url=$url || echo'\n ", "delta": "0:00:03.292585", "end": "2018-03-22 09:33:05.533853", "failed_when_result": true, "item": "template_root", "rc": 0, "start": "2018-03-22 09:33:02.241268", "stderr": "Error: Could not get 'template_root' option. Does it exist?\nError: Could not get 'template_root' option. Does it exist?\nError: Could not get 'template_root' option. Does it exist?\nError: Could not get 'template_root' option. Does it exist?", "stderr_lines": ["Error: Could not get 'template_root' option. Does it exist?", "Error: Could not get 'template_root' option. Does it exist?", "Error: Could not get 'template_root' option. Does it exist?", "Error: Could not get 'template_root' option. Does it exist?"], "stdout": "http://staging.example.com/fr/ /themes\nhttp://staging.example.com/en/ /themes\nhttp://staging.example.com/ru/ \nhttp://staging.example.com/it/ \nhttp://staging.example.com/de/ \nhttp://staging.example.com/es/ ", "stdout_lines": ["http://staging.example.com/fr/ /themes", "http://staging.example.com/en/ /themes", "http://staging.example.com/ru/ ", "http://staging.example.com/it/ ", "http://staging.example.com/de/ ", "http://staging.example.com/es/ "]}

But that could be related to Error: Could not get 'template_root' option. Does it exist? so checking

Whoa.

Whoooa. You shouldn’t ever have to do these things. :slight_smile:

I’m unlisting this as you’re looking for Composer/PHP support in the Trellis category, and this isn’t really Roots related at all.