Laravel create helper


Laravel create helper – Laravel Provides a default helper named as global.php which contains global functions which are available globally. global.php is located at the app/start/global.php location. Here in this tutorial we are going to explain how you can create custom helpers in Laravel.


Laravel create helper

You can create helper in laravel simply as below –

Create a file helpers.php at app/helpers.php location

Laravel create Custom helper Example:

<?php
function myFunction(){
// add stuffs here..

}
?>

Now you can load this helper in global.php as below –

Laravel load customhelper Example:

<?php
require app_path().'/helpers.php';
?>

Thus you can add your helper functions in this file.


Advertisements

Add Comment

📖 Read More