Have you done a composer dumpautoload?
Aug 9, 2015
13
Level 6
Laravel 5.1 - Can't get facade to work
So, I've looked through every possible documentation and forum thread on service providers and facades and still can't get this to work...
I have a service and a provider:
namespace App\Providers;
use App\Services\AddressFinder;
use Illuminate\Support\ServiceProvider;
class AddressFinderServiceProvider extends ServiceProvider
{
protected $defer = true;
public function register()
{
$this->app->bind('address_finder', function()
{
return new AddressFinder('idealpostcodes');
});
}
}
And a facade for it:
namespace App\Services\Facades;
use Illuminate\Support\Facades\Facade;
class AddressFinderFacade extends Facade
{
protected static function getFacadeAccessor()
{
return 'address_finder';
}
}
Now when I try to use AddressFinder::find($postcode); I'm getting
ReflectionException in Container.php line 736:
Class address_finder does not exist
Both the service provider and facade are properly registered in app.php.
If I pass the full class name in getFacadeAccessor() only then it works. As if the facade doesn't even try to resolve it from the service container.
Please or to participate in this conversation.