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

Laravel Log useFiles method is making Log write in multiple files

I am using Laravel Log Facade in my app. And I have several services like Mandrill, Twilio, Stripe, etc., that need to be logged in separate file. But when I use Log::useFiles() to set separate file for one of the service wrapper class, like…
Mladen Janjetovic
  • 13,844
  • 8
  • 72
  • 82
6
votes
1 answer

Attempting to use custom facade results in 'Call to undefined method' on Application::create() in Laravel?

I am attempting to create my own custom facade for a Search feature, but I'm having a little difficulty: type: Symfony\Component\Debug\Exception\FatalErrorException message: Call to undefined method Illuminate\Foundation\Application::create() file:…
marked-down
  • 9,958
  • 22
  • 87
  • 150
6
votes
1 answer

Laravel - performance of Facades vs. helper methods

I wonder if there is a performance difference between using Facades and helper methods in laravel 5.1. I startet to remove for example use View; or View::make() wherever possible, thinking that view() would be simpler and possibly faster. But I…
haheute
  • 2,129
  • 3
  • 32
  • 49
6
votes
1 answer

Laravel constants in class Facades

I have a class called Awesome and have used the ServiceProvider and the Facade to register it to the app. Now I can use it as Awesome::Things(). I want to add constants to this class, so I tried
Kousha
  • 32,871
  • 51
  • 172
  • 296
5
votes
2 answers

Class 'Form' not found in Laravel 7

I'm upgrading from Laravel 5 to Laravel 7. I'm using a lot of Form::model on my project. Class 'Form' not found I tried to install "laravelcollective/html": "~5.0" I kept getting Problem 1 - Conclusion: remove laravel/framework v7.3.0 -…
code-8
  • 54,650
  • 106
  • 352
  • 604
5
votes
1 answer

How to create Illuminate/Support/Facade/App facade for standalone Illuminate IoC Container

In my standalone (without Laravel) project i want to use Illuminate IoC container. Also i would like to access the app container through App facade provided by illuminate/support component. I installed both components (v5.0.28). Here is my…
5
votes
1 answer

Laravel: Difference between Facades and Aliases

Good day! The more I read, the more I get confused about this. What is the difference between a Facade and Aliases? I have this Class: /app/libraries/Project/Data.php namespace PJ; class Data { // It is much like a data container, with static…
Marco Madueño Mejía
  • 1,105
  • 2
  • 9
  • 7
4
votes
0 answers

In Facade.php line 258: A facade root has not been set

I was working on my Laravel project and suddenly got this error: In Facade.php line 258: A facade root has not been set. My last command is php artisan make:migration ... It ran successfully Here is the file causing the…
4
votes
0 answers

Laravel DatabaseTransactions do not work with DB Facade

I have an issue when I run tests using DatabaseTransactions. In my Products table, I have all Products where the stock_count = -99. Here is my code TestCase.php (all the tests extend this class) use DatabaseTransactions; protected…
Alessandro.Vegna
  • 1,262
  • 10
  • 19
4
votes
2 answers

Problems with laravel-ide-helper

I am going through the Laravel 5 Fundamentals Laracasts video set but am having some difficulties with Facades in my IDE (Phpstorm 8). I have a model which uses the Eloquent facade use Illuminate\Database\Eloquent\Model; I have required the…
Kevbot
  • 474
  • 8
  • 21
4
votes
1 answer

Are Laravel facades dependencies?

I have read that there should be not too much dependencies to one class. In one book, it states that 4 dependencies might be a sign that class might be doing too much. Lets say I have written a class which uses 10 dependencies: 6 classes and 4…
Dariux
  • 3,953
  • 9
  • 43
  • 69
4
votes
3 answers

Laravel 4.2 Illuminate Facade are not getting resolved

I created a artisan command to clear application cache by following below link http://code.tutsplus.com/tutorials/your-one-stop-guide-to-laravel-commands--net-30349 I'm trying to call it inside my Dashboard controller as below namespace ABC; class…
Ravikumar Sharma
  • 3,678
  • 5
  • 36
  • 59
3
votes
1 answer

Create custom package with facade in Laravel 8

I am trying to develop a new Laravel package locally installed via Composer. These are my steps: I install a new Laravel application with composer create-project laravel/laravel my-application I create a new directory in the root with the…
Randolf
  • 367
  • 1
  • 14
3
votes
3 answers

Laravel Facade error: Non-static method should not be called statically

I have a simple modal having an index method to get data from DB Modal: Nation namespace App\Models; use Illuminate\Database\Eloquent\Model; class Nation extends Model{ function index(){ Nation::where(['visible'=>1])->get(); } } Now I…
Uncoke
  • 1,832
  • 4
  • 26
  • 58
3
votes
0 answers

Laravel 5.7+, How to use helper functions within Blade templates smartly

Since Laravel 5.7, the majority of global Helper functions (specifically the ones related with "Arrays & Objects" and "Strings") are now based on Facades (using Illuminate\Support\Str and Illuminate\Support\Arr classes) instead of being defined as…
andcl
  • 3,342
  • 7
  • 33
  • 61
1
2
3
11 12