uuid: - value: 52049b70-5092-41ea-a749-5fde0d95b39e langcode: - value: en type: - target_id: daily_email target_type: node_type target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7 revision_timestamp: - value: '2025-05-11T09:00:04+00:00' revision_uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 revision_log: { } status: - value: true uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 title: - value: 'Running Drupal on devenv' created: - value: '2024-12-09T00:00:00+00:00' changed: - value: '2025-05-11T09:00:04+00:00' promote: - value: false sticky: - value: false default_langcode: - value: true revision_translation_affected: - value: true path: - alias: /daily/2024/12/09/drupal-devenv langcode: en body: - value: |
I recently said that I've been using devenv to run Drupal applications locally.
Here's the devenv.nix
file I used for my recent talk for the Drupal London meetup:
{ pkgs, ... }:
let
drupal.root = "web";
in
{
packages = [ pkgs.git ];
dotenv.disableHint = true;
languages = {
php = {
enable = true;
version = "8.2";
ini = ''
memory_limit = 256M
'';
fpm.pools.web = {
listen = "127.0.0.1:9000";
settings = {
"pm" = "dynamic";
"pm.max_children" = 75;
"pm.max_requests" = 500;
"pm.max_spare_servers" = 20;
"pm.min_spare_servers" = 5;
"pm.start_servers" = 10;
};
};
};
};
processes = { };
services = {
caddy = {
enable = true;
config = ''
{
http_port 8080
}
localhost:8080 {
root * ${drupal.root}
encode gzip
php_fastcgi localhost:9000
file_server
}
'';
};
mysql = {
enable = true;
initialDatabases = [ { name = "drupal_london"; } ];
};
};
enterShell = ''
if [[ ! -d vendor ]]; then
composer install
fi
'';
enterTest = ''
phpunit --testdox
'';
}
It installs the required version of PHP for this project, creates a web server (Caddy) and configures MariaDB with a default database.
I've also added commands to run composer install
to download dependencies when entering the shell and phpunit
for tests.
With this approach, there's no need for containers as everything is run locally and I can view the site at http://localhost:8080 (or whatever port is defined).
All of my current development projects are using this approach and I think it'll be my default method for future projects.
format: full_html processed: |I recently said that I've been using devenv to run Drupal applications locally.
Here's the devenv.nix
file I used for my recent talk for the Drupal London meetup:
{ pkgs, ... }:
let
drupal.root = "web";
in
{
packages = [ pkgs.git ];
dotenv.disableHint = true;
languages = {
php = {
enable = true;
version = "8.2";
ini = ''
memory_limit = 256M
'';
fpm.pools.web = {
listen = "127.0.0.1:9000";
settings = {
"pm" = "dynamic";
"pm.max_children" = 75;
"pm.max_requests" = 500;
"pm.max_spare_servers" = 20;
"pm.min_spare_servers" = 5;
"pm.start_servers" = 10;
};
};
};
};
processes = { };
services = {
caddy = {
enable = true;
config = ''
{
http_port 8080
}
localhost:8080 {
root * ${drupal.root}
encode gzip
php_fastcgi localhost:9000
file_server
}
'';
};
mysql = {
enable = true;
initialDatabases = [ { name = "drupal_london"; } ];
};
};
enterShell = ''
if [[ ! -d vendor ]]; then
composer install
fi
'';
enterTest = ''
phpunit --testdox
'';
}
It installs the required version of PHP for this project, creates a web server (Caddy) and configures MariaDB with a default database.
I've also added commands to run composer install
to download dependencies when entering the shell and phpunit
for tests.
With this approach, there's no need for containers as everything is run locally and I can view the site at http://localhost:8080 (or whatever port is defined).
All of my current development projects are using this approach and I think it'll be my default method for future projects.
summary: null field_daily_email_cta: { }