laravel 5 - How to use constants with Request in Laravel5 -


i trying upgrade laravel4 app laravel5.

in laravel4 app, use app/config/constants.php file , difine constants using request class.

if (request::is('admin/*')) {     define('path', 'admin') }else {     define('path', 'public') } 

and read in app/start.php.

require __dir__.'/../app/config/constants.php'; 

these constants used in controllers, models, commands, views, , files in 'app/config' directory.

in laravel5, how read file?

i tried: 1, added in config directory , changed composer.json

"autoload": {     "files": [         "config/constants.php"     ] } 

i got error: php fatal error: class 'request' not found

2, added in config directory , changed app/providers/appserviceprovider.php

public function boot() {     require __dir__.'/../config/constants.php'; } 

i got same error: php fatal error: class 'request' not found

thanks,

try \request instead of request , don't need add constants.php composer json use \config::get('constants.const_name') helper function ge const value , can use const keyword define constants instead of define()


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -