Are there solutions to get SoberWP Controller working with Sage 9 and PHP 8.1?

Hi all,

I’ve got a couple of projects that’s built on Sage 9. So far I was able to use the solution in this article but it recently stopped working and Wordpress returns a Fatal error.

The error message:

( ! ) Fatal error: Uncaught ReflectionException: Class "App\Controllers\App" does not exist in /www/kinsta/public/wordpress-test/wp-content/themes/sage_9.1/vendor/soberwp/controller/src/Loader.php on line *75*
( ! ) ReflectionException: Class "App\Controllers\App" does not exist in /www/kinsta/public/wordpress-test/wp-content/themes/sage_9.1/vendor/soberwp/controller/src/Loader.php on line *75*

This is my composer.json file

{
  "name": "roots/sage",
  "type": "wordpress-theme",
  "license": "MIT",
  "description": "WordPress starter theme with a modern development workflow",
  "homepage": "https://roots.io/sage/",
  "authors": [
    {
      "name": "Ben Word",
      "email": "ben@benword.com",
      "homepage": "https://github.com/retlehs"
    },
    {
      "name": "Scott Walkinshaw",
      "email": "scott.walkinshaw@gmail.com",
      "homepage": "https://github.com/swalkinshaw"
    },
    {
      "name": "QWp6t",
      "email": "hi@qwp6t.me",
      "homepage": "https://github.com/qwp6t"
    }
  ],
  "keywords": ["wordpress"],
  "support": {
    "issues": "https://github.com/roots/sage/issues",
    "forum": "https://discourse.roots.io/"
  },
  "autoload": {
    "psr-4": {
      "App\\": "app/"
    }
  },
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/jeh5256/sage-installer"
    },
    {
      "type": "vcs",
      "url": "https://github.com/jeh5256/sage-lib"
    }
  ],
  "require": {
    "php": "^8.1",
    "composer/installers": "^2.0",
    "soberwp/controller": "~2.1.0",
    "roots/sage-installer": "^2.0",
    "roots/sage-lib": "dev-master"
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "^2.8.0"
  },
  "scripts": {
    "test": [
      "phpcs src --extensions=php --standard=PSR2"
    ],
    "post-create-project-cmd": [
      "Roots\\Sage\\Installer\\ComposerScript::postCreateProject"
    ]
  },
  "config": {
    "allow-plugins": {
      "kylekatarnls/update-helper": true,
      "composer/installers": false
    }
  }
}

This only stopped working a couple of days ago. If I downgrade the PHP to 8.0 then there are no issues.

Thanks in advance.

1 Like

Which WordPress- & PHP-version are you using when the error occurs?

See this thread: Uncaught ReflectionException after composer update · Issue #55 · soberwp/controller · GitHub

3 Likes

Thanks @evance! It was exactly that, I found that a couple of hours ago.

Had to update my controllers from this

To this

I’m using WordPress 6.5.3 and PHP 8.2

2 Likes