laryn's picture

What is the best way (via code, e.g. in a custom module) to check if a configuration file already exists?


@Herb suggests (on Zulip) something like this:

$config = config('mymodule.settings');
if (!$config->isNew()) {

If the config has never existed before then it'll exist only as an object and have the isNew flag. Otherwise you know it existed previously.

BWPanda's picture

You could also use:

There's probably lots of other ways too...