laravel-facade

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

房东的猫 提交于 2019-12-11 00:59:46
问题 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 caching(to avoid issuing database calls every time a config value is accessed). However, it appears, that Facades are loaded after config files, thus the code below doesn't work: <?php // app/config/custom_settings.php return [ 'key' => Cache::get('key');

Dependency Injection in Laravel 5 Package To Use or Not To Use

夙愿已清 提交于 2019-12-08 20:14:37
I am developing a package for Laravel 5, I decided to benefit from dependency injection in my package when using the Core classes of Laravel, but after reading more and also having asked this question Best approach for Dependency Injection in Laravel 5 package Now I came up with the idea that if we are using Facades so much and calling static methods like FaceadeName:nameOfMethod the Container actually creates an object for us and calls its method, so to some extend using dependency injection for laravel for classes which are also available through the Facades are is almost useless. For

Dependency Injection in Laravel 5 Package To Use or Not To Use

杀马特。学长 韩版系。学妹 提交于 2019-12-08 08:01:51
问题 I am developing a package for Laravel 5, I decided to benefit from dependency injection in my package when using the Core classes of Laravel, but after reading more and also having asked this question Best approach for Dependency Injection in Laravel 5 package Now I came up with the idea that if we are using Facades so much and calling static methods like FaceadeName:nameOfMethod the Container actually creates an object for us and calls its method, so to some extend using dependency injection

Are Laravel facades dependencies?

风流意气都作罢 提交于 2019-12-07 12:51:43
问题 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 facades. Should I care only about those 6 classes and split them, or care about 4 facades too? If somebody want to know how I get so many facades: use Input; use App; use Session; use Log; Those all are needed often. I have heard question - why do I

Laravel Log useFiles method is making Log write in multiple files

女生的网名这么多〃 提交于 2019-12-07 11:43:21
问题 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 this: Class Mailer { static function init() { Log::useFiles(storage_path('logs/mandrill-'.date("Y-m-d").'.log')); } static function send() { // some code here... Log::error("Email not sent"); } } And I am ending up with log being written in both Laravel

laravel 5 : Extend a Facade

时光怂恿深爱的人放手 提交于 2019-12-07 05:43:44
问题 I need to handle different types of DB depending on the client. I created a Facade called MyDBFacade where I can call my own functions. For example: MyDBFacade::createDBUser("MyUser"); // will create a DB user whatever I'm using Postgres or SQL Server Is there a possibility to extends the framework Facade DB:: in a way I could add my own functions and then call DB::createUser("MyUser") ? Any clue or idea would be appreciate. Thanks in advance, have a nice day. 回答1: Let's say that you define

Are Laravel facades dependencies?

拟墨画扇 提交于 2019-12-05 20:02:20
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 facades. Should I care only about those 6 classes and split them, or care about 4 facades too? If somebody want to know how I get so many facades: use Input; use App; use Session; use Log; Those all are needed often. I have heard question - why do I need App? To call a function: App::setLocale('lt'); Some say that facades are not dependencies, also in

Manipulating Laravel html response just before sending it to browser

…衆ロ難τιáo~ 提交于 2019-12-05 19:57:24
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 ResponseHttp; class Response extends ResponseFacade { public static function viewMod($view, $data = [], $status = 200, array $headers = []) { $output = \Response::view($view, $data, $status, $headers); return some_manipulating_function($output); } } and in the controller action i use return viewMod("my_view_file", array $view_data); but i receive corrupted output

laravel 5 : Extend a Facade

╄→尐↘猪︶ㄣ 提交于 2019-12-05 09:07:48
I need to handle different types of DB depending on the client. I created a Facade called MyDBFacade where I can call my own functions. For example: MyDBFacade::createDBUser("MyUser"); // will create a DB user whatever I'm using Postgres or SQL Server Is there a possibility to extends the framework Facade DB:: in a way I could add my own functions and then call DB::createUser("MyUser") ? Any clue or idea would be appreciate. Thanks in advance, have a nice day. Let's say that you define your custom facade in app/Facades/MyDBFacade.php <?php namespace App\Facades; use Illuminate\Support\Facades

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

こ雲淡風輕ζ 提交于 2019-12-05 06:43:31
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 (simplified) code: function setup_App(){ $container = new Illuminate\Container\Container(); Illuminate\Support\Facades\Facade::setFacadeApplication($container); class_alias('Illuminate\Support\Facades\App', 'App'); } setup_App(); App::bind('w', 'Widget'); $widget = App::make('w'); Unfortunately, trying to bind something results in: Fatal error: Call to