Pregunta

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?

¿Fue útil?

Solución

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',
);

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top