oliverdavies.uk/content/node.52049b70-5092-41ea-a749-5fde0d95b39e.yml

212 lines
5.7 KiB
YAML

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: |
<p>I recently said that <a href="/daily/2024/11/30/using-nix-for-local-application-development">I've been using devenv to run Drupal applications locally</a>.</p>
<p>Here's the <code>devenv.nix</code> file I used for <a href="/presentations/tdd-test-driven-drupal">my recent talk for the Drupal London meetup</a>:</p>
<pre><code class="nix">{ 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
'';
}
</code></pre>
<p>It installs the required version of PHP for this project, creates a web server (Caddy) and configures MariaDB with a default database.</p>
<p>I've also added commands to run <code>composer install</code> to download dependencies when entering the shell and <code>phpunit</code> for tests.</p>
<p>With this approach, there's no need for containers as everything is run locally and I can view the site at <a href="http://localhost:8080">http://localhost:8080</a> (or whatever port is defined).</p>
<p>All of my current development projects are using this approach and I think it'll be my default method for future projects.</p>
format: full_html
processed: |
<p>I recently said that <a href="/daily/2024/11/30/using-nix-for-local-application-development">I've been using devenv to run Drupal applications locally</a>.</p>
<p>Here's the <code>devenv.nix</code> file I used for <a href="/presentations/tdd-test-driven-drupal">my recent talk for the Drupal London meetup</a>:</p>
<pre><code class="nix">{ 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
'';
}
</code></pre>
<p>It installs the required version of PHP for this project, creates a web server (Caddy) and configures MariaDB with a default database.</p>
<p>I've also added commands to run <code>composer install</code> to download dependencies when entering the shell and <code>phpunit</code> for tests.</p>
<p>With this approach, there's no need for containers as everything is run locally and I can view the site at <a href="http://localhost:8080">http://localhost:8080</a> (or whatever port is defined).</p>
<p>All of my current development projects are using this approach and I think it'll be my default method for future projects.</p>
summary: null
field_daily_email_cta: { }