I have a call to a Laravel facade that fails with a 'class not found' error. The odd thing is that it works in my development environment, but not my staging environment. It's particularly bizarre given that both environments are standard Laravel environments. (Dev is a homestead machine. Staging was deployed by Forge, and is managed by Forge).
There have been no similar issues with either dev or staging.
I have managed to get around the problem using the resolve()
helper, but I still need to understand why the usual facade usage does not work.
Here's the code that fails in staging, but works in dev:
$referrer = \Illuminate\Support\Facades\Url::previous();
Here's the code that works in both environments:
$referrer = resolve('url')->previous();
The code lives in a helper file which does not have access to $this->app
. I have dozens of helpers in there and they all work fine, including many that make use of facades.
Here are some checks that I have done:
composer.lock
)composer dump-autoload
had no effectIts possible your environment may be case sensitive, try:
$referrer = \Illuminate\Support\Facades\URL::previous();