slimphp / Slim-Console

Slim Framework Console
https://slimframework.com
MIT License
28 stars 12 forks source link

Configuration Object #6

Closed l0gicgate closed 4 years ago

l0gicgate commented 4 years ago

We are going to need to create a global configuration object to keep track of paths and other settings.

It will need to keep track of these items:

We should enable populating that object using:

What should the configuration files be named?

zhorton34 commented 4 years ago

slim-console.config.php?

I would highly recommend creating it as a .php file.

Any other format will require that we parse it and format it over to php so we can use the configuration to preset/make stuff.

flangofas commented 4 years ago

@l0gicgate I can work on this one if it is OK 😄

l0gicgate commented 4 years ago

Let’s proceed with the initial configuration being .php and further down the road we can offer other options if requested!

And @flangofas absolutely!

flangofas commented 4 years ago

@l0gicgate For now, should I use the following parameters within the Config Object?

    protected static $defaultParams = [
        'root'          => 'Absolute path of the project\'s root directory',
        'bootstrap'     => 'app',
        'commandsDir'   => 'Application/Commands',
        'public'        => 'public/index.php',
        'src'           => 'src',
    ];
l0gicgate commented 4 years ago

I think we should probably keep the naming uniform and alphabetized keys:

    $defaultParams = [
        'bootstrapDir'  => 'app',
        'commandsDir'   => 'Application/Commands',
        'indexDir'  => 'public',
        'indexFile' => 'index.php',
        'rootDir'   => 'Absolute path of the project\'s root directory',
        'sourceDir' => 'src',
    ];

I'm not final on this but that's what I'm thinking. Thoughts @ABGEO07?

flangofas commented 4 years ago

@l0gicgate @ABGEO07 Agreed. 👍 And the environment variables would be these:

SLIM_CONSOLE_BOOTSTRAP_DIR
SLIM_CONSOLE_COMMANDS_DIR
SLIM_CONSOLE_INDEX_DIR
SLIM_CONSOLE_INDEX_FILE
SLIM_CONSOLE_SOURCE_DIR
ABGEO commented 4 years ago
$defaultParams = [
        'bootstrapDir'    => 'app',
        'commandsDir' => 'Application/Commands',
        'indexDir'    => 'public',
        'indexFile'   => 'index.php',
        'rootDir' => 'Absolute path of the project\'s root directory',
        'sourceDir'   => 'src',
    ];

@l0gicgate this is a good structure :+1: But i have one offer for improvement: What do you think about using some kind of placeholders like

...
'commandsDir' => '{sourceDir}/Commands', // or %sourceDir%
'sourceDir'   => 'src',
...

or something else? This would be good practice when we need to reuse some parameters in other parameters.

It will be easy to parse them using regex and replace before defining constants (or env variables).

l0gicgate commented 4 years ago

What do you think about using some kind of placeholders like

I’m not so sure we need to go that complex. We should have path formatting done via internal functions. sourceDir is implied that it would prefix the commandsDir in this case.

We’ll have to see what @flangofas comes up with and we can make further decision once we see the initial config object.