MageWork

Back to home

Configuration

Open the configuration file for your current environment: etc/config.{MW_ENVIRONMENT}.php

In this configuration file, you can define all the environment information that needs to be passed to your own objects.

Database

To interact with a database, you need to configure your database connection:

<?php

$config = [
    /* ... */
    'default' => [ // "default" is the configuration for all packages. Use the package name for a specific configuration.
        Core_Model::TYPE => [
            'database' => [
                'db_host' => '',
                'db_username' => '',
                'db_password' => '',
                'db_database' => '',
                'db_charset' => 'utf8mb4',
                'lc_time_names' => 'en_US', // Language used to display day and month names and abbreviations
                'time_zone' => '+00:00', // Affects display and storage of time values that are zone-sensitive
            ],
        ],
    ],
    /* ... */
];

This provides the connection information to the Core_Model_Database class, for all packages.

You are able to configure specific settings per package. See data assignment.

Cookie

If you need to use a session, the following configurations are available:

<?php

$config = [
    /* ... */
    'app' => [
        'session_lifetime' => 3600, // Cookie lifetime in seconds
        'cookie_same_site' => 'Lax', // None, Lax, Strict
        'cookie_http_only' => true,
    ],
    /* ... */
];

These configurations are shared by all packages.

Secured protocol port

By default, the port is 443. If you're using a certificate on a different port, a configuration allows you to define the port. This enables the application to determine if the context is secure: App::isSsl().

<?php

$config = [
    /* ... */
    'app' => [
        'secured_port' => 443,
    ],
    /* ... */
];

These configurations are shared by all packages.

Forms

To manage forms and send emails, you can configure the contact settings.

<?php

$config = [
    /* ... */
    'default' => [ // "default" is the configuration for all packages. Use the package name for a specific configuration.
        Core_Model::TYPE => [
            'form' => [
                '_mail_from_name' => 'MageWork',
                '_mail_from_email' => 'hello@example.com',
                '_mail_enabled' => true,
            ],
        ],
    ],
    /* ... */
];

This provides the contact information to the Core_Model_Form class.