Wednesday, January 9, 2019

How to Add Constants in Larvel 5

How to Add Constants in Larvel 5

If it needs to add constants in order to be used everywhere in the app, just follows the steps below:

1. Create a file constants.php inside config directory and put your settings in an array:

file : config/constants.php

<?php
  return [
    'PAGINATION' => 5
  ];
?>

2. Then you can get the value by using ‘config helper’ anywhere in your controllers or views in Laravel 5:

echo config('constants.PAGINATION');
//output-> 5

No comments:

Post a Comment