Merge symfony-server-drupal/master

This commit is contained in:
Oliver Davies 2025-09-29 22:53:24 +01:00
commit 0e809eb46d
13 changed files with 316 additions and 0 deletions

5
symfony-server-drupal/.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
vendor/
web/
.editorconfig
.gitattributes
composer.lock

View file

@ -0,0 +1 @@
7.3

View file

@ -0,0 +1,34 @@
# Testing the Symfony Local Server with Drupal
An example of running Drupal 8.8 on Symfonys [local web server][docs].
[docs]: https://symfony.com/doc/current/setup/symfony_server.html
![A screenshot of Drupal's status page showing Symfony Local Server](docs/status.png)
## Usage
1. Install the Symfony CLI from <https://symfony.com/download>.
1. Clone this repository
```bash
git clone https://github.com/opdavies/symfony-server-drupal-test.git
cd symfony-server-drupal-test
```
1. Run `composer install` to download all of the projects dependencies (Drupal core, Examples module etc).
1. Run `docker-compose up -d` to start the Docker container for MySQL. (You can run `docker-compose ps` afterwards to confirm that its running).
1. Run `symfony server:start` to start the web server.
1. Use Drush to install Drupal, prefixed by `symfony php` to allow access to the environment variables needed in `settings.php`:
```bash
cd web
symfony php ../vendor/bin/drush site:install --no-interaction
```
1. Go to http://127.0.0.1:8000 to view the site.
1. To run tests, PHPUnit also needs to be prefixed with `symfony php`:
```bash
cd web
symfony php ../vendor/bin/phpunit -c core core/modules/action
```
1. Run `symfony server:stop` to stop the web server.

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
<!-- PHPUnit expects functional tests to be run with either a privileged user
or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details.
-->
<phpunit bootstrap="tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter">
<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
<ini name="memory_limit" value="-1"/>
<env name="SIMPLETEST_BASE_URL" value="http://localhost:8000"/>
<env name="SIMPLETEST_DB" value="sqlite://localhost//tmp/test.sqlite"/>
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/>
<env name="BROWSERTEST_OUTPUT_BASE_URL" value=""/>
<env name="MINK_DRIVER_CLASS" value=''/>
<env name="MINK_DRIVER_ARGS" value=''/>
<env name="MINK_DRIVER_ARGS_PHANTOMJS" value=''/>
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=''/>
</php>
<testsuites>
<testsuite name="unit">
<file>./tests/TestSuites/UnitTestSuite.php</file>
</testsuite>
<testsuite name="kernel">
<file>./tests/TestSuites/KernelTestSuite.php</file>
</testsuite>
<testsuite name="functional">
<file>./tests/TestSuites/FunctionalTestSuite.php</file>
</testsuite>
<testsuite name="functional-javascript">
<file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
</testsuite>
<testsuite name="build">
<file>./tests/TestSuites/BuildTestSuite.php</file>
</testsuite>
</testsuites>
<listeners>
<listener class="\Drupal\Tests\Listeners\DrupalListener">
</listener>
<!-- The Symfony deprecation listener has to come after the Drupal listener -->
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
</listener>
</listeners>
<!-- Filter for coverage reports. -->
<filter>
<whitelist>
<directory>./includes</directory>
<directory>./lib</directory>
<!-- Extensions can have their own test directories, so exclude those. -->
<directory>./modules</directory>
<exclude>
<directory>./modules/*/src/Tests</directory>
<directory>./modules/*/tests</directory>
</exclude>
<directory>../modules</directory>
<exclude>
<directory>../modules/*/src/Tests</directory>
<directory>../modules/*/tests</directory>
<directory>../modules/*/*/src/Tests</directory>
<directory>../modules/*/*/tests</directory>
</exclude>
<directory>../sites</directory>
</whitelist>
</filter>
</phpunit>

View file

@ -0,0 +1,33 @@
<?php
// @codingStandardsIgnoreFile
$databases = [];
if ($_SERVER['SYMFONY_DOCKER_ENV']) {
$databases['default']['default'] = [
'driver' => $_SERVER['DATABASE_DRIVER'],
'host' => $_SERVER['DATABASE_HOST'],
'database' => $_SERVER['DATABASE_NAME'],
'username' => $_SERVER['DATABASE_USER'],
'password' => $_SERVER['DATABASE_PASSWORD'],
'port' => $_SERVER['DATABASE_PORT'],
'prefix' => '',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'collation' => 'utf8mb4_general_ci',
];
}
$settings['hash_salt'] = '53cr3t!';
$settings['update_free_access'] = FALSE;
$settings['container_yamls'][] = $app_root . '/' . $site_path . '/services.yml';
$settings['file_scan_ignore_directories'] = [
'node_modules',
'bower_components',
];
$settings['entity_update_batch_size'] = 50;
$settings['entity_update_backup'] = TRUE;

View file

@ -0,0 +1,62 @@
{
"name": "drupal/recommended-project",
"description": "Project template for Drupal 8 projects with a relocated document root",
"type": "project",
"license": "GPL-2.0-or-later",
"homepage": "https://www.drupal.org/project/drupal",
"support": {
"docs": "https://www.drupal.org/docs/user_guide/en/index.html",
"chat": "https://www.drupal.org/node/314178"
},
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"composer/installers": "^1.2",
"drupal/admin_toolbar": "^2.0",
"drupal/config_installer": "^1.8",
"drupal/core-composer-scaffold": "^8.8",
"drupal/core-recommended": "^8.8",
"drush/drush": "^9"
},
"require-dev": {
"drupal/core-dev": "^8.8"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true
},
"scripts": {
"copy-web-assets": "cp -vR assets/web/ web",
"post-install-cmd": [
"@copy-web-assets"
],
"post-update-cmd": [
"@copy-web-assets"
]
},
"extra": {
"drupal-scaffold": {
"locations": {
"web-root": "web/"
}
},
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": ["type:drupal-library"],
"web/modules/contrib/{$name}": ["type:drupal-module"],
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/contrib/{$name}": ["type:drupal-drush"],
"web/modules/custom/{$name}": ["type:drupal-custom-module"],
"web/themes/custom/{$name}": ["type:drupal-custom-theme"]
}
}
}

View file

@ -0,0 +1,27 @@
# Deny all requests from Apache 2.4+.
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
# Deny all requests from Apache 2.0-2.2.
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
# Turn off all options we don't need.
Options -Indexes -ExecCGI -Includes -MultiViews
# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
# Override the handler again if we're run later in the evaluation list.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>
# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
<IfModule mod_php7.c>
php_flag engine off
</IfModule>

View file

@ -0,0 +1,27 @@
# Deny all requests from Apache 2.4+.
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
# Deny all requests from Apache 2.0-2.2.
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
# Turn off all options we don't need.
Options -Indexes -ExecCGI -Includes -MultiViews
# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
# Override the handler again if we're run later in the evaluation list.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>
# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
<IfModule mod_php7.c>
php_flag engine off
</IfModule>

View file

@ -0,0 +1,24 @@
version: '2.1'
services:
database:
image: mysql:5.7
ports: [3306]
environment:
MYSQL_ROOT_PASSWORD: secret
volumes:
- mysql-data:/var/lib/mysql
database_umami:
image: mysql:5.7
ports: [3306]
environment:
MYSQL_ROOT_PASSWORD: secret
volumes:
- mysql-data-umami:/var/lib/mysql
labels:
com.symfony.server.service-prefix: 'DATABASE_UMAMI'
volumes:
mysql-data:
mysql-data-umami:

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

View file

@ -0,0 +1,2 @@
[Date]
date.timezone = Europe/London

View file

@ -0,0 +1,15 @@
<?php
$databases['default']['default'] = [
'driver' => $_SERVER['DATABASE_DRIVER'],
'host' => $_SERVER['DATABASE_HOST'],
'database' => $_SERVER['DATABASE_NAME'],
'username' => $_SERVER['DATABASE_USER'],
'password' => $_SERVER['DATABASE_PASSWORD'],
'port' => $_SERVER['DATABASE_PORT'],
'prefix' => '',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'collation' => 'utf8mb4_general_ci',
];
$settings["config_sync_directory"] = '../config/default';

View file

@ -0,0 +1,15 @@
<?php
$databases['default']['default'] = [
'driver' => $_SERVER['DATABASE_UMAMI_DRIVER'],
'host' => $_SERVER['DATABASE_UMAMI_HOST'],
'database' => $_SERVER['DATABASE_UMAMI_NAME'],
'username' => $_SERVER['DATABASE_UMAMI_USER'],
'password' => $_SERVER['DATABASE_UMAMI_PASSWORD'],
'port' => $_SERVER['DATABASE_UMAMI_PORT'],
'prefix' => '',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'collation' => 'utf8mb4_general_ci',
];
$settings["config_sync_directory"] = '../config/umami';