문제

Back in CodeIgniter, I could have set:

$config['media'] = '/media/';
$config['media_users'] = $config['media'] . 'users/';

But in Laravel4, the configuration (even the custom entries) is just one big array entries. Is there a way to concatenate configuration entires?

도움이 되었습니까?

해결책

As far as I know laravel configuration files must return an array which will be used in configuration. There can be some logic code in there which produces wanted configuration.

Instead of following usual pattern:

<?php
return array(
    'media' => '/media/',
    'media_users' => '/media/users',
};

You can do this instead:

<?php

$mediaDir = '/media/';
return array(
    'media' => $mediaDir,
    'media_users' => $mediaDir.'users',
);

다른 팁

Laravel configuration files are simply PHP files returning arrays. You can do anything you wish inside it, as long as you return the array at the end. So, say you wanted to work with it like you did in CI, you could do it like this:

<?php

$app = array(

    'media' => '/media/'
    // ..

);

$app['media_users'] = $app['media'] . 'users/';

return $app;

PS: This seems ugly though.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top