Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Andreea@Webclix's avatar

Laravel path breakage on hosting. Error 500 all over the place.

Day 2 of hosting horrors.

Yesterday, I tried getting the Laravel installation which currently works in a testing subfolder on the hosting, and installing it. The issue I ran into was that after running composer instal, it couldn't find the Page by the slug, it would always return a 500 and a null on Page::findBySlug($slug);

Instead of that, I simply copied the testing installation to the /project and then /project/public to the /www. Changed the paths and it seemed to be ok but for some reason it isn't. Only the main page worked, every single other one would return 500 and this lovely little error

 Uncaught ErrorException: Undefined variable: listing in /data/sites/web/project/storage/framework/views/faf3b9bc67749f60e786fa6832263e13d2214d7b.php:12
Stack trace:
#0 /data/sites/web/project/storage/framework/views/faf3b9bc67749f60e786fa6832263e13d2214d7b.php(12): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined varia...', '/data/sites/web...', 12, Array)
#1 /data/sites/web/project/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(42): include('/data/sites/web...')
#2 /data/sites/web/project/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/data/sites/web...', Array)
#3 /data/sites/web/project/vendor/laravel/framework/src/Illuminate/View/View.php(149): Illuminate\View\Engines\CompilerEngine->get('/data/sites/web...', Array)
#4 /data/sites/web/project/vendor/laravel/framework/src/Illuminate/View/View.php(120): Ill in /data/sites/web/project/storage/framework/views/faf3b9bc67749f60e786fa6832263e13d2214d7b.php:12

I then ran with artisan config:cache and route:cache which broke even the main page.

At that point, I pointed the /www/index.php to the testing platform folder, which makes the home page function again but the rest is still broken and Laravel screams at me that it indeed cannot find that variable.

Now, my knowledge of this project is quite small and 99% of it has been developed by a completely different person but it seems like I'd indeed need to run the config:cache and route:cache but with changes to something. What that thing is I have no clue...

Would appreciate even the slightest bit of help.

0 likes
3 replies
Narco's avatar

Well what I would do first is look at the stack trace of the error. Apparently the breaking error is the fact that you are referencing an undefined variable listing inside the view. You can see that particular view if you follow that path on your project (storage/frameworks/views/faf3b9bc67749f60e786fa6832263e13d2214d7b.php at line 12)

Which controller is serving that view to the client? I would check the method inside the controller that is responsible to return the view.

Try to dump and die (dd()) the particular variable inside the controller.

Maybe you didn't migrate the database?

Also try to look into your laravel.log file in the storage folder for other errors.

1 like
Andreea@Webclix's avatar

Thanks, it was indeed an issue introduced by the frontend. Fixed it now but I still don't see why config:cache and route:cache break everything. I fixed the $listing issue but now even the homepage results in 500 in instances where I run those commands.

It goes back to returning null on Page::findBySlug($slug).

Please or to participate in this conversation.