Skip to content

Configuration

The keys of crest.php, the project file, with the file that crest new writes for each flavor.

crest.php is the project file (see The project file). This section shows its keys. The examples show the file that crest new writes for each flavor:

MVC

return [
    'flavor'    => 'mvc',
    'namespace' => 'App',
    'bootstrap' => App\AppFront::class,
    'models'    => [
        // Property names in camelCase. A change renames the properties of
        // each model, so choose before the first make:model.
        'camelCase' => false,
        // Protected properties with a getter and a setter for each, as
        // devtools --get-set. A change changes the base of each model.
        'getSet'    => false,
        // The class name of a table, when the default name does not fit,
        // e.g. 'user_logins' => 'Login'.
        'classes'   => [],
    ],
    'paths'     => [
        'command'    => 'src/Command',
        'controller' => 'src/Controllers',
        'form'       => 'src/Forms',
        'model'      => 'src/Models',
        'module'     => 'src/Modules',
        'provider'   => 'src/Providers',
        'views'      => 'themes/default',
    ],
    'runtime'   => ['type' => 'docker', 'service' => 'app'],
];

ADR

return [
    'flavor'    => 'adr',
    'namespace' => 'App',
    'bootstrap' => App\AppFront::class,
    'paths'     => [
        'action'     => 'src/Action',
        'command'    => 'src/Command',
        'middleware' => 'src/Middleware',
        'provider'   => 'src/Provider',
        'repository' => 'src/Repository',
        'responder'  => 'src/Responder',
    ],
    'runtime'   => ['type' => 'docker', 'service' => 'app'],
];

A key that is not in the file takes its default: flavor mvc, namespace App, the default paths of the flavor (the paths in the examples above), and the host runtime. crest new writes the runtime key, with docker by default (see Creating a project). Thus the host default does not apply to a new project.

crest config:show shows the keys of crest.php with their values and their origins, except namespaces and new. declared: crest.php sets the key. default: crest.php does not set the key, or sets it to null, and Crest uses its default value. Each key of paths has its own origin.

In an MVC project, 'views' => false is a project with no views (see The MVC project). config:show then shows none for views.

In an MVC project, templateEngine is the view engine: 'templateEngine' => 'volt' for Volt views (see Volt). No key is phtml. crest new --template-engine=volt writes the key, and config:show shows it. make:scaffold writes the views of this engine.

The runtime key says where the project commands run (see The runtime).

The paths key gives a folder for each kind of file that Crest writes. Crest gets the namespace of a path from the psr-4 map of composer.json. Thus a psr-4 entry must cover each path: src/Action under App\ => src/ gives App\Action. For a folder that no psr-4 entry covers, give the namespace in the namespaces key:

MVC

return [
    'paths'      => ['controller' => 'app/Controllers'],
    'namespaces' => ['controller' => 'Shop\Controllers'],
];

ADR

return [
    'paths'      => ['action' => 'app/Handlers'],
    'namespaces' => ['action' => 'Shop\Handlers'],
];

The models key changes the names that make:model gives in an MVC project. classes gives a class to a table, and camelCase gives camelCase property names. getSet gives protected properties with a getter and a setter for each. The option --get-set of phalcon-devtools (see References) does the same. crest new and crest init write the key for an MVC project, with 'camelCase' => false and 'getSet' => false. crest new --camel-case and --get-set give true. crest config:show shows the key. See Names and Getters and setters:

return [
    'models' => [
        'classes'   => ['users' => 'User'],
        'camelCase' => true,
        'getSet'    => true,
    ],
];

models.schema gives the schema of the tables: make:model and make:scaffold then read the tables of that schema, and each base calls setSchema(). See The schema.

Crest reads vendor-dir and bin-dir as composer does. It uses COMPOSER_VENDOR_DIR and COMPOSER_BIN_DIR first, then config in composer.json, then vendor and <vendor-dir>/bin. The hand-off runs <bin-dir>/crest, and serve checks <vendor-dir>/autoload.php. With the docker runtime, composer runs in the container, so Crest reads only composer.json, and the two folders must be relative. Crest does not expand ~ or $VAR in these values: use a relative or an absolute path.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close