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

Laravel: Deploying without "facade/ignition" composer dependency results in Class "Facade\Ignition\IgnitionServiceProvider" not found error

I'm on Laravel 8. In my composer.json file there is this: "require-dev": { "facade/ignition": "^2.5", .... }, Without facade/ignition, my website always shows me this error: (Symfony Exception) HTTP 500 Internal Server Error Class…
Hillcow
  • 890
  • 3
  • 19
  • 48
0
votes
1 answer

Trying to mock Laravel Facade with MyFacade::shouldReceive() results in "cannot redeclare shouldReceive()"

On Laravel 8, I've created a facade and registered the service provider in Laravel. In my Pest test I've added \App\Facades\Twilio::shouldReceive('AsAdmin');. Running the test results in: PHP Fatal error: Cannot redeclare…
tylersDisplayName
  • 1,603
  • 4
  • 24
  • 42
0
votes
1 answer

Extending the Laravel Http Facade

I'm trying to find the right way to extend the Laravel Http Client Facade. I don't want to do this every time when I want to get something from the response of my request. I would like to add some more helpers to prevent this. Also I can't directly…
Kristian Vasilev
  • 504
  • 8
  • 26
0
votes
1 answer

Class "Facade\Ignition\IgnitionServiceProvider" not found when running php artisan in docker container

Been trying to solve this problem for the last few days to no avail. Basically have been trying to dockerize my application for deployment, but whenever I go inside the container and try to run "php artisan", I get the following error: In…
0
votes
0 answers

How to test a class with DI-ed facade in Laravel

PHP 8.1.1 / Laravel 9 I had Config:get('keycloak.employees_group_id') in my task, and Config::shouldReceive('get')->with('keycloak.employees_group_id')->andReturn('fake-id') in my test which worked NP. Then I wanted to use DI (dependency injection)…
s3c
  • 1,481
  • 19
  • 28
0
votes
1 answer

Laravel HTTP facade does not return content-length in response headers

I have a controller which calls multiple GET requests from Gmail API, Basically, I am trying to get most recent 50 SENT MESSAGES. What I did was pool these requests, and loop the Pool response and insert the retrieved data to my db. $resp =…
0
votes
3 answers

Memory leak when using Http facade with Laravel Octane

Does anyone have idea why is memory going up for every request when I'm using Http facade with Laravel Octane ? Route::get('test', function () { Http::get('https://swapi.dev/api/people/1'); return memory_get_usage(); }); But when I use Guzzle…
0
votes
1 answer

Transform piece of laravel livewire code into Facade or trait

I'm trying to transform the following piece of code into a Facade. But I don't know how to call $this in the facade. I want to do this without using $this or passing it as a parameter. Can I somehow dependency inject it? The following piece of code…
0
votes
2 answers

VS code tracking a function doesn't work with Laravel Facade

I really like Laravel Facade when transforming dynamic class to static. For instance, I can easily add the keyword Facades and call it a static class. use Facades\App\Services\MyService; public function something() { $something =…
ronaldtgi
  • 687
  • 8
  • 17
0
votes
0 answers

Using Laravel Storage Facade to access files on another PC

So , there's a machine where i have some files, and i would like to access those files from my Laravel project that is running locally. This machine is on an example host like 10.0.101.11 , how can i access this with my laravel project? My…
0
votes
1 answer

Getting 403 Forbidden while using gate facade

When writing privileges and rights of a user shows error: 403 Forbidden Controller code class IndexController extends AdminController { public function __construct(){ parent::__construct(); if (Gate::denies('VIEW_ADMIN')) { …
user15520340
0
votes
2 answers

Laravel facade problem when deployed on aws lambda

I'm using laravel 8 and bref to deploy it on lambda. After making a cron job function to send email. When I deploy it, there's a problem with the facade { "errorType": "RuntimeException", "errorMessage": "A facade root has not been set.", …
Howard Do
  • 33
  • 6
0
votes
0 answers

Facing facades issue in laravel

Fatal error: Uncaught RuntimeException: A facade root has not been set. in /app/dragonglass/crm/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218 Stack trace: #0 /app/dragonglass/crm/app/helpers.php(617):…
Soyab Badi
  • 400
  • 6
  • 17
0
votes
1 answer

How to mock a result from an API wrapper class in PHPUNIT?

I am using the spatie laravel calendar package to make api calls to Google Calendar I want to write some Feature tests but I want to mock the Event wrapper class so my tests don't actually make the API calls I used Laravels Facades…
nickc
  • 1,193
  • 1
  • 6
  • 15
0
votes
0 answers

Policy with Session variable

I want to create a policy which would not be linked to any model because I use external APIs in this sense so therefore I store the information in the Session example I have Session::get('isAdmin') but since that does not not working I have used the…