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
2
votes
0 answers

Laravel error with message 'A facade root has not been set

I have recently installed Ratchet on my laravel installation to enable push services over sockets. This is what my SocketController class looks like (note: it does NOT extend controller) class SocketController implements WampServerInterface { …
harveyslash
  • 5,906
  • 12
  • 58
  • 111
2
votes
2 answers

How to map private resource to public in Laravel?

I have been using the Storage facade to store user profile pictures and they are being saved inside the Storage folder in the project. The problem is that I cannot directly display these photos because of the permissions of the storage folder, I…
Joe W
  • 249
  • 2
  • 8
  • 18
2
votes
1 answer

Clarification of Flow Structure of Laravel Facade

So I am examining the code of Laravel I'm looking at the Storage facade. I think this is the way it's being loaded. Correct me if I am wrong. When ever we access the Storage::get('someFile.txt'); The Storage is being accessed through the alias in…
Nello
  • 1,737
  • 3
  • 17
  • 24
2
votes
1 answer

Laravel Facade Implementation

I am confused as to how to use the cache in Laravel. I can either use the Cache facade and do something like … use Cache; public function someMethod() { Cache::remember('users', 60 , function() { return DB::table('users')->get(); …
user3107673
  • 423
  • 4
  • 9
2
votes
2 answers

How to extend PasswordBroker in Laravel?

I want to use my own PasswordBroker because the default one can't have its variable "emailView" modified after being initialized. But I can't extend it in my custom class. Class App\Http\Controllers\Auth\MyPasswordBroker cannot extend from…
Kalzem
  • 7,320
  • 6
  • 54
  • 79
2
votes
3 answers

Where to look in laravel documentation api for all available functions for each facade?

I know how facades work and I can find full facade list in Laravel: https://laravel.com/api/5.2/Illuminate/Support/Facades.html But how I can see all available functions for each facade? If I use the Session Facade I can: Find methods in laravel…
fico7489
  • 7,931
  • 7
  • 55
  • 89
2
votes
1 answer

How to using echo HTML::script in laravel 5.0 in Controller

I need to use echo HTML::script('js/ckeditor/ckeditor.js'); in my controller and function, but error not found HTML I am using larvel 5.0. tnx
reza_khalafi
  • 6,230
  • 7
  • 56
  • 82
2
votes
2 answers

Injecting Artisan into Service class

I am trying to inject Artisan into a service so I can avoid using the facade. Looking at the facade class reference I can see that the class I should be injecting is: Illuminate\Console\Application So I would assume that doing…
Steven1978
  • 476
  • 1
  • 3
  • 15
2
votes
1 answer

PHPStorm complains about static call of instance method handled by __CallStatic facade

I have classes with static methods that I need to change to instance methods for unit testing. However I can not change the code that calls them statically. So I'm trying to implement a facade (similar to what Laravel does) so that I can call the…
Revent
  • 2,091
  • 2
  • 18
  • 33
2
votes
0 answers

Dynamic Laravel Style Facade

I'm using Laravel's Facade architecture (the AliasLoader class and Facade class) to create facades for my app. All is working well initially, I add the aliases to the loader and register them, create a facade class and boom, facades everywhere. But…
secondman
  • 3,233
  • 6
  • 43
  • 66
2
votes
1 answer

Laravel namespace in relations confused me

In my app I have Event and User models.Because of Event model I have to put it into namespace .so I created namespace as of following. Event
Tixeon
  • 930
  • 1
  • 12
  • 27
1
vote
2 answers

I get the same row duplicated as the result when I do a simple join using the laravel's DB facade

Code $result = DB::table('disaster_rescue_data') ->join('users', 'disaster_rescue_data.username', '=', 'users.email') ->get(); Problem I have this very simple join as mentioned in the above code. However when I render the data on a view or…
gfit21x
  • 141
  • 9
1
vote
1 answer

Laravel 8 Sail Redis not assuming the default cache driver

Laravel 8 and the dev environment is Sail - including Redis. The .env file: CACHE_DRIVER=redis .. REDIS_HOST=redis REDIS_PASSWORD=null REDIS_PORT=6379 Using the Redis facade functions, like Redis::set( 'bar', 'The hole of the moon' ); using…
bito_
  • 169
  • 2
  • 10
1
vote
0 answers

Laravel 8: using Facades within Closures

I'm using spatie/async to do async uploading of photos to AWS S3. I'm trying to use some facades from within the closures. For example: foreach ($images as $image) { ... $pool->add(function () use ($encodedImage, $previewImage, $post,…
ChristianF
  • 1,735
  • 4
  • 28
  • 56
1
vote
2 answers

How to mock a given method of Laravel Auth facade

I want to test that the Auth facade, when createUserProivder() method is called, returns my user provider. The problem is that with the following code, with the commented out part, the AuthManager is still the original, not the mock. With the…
JorgeeFG
  • 5,651
  • 12
  • 59
  • 92