Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 don't know.

Same with Redirect::to() --> redirect() , Redirect::back() --> back() and so on..

Is there a difference or does it not matter?

like image 257
haheute Avatar asked Jul 09 '15 17:07

haheute


People also ask

Why facade is important in Laravel?

Laravel facades serve as "static proxies" to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.

What does Laravel use for seeding & facades?

Laravel includes the ability to seed your database with data using seed classes. All seed classes are stored in the database/seeders directory. By default, a DatabaseSeeder class is defined for you. From this class, you may use the call method to run other seed classes, allowing you to control the seeding order.

Can you explain which design pattern does Laravel facades follows?

A facade in Laravel is a wrapper around a non-static function that turns it into a static function. The word "wrapper" can also be used when describing design patterns. Wrapping an object to provide a simplified interface to it is often described as the "facade" pattern. So in short, the wrapper is the facade.

What is helper function in Laravel?

What is a Helper Function? A helper function usually comes in handy if you want to add a feature to your Laravel application that can be used at multiple locations within your controllers, views, or model files. These functions can be considered as global functions.


1 Answers

I don't think there is much performance difference but one thing to consider is the reduced cognitive load of always including the use statement when using a facade. Just one more thing to forget.

like image 130
lucidlogic Avatar answered Sep 17 '22 23:09

lucidlogic