craftcms / element-api

Create a JSON API/Feed for your elements in Craft.
MIT License
498 stars 57 forks source link

Does Element API support per environment configuration? #95

Closed chrislam closed 5 years ago

chrislam commented 5 years ago

As per the description, am I able to set cache => false for dev and cache => true for other environments? If so, so I use the same system as other Craft config files to do this?

EternalBlack commented 5 years ago

@chrislam I don't know if you could use the same system as other Craft config files do but I currently use 'cache' => (bool)getenv('USECACHE'), with USECACHE=1. Works fine for me.

brandonkelly commented 5 years ago

Yep, all plugin config files support multi-environment configuration.

return [
    '*' => [
        // all your endpoint configs
    ],
    'production' => [
        'defaults' => [
            'cache' => true,
        ],
    ]
];

Or as @EternalBlack pointed out, you could just refer to an environment variable with getenv().

chrislam commented 5 years ago

Cool, thanks for the response :)