3

I'm having trouble getting DevMode to work locally. I'm using nitro.

I have this set in my .env file...

ENVIRONMENT=dev

... and my general.php file looks like...

<?php
/**
 * General Configuration
 *
 * All of your system's general configuration settings go in here. You can see a
 * list of the available settings in vendor/craftcms/cms/src/config/GeneralConfig.php.
 *
 * @see \craft\config\GeneralConfig
 */

use craft\helpers\App;

$isDev = App::env('ENVIRONMENT') === 'dev';
$isProd = App::env('ENVIRONMENT') === 'production';

return [
        // Default Week Start Day (0 = Sunday, 1 = Monday...)
        'defaultWeekStartDay' => 1,

        // Whether generated URLs should omit "index.php"
        'omitScriptNameInUrls' => true,

        // The URI segment that tells Craft to load the control panel
        'cpTrigger' => App::env('CP_TRIGGER') ?: 'admin',

        // The secure key Craft will use for hashing and encrypting data
        'securityKey' => App::env('SECURITY_KEY'),

        // Whether Dev Mode should be enabled (see https://craftcms.com/guides/what-dev-mode-does)
        'devMode' => $isDev,

        // Whether administrative changes should be allowed
        'allowAdminChanges' => $isDev,

        // Whether crawlers should be allowed to index pages and following links
        'disallowRobots' => !$isProd,

        // https://craftcms.com/knowledge-base/enabling-fuzzy-search
        'defaultSearchTermOptions' => [
            'subLeft' => true,
        ],

        // Global settings
            '*' => [
                'allowUpdates' => false,
                // ...
        ],

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

I've also tried just setting the devMode to true in the general.php file instead of relying on the .env file. I don't see verbose errors, and I don't see that dashed yellow line in the admin.

I'm using Servd for staging and its "force devmode" function seems to work.

I really just need it to show me the more verbose errors when I make mistakes in twig, which is a lot. I can look at the web.log for the errors, but that's much slower.

What else should I be looking at to debug this? Even if it's my .env file, the fact that directly setting it to true in the config makes me think there's something outside of these two files getting in the way.

1 Answer 1

4

you need to pass in the settings inside the '*' section.

    // Global settings
      '*' => [

        // Default Week Start Day (0 = Sunday, 1 = Monday...)
        'defaultWeekStartDay' => 1,

        // Whether generated URLs should omit "index.php"
        'omitScriptNameInUrls' => true,

        // The URI segment that tells Craft to load the control panel
        'cpTrigger' => App::env('CP_TRIGGER') ?: 'admin',

        // The secure key Craft will use for hashing and encrypting data
        'securityKey' => App::env('SECURITY_KEY'),

        // Whether Dev Mode should be enabled (see https://craftcms.com/guides/what-dev-mode-does)
        'devMode' => $isDev,

        // Whether administrative changes should be allowed
        'allowAdminChanges' => $isDev,

        // Whether crawlers should be allowed to index pages and following links
        'disallowRobots' => !$isProd,

        // https://craftcms.com/knowledge-base/enabling-fuzzy-search
        'defaultSearchTermOptions' => [
            'subLeft' => true,
        ],
  ],

https://craftcms.com/docs/3.x/config/config-settings.html#system

2
  • that's it. Thank you!
    – cringe002
    Commented Apr 29, 2022 at 21:33
  • 1
    In addition to this, Craft changed ENVIRONMENT to CRAFT_ENVIRONMENT in the default setup, so ensure you change it too!
    – ianp
    Commented Jun 1, 2022 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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