diff --git a/symfony-server-drupal/.gitignore b/symfony-server-drupal/.gitignore new file mode 100644 index 0000000..cc3d84f --- /dev/null +++ b/symfony-server-drupal/.gitignore @@ -0,0 +1,5 @@ +vendor/ +web/ +.editorconfig +.gitattributes +composer.lock diff --git a/symfony-server-drupal/.php-version b/symfony-server-drupal/.php-version new file mode 100644 index 0000000..f994162 --- /dev/null +++ b/symfony-server-drupal/.php-version @@ -0,0 +1 @@ +7.3 diff --git a/symfony-server-drupal/README.md b/symfony-server-drupal/README.md new file mode 100644 index 0000000..7c1ffff --- /dev/null +++ b/symfony-server-drupal/README.md @@ -0,0 +1,34 @@ +# Testing the Symfony Local Server with Drupal + +An example of running Drupal 8.8 on Symfony’s [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 . +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 project’s 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 it’s 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. diff --git a/symfony-server-drupal/assets/web/core/phpunit.xml b/symfony-server-drupal/assets/web/core/phpunit.xml new file mode 100644 index 0000000..ca0d9be --- /dev/null +++ b/symfony-server-drupal/assets/web/core/phpunit.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + ./tests/TestSuites/UnitTestSuite.php + + + ./tests/TestSuites/KernelTestSuite.php + + + ./tests/TestSuites/FunctionalTestSuite.php + + + ./tests/TestSuites/FunctionalJavascriptTestSuite.php + + + ./tests/TestSuites/BuildTestSuite.php + + + + + + + + + + + + + ./includes + ./lib + + ./modules + + ./modules/*/src/Tests + ./modules/*/tests + + ../modules + + ../modules/*/src/Tests + ../modules/*/tests + ../modules/*/*/src/Tests + ../modules/*/*/tests + + ../sites + + + diff --git a/symfony-server-drupal/assets/web/sites/default/settings.php b/symfony-server-drupal/assets/web/sites/default/settings.php new file mode 100644 index 0000000..40f37a9 --- /dev/null +++ b/symfony-server-drupal/assets/web/sites/default/settings.php @@ -0,0 +1,33 @@ + $_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; diff --git a/symfony-server-drupal/composer.json b/symfony-server-drupal/composer.json new file mode 100644 index 0000000..4c0d4fe --- /dev/null +++ b/symfony-server-drupal/composer.json @@ -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"] + } + } +} diff --git a/symfony-server-drupal/config/default/.htaccess b/symfony-server-drupal/config/default/.htaccess new file mode 100644 index 0000000..c323d54 --- /dev/null +++ b/symfony-server-drupal/config/default/.htaccess @@ -0,0 +1,27 @@ +# Deny all requests from Apache 2.4+. + + Require all denied + + +# Deny all requests from Apache 2.0-2.2. + + Deny from all + + +# 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 + + # Override the handler again if we're run later in the evaluation list. + SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003 + + +# If we know how to do it safely, disable the PHP engine entirely. + + php_flag engine off + + + php_flag engine off + \ No newline at end of file diff --git a/symfony-server-drupal/config/umami/.htaccess b/symfony-server-drupal/config/umami/.htaccess new file mode 100644 index 0000000..c323d54 --- /dev/null +++ b/symfony-server-drupal/config/umami/.htaccess @@ -0,0 +1,27 @@ +# Deny all requests from Apache 2.4+. + + Require all denied + + +# Deny all requests from Apache 2.0-2.2. + + Deny from all + + +# 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 + + # Override the handler again if we're run later in the evaluation list. + SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003 + + +# If we know how to do it safely, disable the PHP engine entirely. + + php_flag engine off + + + php_flag engine off + \ No newline at end of file diff --git a/symfony-server-drupal/docker-compose.yaml b/symfony-server-drupal/docker-compose.yaml new file mode 100644 index 0000000..ceac1fa --- /dev/null +++ b/symfony-server-drupal/docker-compose.yaml @@ -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: diff --git a/symfony-server-drupal/docs/status.png b/symfony-server-drupal/docs/status.png new file mode 100644 index 0000000..6ed6f68 Binary files /dev/null and b/symfony-server-drupal/docs/status.png differ diff --git a/symfony-server-drupal/php.ini b/symfony-server-drupal/php.ini new file mode 100644 index 0000000..4143154 --- /dev/null +++ b/symfony-server-drupal/php.ini @@ -0,0 +1,2 @@ +[Date] +date.timezone = Europe/London diff --git a/symfony-server-drupal/web/sites/default/settings.php b/symfony-server-drupal/web/sites/default/settings.php new file mode 100644 index 0000000..cbba35e --- /dev/null +++ b/symfony-server-drupal/web/sites/default/settings.php @@ -0,0 +1,15 @@ + $_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'; diff --git a/symfony-server-drupal/web/sites/umami/settings.php b/symfony-server-drupal/web/sites/umami/settings.php new file mode 100644 index 0000000..57addf3 --- /dev/null +++ b/symfony-server-drupal/web/sites/umami/settings.php @@ -0,0 +1,15 @@ + $_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';