Questions tagged [laravel-facade]

Facades in Laravel framework provide a "static" interface to classes that are available in the application's IoC container.

Facades provide a "static" interface to classes that are available in the application's IoC container. Laravel ships with many facades, and you have probably been using them without even knowing it! Laravel "facades" serve as "static proxies" to underlying classes in the IoC container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.

168 questions
1
vote
1 answer

Configuring PhpRedis in Laravel 7

I've set up a fresh installation of Laravel in Homestead and I've installed PhpRedis as recommended in the Laravel docs https://laravel.com/docs/7.x/redis#phpredis. I followed this guide for installing PhpRedis…
Josh
  • 714
  • 2
  • 8
  • 20
1
vote
1 answer

Uncaught RuntimeException: A facade root has not been set. in Facade.php:258 when upgrading to Laravel 7

I got the error regarding facade even though I followed the laravel upgrade guide PHP Fatal error: Uncaught RuntimeException: A facade root has not been set. in…
Aditya Pratama
  • 657
  • 1
  • 8
  • 21
1
vote
1 answer

updating Laravel from 5.7 to 5.8 results in this error: Fatal error: Uncaught RuntimeException: A facade root has not been set

Here's a list of posts claiming they have the same error I've already looked at and tried the answers from but none of them have worked: Laravel 5.6 - Uncaught RuntimeException: A facade root has not been set 'A Facade root has not been set' when…
Gharbad The Weak
  • 1,541
  • 1
  • 17
  • 39
1
vote
3 answers

Why isn't Laravel Auth Facade working in controller?

I have a controller with a store() method called from a Vue component. It works fine, as I can successfully pass data to my controller from the Vue component. But, I am trying to get the identity of the authenticated user, and for some reason, I can…
develpr
  • 1,296
  • 4
  • 22
  • 42
1
vote
1 answer

How laravel facade can use DB and DB instance at the same time?

I use DB facade. I see it can use in DB::connection from Illuminate\Database\DatabaseManager and DB::select from Illuminate\Database\Connection. I don't understand how one facade can apply two serivce? Thank you for your asking!
ray
  • 241
  • 2
  • 13
1
vote
1 answer

How can I define a facade in Lumen?

I had a Laravel project and I've added the following line in config/app.php file (aliases section). 'Telegram' => Telegram\Bot\Laravel\Facades\Telegram::class And then it was working: use Telegram\Bot\Laravel\Facades\Telegram; Now I've migrated…
Martin AJ
  • 6,261
  • 8
  • 53
  • 111
1
vote
1 answer

Why does my Laravel installation need prefixing \ backslash for facades aliases

I don't know the reason for malfunction of the following example: Auth::user()->id However, just prefixing it with backslash makes it works fine: \Auth::user()->id This is a snippet from config/app.php 'aliases' => [ 'App' =>…
SaidbakR
  • 13,303
  • 20
  • 101
  • 195
1
vote
2 answers

How do I over ride (new class) a facade in Laravel 5.4?

I've get the following class
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
1
vote
2 answers

Unable to mock Cache::put() facade in Laravel

I'm trying to mock the Cache::put() facade. But it gives me an error. I have tried different ways but couldn't figure it out. public function testGetAllFromDatabase() { $industry = new Industry(); Cache::shouldReceive('has') …
Achintha Samindika
  • 1,944
  • 1
  • 20
  • 31
1
vote
1 answer

Laravel 5.6 Uncaught RuntimeException: A facade root has not been set. in vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218

After installing Laravel 5.6 on PHP 7.1.8 (fedora 23) using composer, when I try to open url in browser, I get this error PHP Fatal error: Uncaught RuntimeException: A facade root has not been set. in…
FMoridhara
  • 161
  • 5
  • 16
1
vote
1 answer

How facades work in laravel? How the methods can be accessed with ::

I read about Facade Pattern The facade pattern (also spelled façade) is a software design pattern commonly used with object-oriented programming. The name is an analogy to an architectural façade. A facade is an object that provides a simplified…
Shobi
  • 10,374
  • 6
  • 46
  • 82
1
vote
0 answers

requiring a file from laravel facade file

I have a facade 'CustomMage', but from which I'm not able to include magento api.
Geethu
  • 348
  • 6
  • 24
1
vote
2 answers

Laravel DB facade how to express LIKE

I have a query: DB::select('select * from student where name like "%?%" or description like "%?%"',[$keyword,$keyword]) but I got empty result, which shouldn't be. I think it might take "?" instead of my keyword, how should I modify it?
flower
  • 91
  • 1
  • 10
1
vote
1 answer

Why isn't getFacadeAccessor() method abstract?

In Laravel's illuminate/support/Facades/Facade.php file there's a following method: /** * Get the registered name of the component. * * @return string * * @throws \RuntimeException */ protected static function getFacadeAccessor() { throw…
Robo Robok
  • 21,132
  • 17
  • 68
  • 126
1
vote
1 answer

Can't use public_path() in a helper file Laravel 5.4

I have a helper.php file in app/Helpers directory. I included that file in composer.json: ... "files": [ "app/Helpers/helpers.php" ] ... Helper works fine but I can't use public_path() method there. I need to include…
Andrey P.
  • 139
  • 2
  • 14