The Cheeky Monkey Media Blog

A few words from the apes, monkeys, and various primates that make up the Cheeky Monkey Super Squad.

Settings php banner

If you’ve ever set up a drupal installation before, then you’re familiar with the settings.php file. This little file resides in the default folder on a typical drupal install. Normally, it’s only used to simply tell drupal about our database name and password. However, there are some other cool things you can do with it.

CSS/JS Aggregation

Often, we’ll work on sites locally and then push it up to staging or production for the client or the world to see. If you’re a good little web developer, you will want to minify and aggregate your assets, but having to disable CSS and javascript aggregation every time to pull the latest master database, can often leave one puzzled.

Because settings.php is not part of our repo, you can easily make edits on your local settings.php with the following variables overrides in it:

// Aggregate and compress CSS files in Drupal - off.

$conf['preprocess_css'] = 0;

// Aggregate JavaScript files in Drupal - off.

$conf['preprocess_js'] = 0;

Site Mail

If you’re looking to test email notifications on your local development machine and don’t want to send notifications to the person that receives e-mails on the production site, you could set the site’s admin e-mail in settings.php as well.

$conf[‘site_mail’] = ‘[email protected]’;

Custom Settings

You can also set custom settings that you can use in your PHP code, for example, a web key. You will set this variable the same way you overwrite existing ones.

$conf[‘my_custom_settings’] = ‘This is my custom string’

To get the variable in code use the handy variable_get() function

echo variable_get(‘my_custom_settings);

Experiment

A full list of the default variables that you can overwrite can be found in the drupal documentation and adding contrib modules can add extra variables that you might want to overwrite on your next project.