2

I'm trying to setup aliases following the instructions in the docs, but I can't get them to work (for example they don't appear when setting paths for Assets).

I copied and pasted the code exactly as the example in the docs, and the env variable ROOT_URL shows up in the CP, but the alias @rootUrl does not. Is there another step? I tried clearing caches and logging out/in, but that didn't help.

In the config/general.php file I pasted the code last, right below Dev environment settings. Here is that last portion of the config:

    // Dev environment settings
        'dev' => [
            // existing settings ...
            'backupCommand' => getenv('BACKUP_COMMAND'),
            'restoreCommand' => getenv('RESTORE_COMMAND'),
        ],

    // -- config/general.php Code example from docs --
        'aliases' => [
            '@rootUrl' => getenv('ROOT_URL'),
        ],
];

Also, the 3.6 upgrade documentation states (emphasis mine):

The siteName and siteUrl config settings have been deprecated. We strongly recommend you set your sites’ names and URLs using environment variables instead.

So, does this mean I shouldn't even be bothering with aliases? Should everything be an environment variable only?

2

Try to add your alias array within one of your environment array such as:

<?php

return [
    // Global settings
    '*' => [
        'aliases' => [
            '@rootUrl' => getenv('ROOT_URL'),
        ],
    ],

    // Dev environment settings
    'dev' => [
        // ...
    ],

    // Staging environment settings
    'staging' => [
        // ...
    ],

    // Production environment settings
    'production' => [
        // ...
    ],
];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.