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
3
votes
1 answer

Is this considered to be a custom facade approach in Laravel?

I have piece of functionality that identifies access by a given token (string). If a valid token is given the session should be populated with a valid entry (using the SessionInterface). I've set up my VerifyToken middleware and would like to use a…
Ben Fransen
  • 10,884
  • 18
  • 76
  • 129
3
votes
1 answer

Manipulating Laravel html response just before sending it to browser

What is the proper way to manipulate final output before sending it to browser? (laravel 5.*) I have created facade namespace App\Facades; use Illuminate\Support\Facades\Response as ResponseFacade; use Illuminate\Http\Response as…
3
votes
1 answer

Laravel 5 Class 'Illuminate\Support\Facades\FormFacade' not found

Ok, this is driving me mad. I'm trying to include forms functionalities with FormFacade with Laravel 5, but I keep getting this error: Class 'Illuminate\Support\Facades\FormFacade' not found I'll write down what I have done: After laravel 5…
SBD
  • 446
  • 6
  • 17
3
votes
1 answer

Use static variables in Laravel Facades

I have a Facade (in this case a singleton) and I register it using a ServiceProvider: Service Provider use App; class FacilityServiceProvider extends ServiceProvider { public function register() { …
Kousha
  • 32,871
  • 51
  • 172
  • 296
2
votes
2 answers

How does this Facade works

I'm working with Laravel 5.8 and it's an Online Store project written by other programmers. Basically I have faced something weird that never seen before. Let's say we have this at a Controller method: $payment =…
Pouya
  • 114
  • 1
  • 8
  • 36
2
votes
1 answer

Laravel Package: How to register a third party facade inside a custom package?

I'm creating a package that uses internally this hashid package. How can I register a third party facade inside a custom package? I tried three options and none of them worked. Version - Composer "aliases": { "Hashids":…
Philipp Mochine
  • 4,351
  • 10
  • 36
  • 68
2
votes
0 answers

Unable to use facades during tests on Lumen

I wanted to refresh my testing database once per class instead of per test using the setUpBeforeClass method. As it is static, I can't call $this->artisan() therefore I tried to use Artisan::call() with facades. The problem is that facades are not…
guizo
  • 2,594
  • 19
  • 26
2
votes
1 answer

Laravel eloquent giving different results from DB facade

I have a laravel eloquent query that is giving me a different result from the same query using the DB facade. I cannot understand why the result would be different. The result set is the same length (6), but the one data object key ha stays the…
Hmerman6006
  • 1,622
  • 1
  • 20
  • 45
2
votes
0 answers

Call to undefined method Illuminate\Support\Facades\Schema::isDeferred()

I am try to run any php artisan commend in my project but i can't every time try i find this error als when i try to load In ProviderRepository.php line 149: Call to undefined method…
2
votes
1 answer

How to solve A facade root has not been set. In Facade.php line 236: Laravel 5.8?

I am receiving In Facade.php line 236: A facade root has not been set. in a Laravel 5.8 project I am cloning from GitLab. here is the log output [stacktrace] #0 C:\\Users\\Abdellah Ramadan\\Desktop\\COMPANY\\poblysh\\config\\seotools.php(14):…
Abdellah Ramadan
  • 367
  • 4
  • 15
2
votes
2 answers

Adding Facades before namespace in Laravel , How it works?

Okay there are questions about the same topic before but they don't help to fully understand this topic SO SuggestionFirst SO Suggestion Second All the code is just to illustrate the situation, So this is the structure A helper function which does…
BlackXero
  • 880
  • 4
  • 17
2
votes
1 answer

Multiple classes behind one facade

Facade namespace App\Webshop\Facades; use Illuminate\Support\Facades\Facade; class Webshop extends Facade { /** * @return string */ protected static function getFacadeAccessor() { return \App\Webshop\Webshop::class; …
yooouuri
  • 2,578
  • 10
  • 32
  • 54
2
votes
2 answers

How to extend Laravel Storage facade?

Without knowing how Laravel facades work, based on my PHP knowledge, I tried to extend Storage facade to add some new functionalities. I have this code: class MyStorageFacade extends Facade { /** * Get the binding in the IoC container …
Omid
  • 4,575
  • 9
  • 43
  • 74
2
votes
1 answer

Is it a good idea to edit .env dynamically in Laravel 5?

I am building an admin panel, so I need to make some core settings (like smtp settings, etc) of my Laravel 5 app configurable to end users through front-end interface. My initial thoughts were to use database as a settings storage alongside…
Alex Lomia
  • 6,705
  • 12
  • 53
  • 87
2
votes
1 answer

Extend Laravel 5's Response Facade to include further helpers?

I'm trying to allow an user to do something like response()->yaml(['their content']), but I don't understand how I'd go on injecting my YAML method to the response() (ResponseFactory) facade. Is there any guide that would explain on how to do this?…
aborted
  • 4,481
  • 14
  • 69
  • 132
1 2
3
11 12