Controller doesn't work when installing Sage-based theme via Composer

Just confirmed this using a vanilla Bedrock site and Sage dev-master.

Steps to reproduce:

  1. Set up Bedrock. I used Valet in this instance:
wp valet new bedrock --project=bedrock
  1. Add the following lines to composer.json (to allow roots/sage:dev-master to be installed):
  "config": {
    "preferred-install": "dist"
+  "minimum-stability": "dev",
+  "prefer-stable": true,
  1. Require Sage:
composer require roots/sage:dev-master
  1. Install Sage dependencies:
cd web/app/themes/sage && yarn && yarn run build
  1. Navigate to home page.


38 PM


Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App' not found in /Users/redacted/valet/bedrock/web/app/uploads/cache/25eb1bdac02de62c405a9c99ac70e813c2250241.php on line 2
( ! ) ErrorException: Class 'App' not found (View: /Users/redacted/valet/bedrock/web/app/themes/sage/resources/views/partials/page-header.blade.php) (View: /Users/redacted/valet/bedrock/web/app/themes/sage/resources/views/partials/page-header.blade.php) in /Users/redacted/valet/bedrock/web/app/uploads/cache/25eb1bdac02de62c405a9c99ac70e813c2250241.php on line 2

Note that I get the “Expected” result when cloning roots/sage into web/app/themes then running composer install from the web/app/themes/sage directory.

It seems like for some reason having soberwp/controller in the Bedrock vendor directory doesn’t work, which means that themes based on Sage won’t work if installed via Composer as per this thread: Yes or No - Sage can be part of bedrock using composer

Happy to help troubleshoot this further!

1 Like

composer require roots/sage:dev-master

Please follow the installation instructions for Sage:

They just updated the controller folder location in the repo today (I was dealing with the same issue).

Would suggest trying to move resources/controllers to app/controllers. Maybe your second clone used the updated version.

1 Like

Hi @ben, I’m building a theme based on Sage which I’d like to be installable using Composer — that’s why I didn’t follow the normal instructions. Is distributing a Sage-based theme for installation via Composer possible? It appears that it isn’t right now although the thread I linked to above suggests that it should be. Thanks for any clarification you can provide.

@patram1121 I’ve been tracking those changes and I can confirm I’m using the latest.

Did you confirm that your controllers are located in app/controllers?

Yes, I did. I tested this with a fresh clone 30 minutes ago.

Sure it is. But you wouldn’t require the base Sage theme, you would create your own repository/fork/however you want to distribute it.

Sorry, I guess I wasn’t clear. I did create a Sage-based theme with the same dependencies as current dev-master. If I install it using Composer in a Bedrock environment (and Controller ends up in Bedrock’s vendor directory) then Controller doesn’t work. The only way I can get the Controller to work in a Bedrock environment is if Sage’s/my fork’s Composer dependencies are installed in web/app/themes/my-sage-fork/vendor.

I’ve been able to reproduce this issue using the following repos:

  1. Bedrock:
  2. Sage Controller:

The latter was created using composer create-project roots/sage:dev-master sage-controller. The only modification I made was changing the name in composer.json so that I could install the fork as a VCS repository.

I’ll note that the App, Home and About classes declared in app/controllers are not in the array of classes returned by get_declared_classes(). I can confirm that the files are being included by Bedrock’s autoloader but the classes themselves are not available. My assumption is that this has something to do with this method in roots/sage-lib and the context in which classes are loaded (at the Bedrock level vs. at the Sage level) but I don’t know enough about Illuminate/View to speculate any further.

Hey, y’all. I can also confirm this issue: a Sage-based theme in its own Git repo, with its own composer.json (the standard Sage one modified with the theme’s name) doesn’t autoload Controller properly.

I can confirm that, when composer install-ing the theme the first time, soberwp/controller is installed as a dependency of Bedrock, and that running composer install in the theme directory also installs Controller in the theme’s vendor directory, but neither instance seems to load, or work.

git clone-ing the theme works just fine, but I’d like to pull it in as a composer dependency if possible.

Other dependencies, like the stuff that makes Blade work, work fine, so perhaps this is a Controller-specific problem? @withjacoby can you lend some insight?

Thanks, y’all.

1 Like

There’s a temporary fix via @anon66789415 in the related GitHub issue:


Ugghhhh I have to commit the build artifacts! :wink:

I know this is quite a bit later, but I hit this issue recently. My Digital Ocean dev server is running PHP < 7.1 so I had to install a legacy version of Sage. I pulled the composer.json from the 9.0.0 release, ran composer install and everything seemed to go OK. Then I saw the Class 'App' not found error.

I found that it was just a capitalisation issue. The theme’s path to App was app/Controllers/App.php - note the capital “C”. I changed it to lowercase so the path became app/controllers/App.php and hey presto! It worked.

Hello guys,

I have something similar.

Has anyone figured out how to fix this problem with controller?

I will be very appreciate for any help.

Thanks in advance.

It looks like there’s a couple fixes listed in this thread as well as the GH issue

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