0

I read the question

global variable for all controller and views

It tells about declaring a variable in the filters.php in the root folder, (Thought it was said it is not a good practice to declare in the filters.php file )I tried but didn't succeed. But i need to declare a variable in any file of the config folder that should be available to all controllers and views.

Where should i do this ?

Community
  • 1
  • 1
ABD
  • 869
  • 2
  • 12
  • 28

1 Answers1

3

You can create a PHP file inside app/config folder

For example: Create app/config/settings.php

Inside this settings.php:

<?php
     return array(
                 'LANGUAGE_ID' => 1,
                 'DATE_FORMAT' => 'Y-m-d'
            );

And you can access this in views and controllers using:

Config::get('settings.LANGUAGE_ID');

If you will create different environment, you need to put the newly created config file to each environment folder.

Raffy Cortez
  • 458
  • 3
  • 8