Finally - how to solve the good old "App not found" error!

After reading all posts, reading about psr4 once again, I dove deep… Here’s what I’ve found:

In my case, the error was that what tried to autoload the App was not sage, but bedrock. Running a few breakpoints gave this result:

PHP Warning: include(/bedrock/vendor/composer/../../web/app/themes/sage/app/Controllers/App.php):
failed to open stream: No such file or directory in 
bedrock/vendor/composer/ClassLoader.php on line 444

Meaning that it somehow used the theme’s (sage’s) autoloader from bedrock, from the upper composer project, instead of the theme’s autoloader. To solve this, I’ve simply added this line to my bedrock’s composer.json:

  "autoload": {
    "psr-4": {
      "App\\": "web/app/themes/sage"
    }
  },

Please note that the theme name .../themes/sage should be replaced with the theme name you gave to your theme, i.e. .../themes/my-theme.

Another thing is to change App::title() to App\Controllers\App::title() so that it can be autoloaded properly. For whatever reason it didn’t work with just App

This topic was automatically closed after 42 days. New replies are no longer allowed.