Drupal best practice settings
Having installed Drupal in DDEV on WSL2, as explained in the previous pages of this guide, here are a couple of best-practice things to set up before you continue with development.
settings.local.php
For development, it is recommended to enable a local PHP settings file, in particular so that all errors are displayed in the browser. You can also use it to disable caching, disable Javascript/CSS compression, and reroute outgoing emails etc..
In your Ubuntu terminal, from your project folder, copy the example local settings file to a new file, settings.local.php:
cp web/sites/example.settings.local.php web/sites/default/settings.local.phpIn web/sites/default/settings.php, enable settings.local.php by uncommenting these 3 lines at the bottom, by removing the leading # :
# if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
# include $app_root . '/' . $site_path . '/settings.local.php';
# }Private file system path
While you're editing settings.php, it's a good idea to set your private file system path to be outside the site's web root, where private files are inaccessible from the web.
In your Ubuntu terminal, from your project folder, create a new directory named private:
mkdir privateIn web/sites/default/settings.php, add the following line, or uncomment the existing line and modify it:
$settings['file_private_path'] = '../private';Summary & next steps
This guide explained how to install WSL2 & Ubuntu, then Docker, DDEV and Drupal on a Windows PC.
It offered tips and basic instruction on how to use Ubuntu and DDEV from the perspective of a Windows-using site builder with no Linux experience and limited development experience.
It also showed you how to integrate Visual Studio Code with these tools to create an efficient development environment.
Finally, this page showed you a couple of best-practice Drupal settings to configure for development.
Visit the Develop documentation for more guidance on tools, processes, and standards for Drupal developers.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion