Sage: Class 'App' not found

Created on 7 Aug 2019  路  16Comments  路  Source: roots/sage

Description

Can't get Sage to install properly.

Steps to reproduce

  1. Install Sage through composer or git
  2. Activate

Expected behavior: Working homepage

Actual behavior: Empty homepage with errors

> ( ! )聽Fatal error: Uncaught SymfonyComponentDebugExceptionFatalThrowableError: Class 'App' not found in /srv/www/domain.tld/current/web/app/uploads/cache/a1e3c48b0395f0adfcf4ce178f4dd567983a6e72.php on line聽2

Reproduces how often: 100%

Versions

Windows 10 Pro 1903
VirtualBox : 5.2.32
Vagrant : 2.2.4
Ansible : 2.7.5
Trellis : 1.0.3
Sage : 9.0.9
WSL : Ubuntu 18.04.2 LTS
WSL Node : 8.10.0
WSL NPM : 3.5.2
WSL Composer : 1.9.0
WSL PHP : 7.1.3

Additional information

I also tried to downgrade my PHP version in trellis to 7.1 still not working.

Most helpful comment

I have the same issue. Any update? Any one solved this bug?
-thanks

All 16 comments

Assuming you have ran composer install inside of Sage's directory, perhaps try clearing your cache located in app/uploads/cache/.

Nonetheless, this is not a bug or issue directly with Sage and is better suited for the Roots Discourse if further help is needed.

Even when clearing the cache it's not working. I'm sorry to ask you, but why are you so confident it's not a bug and it's user related ? I destroyed my VM and local files so many time that the cache got rebuild every time I tried. Seriously I spent many hours making sure it was not my manipulation that cause the bug.

What is your install / build step order for Sage?

This problem has been mentioned multiple times and has to do with Controller. There should be plenty out there to debug it no matter your specific situation by searching:

( ! ) Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App' not found in 

I've read the 3 you just sent me, none worked for me. And yes I know how to do a google search I already searched that particular error.

If there's so many people talking about that error, it's not a bug, it's all people fault ?

What are my steps,

In /site/web/app/themes/ I ran :
rm -r ../uploads/cache
composer create-project roots/sage my-cool-theme
cd /my-cool-theme
composer install
yarn & yarn build

Wordpress Settings -> Activate the my-cool-theme

Go to the front page, and got error.

Just for the hint: @jonathanlaf, the root in the mentioned error (/srv/www/domain.tld/current/web/app/) differs from the last mentioned steps (/site/web/app/themes/). Did you shortened / simplify it for your last comment?

Yes I shortened it since I was typing it from the top of my head..

I have the same issue. Any update? Any one solved this bug?
-thanks

I got this fixed by upgrading composer packages.

I got this fixed by upgrading composer packages.

@RistoNiinemets Could you please elaborate which packages?

In our case it had to do with PHP 7.4. When we switched back to PHP 7.3 the error did not pop up anymore.

Hello. I have also the issue on my association website; here also when migrating PHP to a newer version here 7.4.
I'm using a plugin based on older version of Sage it seems but since I don't know about PHP it is hard to debug on my side. I'm not developing under composer.

The faulty code is certainly a "user related" but the "user" is no more there
I certainly need to put some reference description for the new PHP to find the 'App'... not sure what yet.
Was wondering if some could have a clue here? Thanks

issue is resources/views/front-page.blade.php

         <div> id="cubsmap-service"
               data-zoom='{!! App::GetOption("cc_gmap_zoom", 0) !!}' 
               data-lat='{!! App::GetOption("cc_gmap_lat", 0) !!}' 
               data-lng='{!! App::GetOption("cc_gmap_lng", 0) !!}' 
               data-markers='{!! FrontPage::MapPositions() !!}'>
          </div>

PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App' not found in /var/www/html/wp-content/uploads/cache/91c448e866...

Stack trace:
#0 /var/www/html/wp-content/themes/[oursite]/vendor/illuminate/view/Engines/PhpEngine.php(43): include()
#1 /var/www/html/wp-content/themes/[oursite]/vendor/illuminate/view/Engines/CompilerEngine.php(59): Illuminate\\View\\Engines\\PhpEngine->evaluatePath('/var/www/html/w...', Array)
#2 /var/www/html/wp-content/themes/[oursite]/vendor/illuminate/view/View.php(142): Illuminate\\View\\Engines\\CompilerEngine->get('/var/www/html/w...', Array)
#3 /var/www/html/wp-content/themes/[oursite]/vendor/illuminate/view/View.php(125): Illuminate\\View\\View->getContents()
#4 /var/www/html/wp-content/themes/[oursite]/vendor/illuminate/view/View.php(90): Illuminate\\View\\View->renderContents()
#5 /var/www/html/wp-content/themes/[oursite]/vendor/roots/sage-lib/Template/Blade.php(58): Illuminate\\View\\View->render()
#6 /var/www/html/wp-content/themes/[oursite] in /var/www/html/wp-content/uploads/cache/91c448e8663ee0a6aecbc2d4c451f96c9b8792c4.php on line 38

but since I don't know about PHP it is hard to debug on my side.

@stilmant This is not the place for this question. Your association needs to hire a PHP developer.

Well. Seems I'm not alone to face the issue. Seems that, the plugins that where developed with roots sage in the past are facing an issue when the website is upgraded to newer version of PHP. PHP 7.4

So here it is a good place to ask the question:

  • So it could be bad usage by developers working with the Sage in the past
  • or an issue in Sage in older versions. (usage of a now deprecated feature?, or similar )

In both case it could be interesting to document the reason here. (or on Sage side or what new in PHP 7.4 affecting the plugin) because when you search google for that exact problem you end-up here in this place.

For your suggestion about PHP developer for my association, I would be that developer but seems I will have to ramp up quickly and installing a full development environment since upgrading composer package seems a way to go... but here no composer etc.. just sources code on production. a classic :-D

So I've a resolution of my issue.
Seems it has to do with namespace. why affecter in PHP 7.4 is maybe(?) due to get_declared_classes() unpredictability in PHP 7.4 'https://github.com/squizlabs/PHP_CodeSniffer/pull/3052'

So I explicitly named the class including it's namespace

+               data-zoom='{!! \App\App::GetOption("cc_gmap_zoom", 0) !!}'
+               data-lat='{!! \App\App::GetOption("cc_gmap_lat", 0) !!}'
+               data-lng='{!! \App\App::GetOption("cc_gmap_lng", 0) `!!}'

Now certainly not the best approach but. I started learning PHP like today :D

I encountered something similar to this after re-provisioning Homestead vagrant box, jumping from PHP 7.1 to PHP 7.4. After a lot of digging I found that the problem was an old version of VirtualBox and everything was fixed after updating to VirtualBox 6. See: https://github.com/laravel/homestead/issues/1219

Let's continue this conversation on the forum.

https://discourse.roots.io/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tofraser picture tofraser  路  5Comments

retlehs picture retlehs  路  3Comments

MitchEff picture MitchEff  路  3Comments

eduardoarandah picture eduardoarandah  路  4Comments

inverse picture inverse  路  5Comments