├── README.images ├── php.png ├── debug.png ├── docker.png ├── test-framework.png ├── cli-interpreters.png ├── docker-container.png ├── docker-file-sharing.png └── server-path-mappings.png ├── .gitignore ├── config ├── linux-hosts.sh ├── init.sh └── sites.default.settings.php ├── run-selenium.sh ├── LICENSE ├── .lando.yml └── README.md /README.images/php.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finnef/lando-drupal8-test-debugging/HEAD/README.images/php.png -------------------------------------------------------------------------------- /README.images/debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finnef/lando-drupal8-test-debugging/HEAD/README.images/debug.png -------------------------------------------------------------------------------- /README.images/docker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finnef/lando-drupal8-test-debugging/HEAD/README.images/docker.png -------------------------------------------------------------------------------- /README.images/test-framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finnef/lando-drupal8-test-debugging/HEAD/README.images/test-framework.png -------------------------------------------------------------------------------- /README.images/cli-interpreters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finnef/lando-drupal8-test-debugging/HEAD/README.images/cli-interpreters.png -------------------------------------------------------------------------------- /README.images/docker-container.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finnef/lando-drupal8-test-debugging/HEAD/README.images/docker-container.png -------------------------------------------------------------------------------- /README.images/docker-file-sharing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finnef/lando-drupal8-test-debugging/HEAD/README.images/docker-file-sharing.png -------------------------------------------------------------------------------- /README.images/server-path-mappings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finnef/lando-drupal8-test-debugging/HEAD/README.images/server-path-mappings.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore generated directories 2 | /web 3 | /files 4 | 5 | # Ignore files generated by PhpStorm 6 | /.idea/ 7 | 8 | # Ignore local db-dumps 9 | *.sql 10 | *.sql* 11 | -------------------------------------------------------------------------------- /config/linux-hosts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HOST_DOMAIN="host.docker.internal" 4 | ping -q -c1 $HOST_DOMAIN > /dev/null 2>&1 5 | if [ $? -ne 0 ]; then 6 | HOST_IP=$(ip route | awk 'NR==1 {print $3}') 7 | echo $HOST_IP $HOST_DOMAIN >> /etc/hosts 8 | fi 9 | -------------------------------------------------------------------------------- /run-selenium.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Prepare PATH for Chrome web driver. 4 | case "$(uname -s)" in 5 | Darwin) 6 | echo 'detected Mac OS X' 7 | DRIVER_PATH=mac 8 | ;; 9 | Linux|GNU*|*BSD) 10 | echo 'detected Linux' 11 | DRIVER_PATH=linux 12 | ;; 13 | CYGWIN*|MINGW32*|MSYS*) 14 | echo 'detected Windows' 15 | DRIVER_PATH=windows 16 | ;; 17 | esac 18 | export PATH=`pwd`/web/vendor/joomla-projects/selenium-server-standalone/bin/webdrivers/chrome/$DRIVER_PATH:$PATH 19 | 20 | # Launch Selenium. 21 | `pwd`/web/vendor/bin/selenium-server-standalone 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Finne Fortuin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.lando.yml: -------------------------------------------------------------------------------- 1 | name: drupal8phpunit 2 | # https://docs.devwithlando.io/tutorials/drupal8.html 3 | recipe: drupal8 4 | 5 | # Requires lando 3.0.0-rc2 or higher. 6 | # You can put local (non-git) overrides in .lando.local.yml 7 | 8 | # Add some default configuration for the recipe here. Which will be passed to all the services within the recipe. 9 | # https://docs.devwithlando.io/recipes/drupal8.html 10 | config: 11 | # Set the php version. 12 | php: 7.3 13 | # Set the webroot dir. 14 | webroot: web 15 | # Enable xdebug using "lando xdebug-on" tooling defined below. 16 | xdebug: false 17 | 18 | # We can add additional services here or even override some configuration. 19 | services: 20 | appserver: 21 | run: 22 | - 'bash config/init.sh' 23 | overrides: 24 | environment: 25 | # Enable PHPStorm XDebug with CLI. 26 | PHP_IDE_CONFIG: "serverName=appserver" 27 | # Set the Mink webdriver args. 28 | MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", null, "http://host.docker.internal:4444/wd/hub"]' 29 | volumes: 30 | # Fix linux docker host.docker.internal resolving. 31 | - 'config/linux-hosts.sh:/scripts/linux-hosts.sh' 32 | database: 33 | # Add a static db port for easy bookmarking and access through SQL clients. 34 | # Ideally you would set this in a .lando.local.yml. 35 | portforward: 33006 36 | 37 | # This will add some tools from the containers to the command line of your OS. 38 | # https://docs.devwithlando.io/config/tooling.html 39 | tooling: 40 | phpunit: 41 | service: appserver 42 | description: "Run PHP Unit tests: lando phpunit" 43 | cmd: "/app/web/vendor/bin/phpunit --debug --configuration /app/web/core/phpunit.xml --printer=\\Drupal\\Tests\\Listeners\\HtmlOutputPrinter" 44 | drush: 45 | cmd: "/app/web/vendor/bin/drush --root=/app/web --uri=http://drupal8phpunit.lndo.site" 46 | drupal: 47 | cmd: "/app/web/vendor/bin/drupal --root=/app/web" 48 | xdebug-on: 49 | service: appserver 50 | description: Enable xdebug. 51 | cmd: "docker-php-ext-enable xdebug && /etc/init.d/apache2 reload" 52 | user: root 53 | xdebug-off: 54 | service: appserver 55 | description: Disable xdebug. 56 | cmd: "rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && /etc/init.d/apache2 reload" 57 | user: root 58 | -------------------------------------------------------------------------------- /config/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Install Drupal. 4 | cd $LANDO_MOUNT 5 | if [ -d 'web' ]; then 6 | echo "Web folder already exists. No git clone executed." 7 | FIRST_RUN=0 8 | else 9 | # Do a git checkout of the current D8 core. 10 | echo "Cloning drupal core." 11 | git clone --depth 1 https://git.drupal.org/project/drupal.git web 12 | FIRST_RUN=1 13 | fi 14 | 15 | echo "Composer installing drupal core." 16 | cd /app/web 17 | composer install 18 | 19 | if [ $FIRST_RUN ]; then 20 | # Upgrade PHPUnit to work with PHP 7, add drush, console, selenium 21 | composer require --update-with-dependencies "phpunit/phpunit ^6.0" "drush/drush" "drupal/console" "joomla-projects/selenium-server-standalone" 22 | fi 23 | 24 | # Create file dirs. 25 | echo "Creating dirs and symlinks." 26 | cd /app 27 | mkdir -p -m 777 /app/web/sites/default/files/phpunit 28 | mkdir -p -m 777 /app/web/sites/simpletest 29 | mkdir -p -m 777 /app/files/private 30 | mkdir -p -m 777 /app/files/tmp 31 | mkdir -p -m 777 /app/files/sync 32 | 33 | # Copy the settings and symlink the file dirs. 34 | if [ ! -e "/app/web/sites/default/settings.php" ]; then 35 | cp /app/config/sites.default.settings.php /app/web/sites/default/settings.php 36 | fi 37 | if [ ! -L "/app/files/public" ]; then 38 | ln -s /app/web/sites/default/files /app/files/public 39 | fi 40 | if [ ! -L "files/simpletest" ]; then 41 | ln -s /app/web/sites/simpletest /app/files/simpletest 42 | fi 43 | 44 | if [ $FIRST_RUN ]; then 45 | echo "Installing default site." 46 | cd /app/web 47 | drush site-install -y 48 | cd /app/ 49 | fi 50 | 51 | if [ ! -f /app/web/.gitignore ]; then 52 | # Ignore changed core files 53 | echo "composer.json 54 | composer.lock 55 | vendor 56 | sites/default/settings.php 57 | sites/default/files 58 | sites/simpletest 59 | " > /app/web/.gitignore 60 | fi 61 | 62 | # Create phpunit.xml and configure. 63 | if [ ! -f /app/web/core/phpunit.xml ]; then 64 | echo 'Creating phpunit.xml.' 65 | cd /app/web/core 66 | cp phpunit.xml.dist phpunit.xml 67 | sed -i 's/SIMPLETEST_DB" value=""/SIMPLETEST_DB" value="sqlite:\/\/localhost\/\/app\/web\/sites\/default\/files\/test.sqlite"/' phpunit.xml 68 | sed -i 's/SIMPLETEST_BASE_URL" value=""/SIMPLETEST_BASE_URL" value="http:\/\/\'$LANDO_APP_NAME'.'$LANDO_DOMAIN'"/' phpunit.xml 69 | sed -i 's/BROWSERTEST_OUTPUT_DIRECTORY" value=""/BROWSERTEST_OUTPUT_DIRECTORY" value="\/app\/web\/sites\/default\/files\/phpunit"/' phpunit.xml 70 | sed -i 's/beStrictAboutOutputDuringTests="true"/beStrictAboutOutputDuringTests="false" verbose="true"/' phpunit.xml 71 | sed -i 's/<\/phpunit>/<\/logging><\/phpunit>/' phpunit.xml 72 | fi 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lando-drupal8-test-debugging 2 | 3 | ## Purpose 4 | The purpose of this lando "recipe" is to provide an easy setup for Drupal 8 core development, especially writing and debugging tests. This is geared towards PHPStorm, but should also work with other tools. 5 | 6 | ## Setup 7 | 8 | ### To start: 9 | 1. Make sure your software stack is installed and up to date: you need an up to date version of [lando](https://github.com/lando/lando/releases), Docker, Chrome and java. 10 | 2. Download the the repo to a new empty project directory. 11 | 3. Start docker (make sure your project dir [or parent dir] is shared in Docker > Preferences > File sharing) 12 | 4. run 'lando start' from inside this dir. 13 | 14 | ### Run! 15 | 16 | You should now be able to run Drupal 8 core tests. From the command line it looks like this: 17 | ```bash 18 | # unit test 19 | lando phpunit "/app/web/core/modules/toolbar/tests/src/Unit/PageCache/AllowToolbarPathTest.php" 20 | # kernel test 21 | lando phpunit "/app/web/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php" 22 | # functional test 23 | lando phpunit "/app/web/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php" 24 | # functional javascript test 25 | sh run-selenium.sh 26 | lando phpunit "/app/web/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebWithWebDriverAssertTest.php" 27 | ``` 28 | NB: You need to provide the path to the test file as seen in the container, not the host. 29 | NNB: For Functional Javascript tests you need to start the selenium server before running the test. Selenium requires that you have java installed on your host. 30 | NNNB: Sometimes testing becomes very slow. It can help to restart docker, or even your entire machine. 31 | 32 | The test output files can be found in various locations under the /files directory. 33 | 34 | ### Debugging in PHPStorm: check your PHPStorm debug settings: 35 | - To debug tests run from the command line you only need to provide a php server configuration in PhpStorm. Configure path mappings so PHPStorm knows where you are when debugging. Make sure the server is named 'appserver' and you map the top level path to '/app': Preferences > Languages & Frameworks > PHP > Servers ![server-path-mappings](README.images/server-path-mappings.png) 36 | 37 | Try and enable xdebug ('lando xdebug-on'), enable your debug listener in PHPStorm, setting a breakpoint in a test and running a test. You should now be able to debug your tests. 38 | 39 | NB: Running Docker (for Mac) with a debugger on slows down php quite a bit. Use the tooling provided to quickly switch debugging on/off without restarting your containers: 'lando xdebug-on' and 'lando xdebug-off'. 40 | NNB: Docker for Mac can be quite slow because of the slow file syncing. The default settings sync your user folder, including all data in ~/Library. To speed up Docker you should only sync folders you need: your project folders, and the composer/ssh/lando config dirs: 41 | 42 | ![docker-file-sharing](README.images/docker-file-sharing.png) 43 | 44 | ### Running tests in PHPStorm: check your PHPStorm debug settings: 45 | - To run tests from the PhpStorm GUI you need to configure a test framework. The test framework needs a CLI interpreter that refers to Docker, so the first thing to do is configure PhpStorm to register Docker: Preferences > Build, Execution, Deployment > Docker ![docker](README.images/docker.png) 46 | - Register the CLI PHP interpreter from Docker so you can use its debugger: Preferences > Languages & Frameworks > PHP, then click the '...' button after CLI Interpreter, then add a new From Docker interpreter from the correct Docker image ![cli-interpreters](README.images/cli-interpreters.png) 47 | - Change the default Docker container settings so the network and path mapping correspond to lando's defaults: Preferences > Languages & Frameworks > PHP, then click the folder icon after button after the line "Docker container" ![docker-container](README.images/docker-container.png) 48 | - Configure the test framework so PHPStorm can run tests using the PHPStorm GUI: Preferences > Languages & Frameworks > PHP > Test Frameworks, add a PHPUnit by Remote Interpreter and choose the Docker interpreter. Make sure you set the autoload script, config file and bootstrap file using paths that are local to the PHPStorm docker helper container as shown: ![test-framework](README.images/test-framework.png) 49 | 50 | In PHPStorm try to right-click a test function and select 'run'. Running tests via the PHPStorm GUI currently only works with Unit and Kernel tests. 51 | 52 | - If you are having trouble getting this to work check the PHP debug settings, especially the max simultaneous connections: Preferences > Languages & Frameworks > PHP > Debug ![debug](README.images/debug.png) 53 | 54 | 55 | 56 | ### The files in this package do the following: 57 | - **.lando.yml**: the lando file that spins up the apache/php/database containers and set some defaults. Here the init.sh script is called after the containers are up. 58 | - **config/init.sh**: this script (shallow) clones the Drupal git repository to the /web dir, and checks out the default branch. Then composer install runs to complete the vendor dir. It upgrades the phpunit version to work with PHP 7.1, and installs Drush, Drupal Console and Selenium. It creates dirs for file operations in /files. It links config/sites.default.settings.php into the Drupal installation so base setup is automatic. Then it runs drush site-install to setup a working installation. Lastly it configures phpunit.xml for testing. 59 | - **config/linux-hosts.sh**: The hostname host.docker.internal resolves to the host machine from a container in Docker for Mac and Windows, but not Linux. This script adds this name to the hosts file. 60 | - **config/sites.default.settings.php**: this settings file contains development defaults for Drupal 8. It connects to the lando database container. 61 | - **run-selenium.sh**: this script sets the correct Chrome drive path and launches the project-local standalone Selenium server. 62 | 63 | 64 | ## Future improvements 65 | - run functional and fjs tests via PHPStorm GUI 66 | - export and import PHPStorm settings 67 | - enable Test module by default 68 | - use Chromedriver without Selenium 69 | - cater for different ports if 80 is taken (in SIMPLETEST_BASE_URL) 70 | 71 | -------------------------------------------------------------------------------- /config/sites.default.settings.php: -------------------------------------------------------------------------------- 1 | 'databasename', 90 | * 'username' => 'sqlusername', 91 | * 'password' => 'sqlpassword', 92 | * 'host' => 'localhost', 93 | * 'port' => '3306', 94 | * 'driver' => 'mysql', 95 | * 'prefix' => '', 96 | * 'collation' => 'utf8mb4_general_ci', 97 | * ); 98 | * @endcode 99 | */ 100 | $databases = []; 101 | 102 | /** 103 | * Customizing database settings. 104 | * 105 | * Many of the values of the $databases array can be customized for your 106 | * particular database system. Refer to the sample in the section above as a 107 | * starting point. 108 | * 109 | * The "driver" property indicates what Drupal database driver the 110 | * connection should use. This is usually the same as the name of the 111 | * database type, such as mysql or sqlite, but not always. The other 112 | * properties will vary depending on the driver. For SQLite, you must 113 | * specify a database file name in a directory that is writable by the 114 | * webserver. For most other drivers, you must specify a 115 | * username, password, host, and database name. 116 | * 117 | * Transaction support is enabled by default for all drivers that support it, 118 | * including MySQL. To explicitly disable it, set the 'transactions' key to 119 | * FALSE. 120 | * Note that some configurations of MySQL, such as the MyISAM engine, don't 121 | * support it and will proceed silently even if enabled. If you experience 122 | * transaction related crashes with such configuration, set the 'transactions' 123 | * key to FALSE. 124 | * 125 | * For each database, you may optionally specify multiple "target" databases. 126 | * A target database allows Drupal to try to send certain queries to a 127 | * different database if it can but fall back to the default connection if not. 128 | * That is useful for primary/replica replication, as Drupal may try to connect 129 | * to a replica server when appropriate and if one is not available will simply 130 | * fall back to the single primary server (The terms primary/replica are 131 | * traditionally referred to as master/slave in database server documentation). 132 | * 133 | * The general format for the $databases array is as follows: 134 | * @code 135 | * $databases['default']['default'] = $info_array; 136 | * $databases['default']['replica'][] = $info_array; 137 | * $databases['default']['replica'][] = $info_array; 138 | * $databases['extra']['default'] = $info_array; 139 | * @endcode 140 | * 141 | * In the above example, $info_array is an array of settings described above. 142 | * The first line sets a "default" database that has one primary database 143 | * (the second level default). The second and third lines create an array 144 | * of potential replica databases. Drupal will select one at random for a given 145 | * request as needed. The fourth line creates a new database with a name of 146 | * "extra". 147 | * 148 | * You can optionally set prefixes for some or all database table names 149 | * by using the 'prefix' setting. If a prefix is specified, the table 150 | * name will be prepended with its value. Be sure to use valid database 151 | * characters only, usually alphanumeric and underscore. If no prefixes 152 | * are desired, leave it as an empty string ''. 153 | * 154 | * To have all database names prefixed, set 'prefix' as a string: 155 | * @code 156 | * 'prefix' => 'main_', 157 | * @endcode 158 | * 159 | * Per-table prefixes are deprecated as of Drupal 8.2, and will be removed in 160 | * Drupal 9.0. After that, only a single prefix for all tables will be 161 | * supported. 162 | * 163 | * To provide prefixes for specific tables, set 'prefix' as an array. 164 | * The array's keys are the table names and the values are the prefixes. 165 | * The 'default' element is mandatory and holds the prefix for any tables 166 | * not specified elsewhere in the array. Example: 167 | * @code 168 | * 'prefix' => array( 169 | * 'default' => 'main_', 170 | * 'users' => 'shared_', 171 | * 'sessions' => 'shared_', 172 | * 'role' => 'shared_', 173 | * 'authmap' => 'shared_', 174 | * ), 175 | * @endcode 176 | * You can also use a reference to a schema/database as a prefix. This may be 177 | * useful if your Drupal installation exists in a schema that is not the default 178 | * or you want to access several databases from the same code base at the same 179 | * time. 180 | * Example: 181 | * @code 182 | * 'prefix' => array( 183 | * 'default' => 'main.', 184 | * 'users' => 'shared.', 185 | * 'sessions' => 'shared.', 186 | * 'role' => 'shared.', 187 | * 'authmap' => 'shared.', 188 | * ); 189 | * @endcode 190 | * NOTE: MySQL and SQLite's definition of a schema is a database. 191 | * 192 | * Advanced users can add or override initial commands to execute when 193 | * connecting to the database server, as well as PDO connection settings. For 194 | * example, to enable MySQL SELECT queries to exceed the max_join_size system 195 | * variable, and to reduce the database connection timeout to 5 seconds: 196 | * @code 197 | * $databases['default']['default'] = array( 198 | * 'init_commands' => array( 199 | * 'big_selects' => 'SET SQL_BIG_SELECTS=1', 200 | * ), 201 | * 'pdo' => array( 202 | * PDO::ATTR_TIMEOUT => 5, 203 | * ), 204 | * ); 205 | * @endcode 206 | * 207 | * WARNING: The above defaults are designed for database portability. Changing 208 | * them may cause unexpected behavior, including potential data loss. See 209 | * https://www.drupal.org/developing/api/database/configuration for more 210 | * information on these defaults and the potential issues. 211 | * 212 | * More details can be found in the constructor methods for each driver: 213 | * - \Drupal\Core\Database\Driver\mysql\Connection::__construct() 214 | * - \Drupal\Core\Database\Driver\pgsql\Connection::__construct() 215 | * - \Drupal\Core\Database\Driver\sqlite\Connection::__construct() 216 | * 217 | * Sample Database configuration format for PostgreSQL (pgsql): 218 | * @code 219 | * $databases['default']['default'] = array( 220 | * 'driver' => 'pgsql', 221 | * 'database' => 'databasename', 222 | * 'username' => 'sqlusername', 223 | * 'password' => 'sqlpassword', 224 | * 'host' => 'localhost', 225 | * 'prefix' => '', 226 | * ); 227 | * @endcode 228 | * 229 | * Sample Database configuration format for SQLite (sqlite): 230 | * @code 231 | * $databases['default']['default'] = array( 232 | * 'driver' => 'sqlite', 233 | * 'database' => '/path/to/databasefilename', 234 | * ); 235 | * @endcode 236 | */ 237 | 238 | /** 239 | * Location of the site configuration files. 240 | * 241 | * The $config_directories array specifies the location of file system 242 | * directories used for configuration data. On install, the "sync" directory is 243 | * created. This is used for configuration imports. The "active" directory is 244 | * not created by default since the default storage for active configuration is 245 | * the database rather than the file system. (This can be changed. See "Active 246 | * configuration settings" below). 247 | * 248 | * The default location for the "sync" directory is inside a randomly-named 249 | * directory in the public files path. The setting below allows you to override 250 | * the "sync" location. 251 | * 252 | * If you use files for the "active" configuration, you can tell the 253 | * Configuration system where this directory is located by adding an entry with 254 | * array key CONFIG_ACTIVE_DIRECTORY. 255 | * 256 | * Example: 257 | * @code 258 | * $config_directories = array( 259 | * CONFIG_SYNC_DIRECTORY => '/directory/outside/webroot', 260 | * ); 261 | * @endcode 262 | */ 263 | $config_directories = []; 264 | 265 | /** 266 | * Settings: 267 | * 268 | * $settings contains environment-specific configuration, such as the files 269 | * directory and reverse proxy address, and temporary configuration, such as 270 | * security overrides. 271 | * 272 | * @see \Drupal\Core\Site\Settings::get() 273 | */ 274 | 275 | /** 276 | * Salt for one-time login links, cancel links, form tokens, etc. 277 | * 278 | * This variable will be set to a random value by the installer. All one-time 279 | * login links will be invalidated if the value is changed. Note that if your 280 | * site is deployed on a cluster of web servers, you must ensure that this 281 | * variable has the same value on each server. 282 | * 283 | * For enhanced security, you may set this variable to the contents of a file 284 | * outside your document root; you should also ensure that this file is not 285 | * stored with backups of your database. 286 | * 287 | * Example: 288 | * @code 289 | * $settings['hash_salt'] = file_get_contents('/home/example/salt.txt'); 290 | * @endcode 291 | */ 292 | $settings['hash_salt'] = 'MxnQKjysVmigO8vw_k5QQwDEM3Ri08frS7YuodoxqTZYOIykCWqVzAMT4X8NKKF9JCdJ81_-qw'; 293 | 294 | /** 295 | * Deployment identifier. 296 | * 297 | * Drupal's dependency injection container will be automatically invalidated and 298 | * rebuilt when the Drupal core version changes. When updating contributed or 299 | * custom code that changes the container, changing this identifier will also 300 | * allow the container to be invalidated as soon as code is deployed. 301 | */ 302 | # $settings['deployment_identifier'] = \Drupal::VERSION; 303 | 304 | /** 305 | * Access control for update.php script. 306 | * 307 | * If you are updating your Drupal installation using the update.php script but 308 | * are not logged in using either an account with the "Administer software 309 | * updates" permission or the site maintenance account (the account that was 310 | * created during installation), you will need to modify the access check 311 | * statement below. Change the FALSE to a TRUE to disable the access check. 312 | * After finishing the upgrade, be sure to open this file again and change the 313 | * TRUE back to a FALSE! 314 | */ 315 | $settings['update_free_access'] = FALSE; 316 | 317 | /** 318 | * External access proxy settings: 319 | * 320 | * If your site must access the Internet via a web proxy then you can enter the 321 | * proxy settings here. Set the full URL of the proxy, including the port, in 322 | * variables: 323 | * - $settings['http_client_config']['proxy']['http']: The proxy URL for HTTP 324 | * requests. 325 | * - $settings['http_client_config']['proxy']['https']: The proxy URL for HTTPS 326 | * requests. 327 | * You can pass in the user name and password for basic authentication in the 328 | * URLs in these settings. 329 | * 330 | * You can also define an array of host names that can be accessed directly, 331 | * bypassing the proxy, in $settings['http_client_config']['proxy']['no']. 332 | */ 333 | # $settings['http_client_config']['proxy']['http'] = 'http://proxy_user:proxy_pass@example.com:8080'; 334 | # $settings['http_client_config']['proxy']['https'] = 'http://proxy_user:proxy_pass@example.com:8080'; 335 | # $settings['http_client_config']['proxy']['no'] = ['127.0.0.1', 'localhost']; 336 | 337 | /** 338 | * Reverse Proxy Configuration: 339 | * 340 | * Reverse proxy servers are often used to enhance the performance 341 | * of heavily visited sites and may also provide other site caching, 342 | * security, or encryption benefits. In an environment where Drupal 343 | * is behind a reverse proxy, the real IP address of the client should 344 | * be determined such that the correct client IP address is available 345 | * to Drupal's logging, statistics, and access management systems. In 346 | * the most simple scenario, the proxy server will add an 347 | * X-Forwarded-For header to the request that contains the client IP 348 | * address. However, HTTP headers are vulnerable to spoofing, where a 349 | * malicious client could bypass restrictions by setting the 350 | * X-Forwarded-For header directly. Therefore, Drupal's proxy 351 | * configuration requires the IP addresses of all remote proxies to be 352 | * specified in $settings['reverse_proxy_addresses'] to work correctly. 353 | * 354 | * Enable this setting to get Drupal to determine the client IP from 355 | * the X-Forwarded-For header (or $settings['reverse_proxy_header'] if set). 356 | * If you are unsure about this setting, do not have a reverse proxy, 357 | * or Drupal operates in a shared hosting environment, this setting 358 | * should remain commented out. 359 | * 360 | * In order for this setting to be used you must specify every possible 361 | * reverse proxy IP address in $settings['reverse_proxy_addresses']. 362 | * If a complete list of reverse proxies is not available in your 363 | * environment (for example, if you use a CDN) you may set the 364 | * $_SERVER['REMOTE_ADDR'] variable directly in settings.php. 365 | * Be aware, however, that it is likely that this would allow IP 366 | * address spoofing unless more advanced precautions are taken. 367 | */ 368 | # $settings['reverse_proxy'] = TRUE; 369 | 370 | /** 371 | * Specify every reverse proxy IP address in your environment. 372 | * This setting is required if $settings['reverse_proxy'] is TRUE. 373 | */ 374 | # $settings['reverse_proxy_addresses'] = ['a.b.c.d', ...]; 375 | 376 | /** 377 | * Set this value if your proxy server sends the client IP in a header 378 | * other than X-Forwarded-For. 379 | */ 380 | # $settings['reverse_proxy_header'] = 'X_CLUSTER_CLIENT_IP'; 381 | 382 | /** 383 | * Set this value if your proxy server sends the client protocol in a header 384 | * other than X-Forwarded-Proto. 385 | */ 386 | # $settings['reverse_proxy_proto_header'] = 'X_FORWARDED_PROTO'; 387 | 388 | /** 389 | * Set this value if your proxy server sends the client protocol in a header 390 | * other than X-Forwarded-Host. 391 | */ 392 | # $settings['reverse_proxy_host_header'] = 'X_FORWARDED_HOST'; 393 | 394 | /** 395 | * Set this value if your proxy server sends the client protocol in a header 396 | * other than X-Forwarded-Port. 397 | */ 398 | # $settings['reverse_proxy_port_header'] = 'X_FORWARDED_PORT'; 399 | 400 | /** 401 | * Set this value if your proxy server sends the client protocol in a header 402 | * other than Forwarded. 403 | */ 404 | # $settings['reverse_proxy_forwarded_header'] = 'FORWARDED'; 405 | 406 | /** 407 | * Page caching: 408 | * 409 | * By default, Drupal sends a "Vary: Cookie" HTTP header for anonymous page 410 | * views. This tells a HTTP proxy that it may return a page from its local 411 | * cache without contacting the web server, if the user sends the same Cookie 412 | * header as the user who originally requested the cached page. Without "Vary: 413 | * Cookie", authenticated users would also be served the anonymous page from 414 | * the cache. If the site has mostly anonymous users except a few known 415 | * editors/administrators, the Vary header can be omitted. This allows for 416 | * better caching in HTTP proxies (including reverse proxies), i.e. even if 417 | * clients send different cookies, they still get content served from the cache. 418 | * However, authenticated users should access the site directly (i.e. not use an 419 | * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid 420 | * getting cached pages from the proxy. 421 | */ 422 | # $settings['omit_vary_cookie'] = TRUE; 423 | 424 | 425 | /** 426 | * Cache TTL for client error (4xx) responses. 427 | * 428 | * Items cached per-URL tend to result in a large number of cache items, and 429 | * this can be problematic on 404 pages which by their nature are unbounded. A 430 | * fixed TTL can be set for these items, defaulting to one hour, so that cache 431 | * backends which do not support LRU can purge older entries. To disable caching 432 | * of client error responses set the value to 0. Currently applies only to 433 | * page_cache module. 434 | */ 435 | # $settings['cache_ttl_4xx'] = 3600; 436 | 437 | /** 438 | * Expiration of cached forms. 439 | * 440 | * Drupal's Form API stores details of forms in a cache and these entries are 441 | * kept for at least 6 hours by default. Expired entries are cleared by cron. 442 | * 443 | * @see \Drupal\Core\Form\FormCache::setCache() 444 | */ 445 | # $settings['form_cache_expiration'] = 21600; 446 | 447 | /** 448 | * Class Loader. 449 | * 450 | * If the APC extension is detected, the Symfony APC class loader is used for 451 | * performance reasons. Detection can be prevented by setting 452 | * class_loader_auto_detect to false, as in the example below. 453 | */ 454 | # $settings['class_loader_auto_detect'] = FALSE; 455 | 456 | /* 457 | * If the APC extension is not detected, either because APC is missing or 458 | * because auto-detection has been disabled, auto-loading falls back to 459 | * Composer's ClassLoader, which is good for development as it does not break 460 | * when code is moved in the file system. You can also decorate the base class 461 | * loader with another cached solution than the Symfony APC class loader, as 462 | * all production sites should have a cached class loader of some sort enabled. 463 | * 464 | * To do so, you may decorate and replace the local $class_loader variable. For 465 | * example, to use Symfony's APC class loader without automatic detection, 466 | * uncomment the code below. 467 | */ 468 | /* 469 | if ($settings['hash_salt']) { 470 | $prefix = 'drupal.' . hash('sha256', 'drupal.' . $settings['hash_salt']); 471 | $apc_loader = new \Symfony\Component\ClassLoader\ApcClassLoader($prefix, $class_loader); 472 | unset($prefix); 473 | $class_loader->unregister(); 474 | $apc_loader->register(); 475 | $class_loader = $apc_loader; 476 | } 477 | */ 478 | 479 | /** 480 | * Authorized file system operations: 481 | * 482 | * The Update Manager module included with Drupal provides a mechanism for 483 | * site administrators to securely install missing updates for the site 484 | * directly through the web user interface. On securely-configured servers, 485 | * the Update manager will require the administrator to provide SSH or FTP 486 | * credentials before allowing the installation to proceed; this allows the 487 | * site to update the new files as the user who owns all the Drupal files, 488 | * instead of as the user the webserver is running as. On servers where the 489 | * webserver user is itself the owner of the Drupal files, the administrator 490 | * will not be prompted for SSH or FTP credentials (note that these server 491 | * setups are common on shared hosting, but are inherently insecure). 492 | * 493 | * Some sites might wish to disable the above functionality, and only update 494 | * the code directly via SSH or FTP themselves. This setting completely 495 | * disables all functionality related to these authorized file operations. 496 | * 497 | * @see https://www.drupal.org/node/244924 498 | * 499 | * Remove the leading hash signs to disable. 500 | */ 501 | # $settings['allow_authorize_operations'] = FALSE; 502 | 503 | /** 504 | * Default mode for directories and files written by Drupal. 505 | * 506 | * Value should be in PHP Octal Notation, with leading zero. 507 | */ 508 | # $settings['file_chmod_directory'] = 0775; 509 | # $settings['file_chmod_file'] = 0664; 510 | 511 | /** 512 | * Public file base URL: 513 | * 514 | * An alternative base URL to be used for serving public files. This must 515 | * include any leading directory path. 516 | * 517 | * A different value from the domain used by Drupal to be used for accessing 518 | * public files. This can be used for a simple CDN integration, or to improve 519 | * security by serving user-uploaded files from a different domain or subdomain 520 | * pointing to the same server. Do not include a trailing slash. 521 | */ 522 | # $settings['file_public_base_url'] = 'http://downloads.example.com/files'; 523 | 524 | /** 525 | * Public file path: 526 | * 527 | * A local file system path where public files will be stored. This directory 528 | * must exist and be writable by Drupal. This directory must be relative to 529 | * the Drupal installation directory and be accessible over the web. 530 | */ 531 | # $settings['file_public_path'] = 'sites/default/files'; 532 | 533 | /** 534 | * Private file path: 535 | * 536 | * A local file system path where private files will be stored. This directory 537 | * must be absolute, outside of the Drupal installation directory and not 538 | * accessible over the web. 539 | * 540 | * Note: Caches need to be cleared when this value is changed to make the 541 | * private:// stream wrapper available to the system. 542 | * 543 | * See https://www.drupal.org/documentation/modules/file for more information 544 | * about securing private files. 545 | */ 546 | # $settings['file_private_path'] = ''; 547 | 548 | /** 549 | * Session write interval: 550 | * 551 | * Set the minimum interval between each session write to database. 552 | * For performance reasons it defaults to 180. 553 | */ 554 | # $settings['session_write_interval'] = 180; 555 | 556 | /** 557 | * String overrides: 558 | * 559 | * To override specific strings on your site with or without enabling the Locale 560 | * module, add an entry to this list. This functionality allows you to change 561 | * a small number of your site's default English language interface strings. 562 | * 563 | * Remove the leading hash signs to enable. 564 | * 565 | * The "en" part of the variable name, is dynamic and can be any langcode of 566 | * any added language. (eg locale_custom_strings_de for german). 567 | */ 568 | # $settings['locale_custom_strings_en'][''] = [ 569 | # 'forum' => 'Discussion board', 570 | # '@count min' => '@count minutes', 571 | # ]; 572 | 573 | /** 574 | * A custom theme for the offline page: 575 | * 576 | * This applies when the site is explicitly set to maintenance mode through the 577 | * administration page or when the database is inactive due to an error. 578 | * The template file should also be copied into the theme. It is located inside 579 | * 'core/modules/system/templates/maintenance-page.html.twig'. 580 | * 581 | * Note: This setting does not apply to installation and update pages. 582 | */ 583 | # $settings['maintenance_theme'] = 'bartik'; 584 | 585 | /** 586 | * PHP settings: 587 | * 588 | * To see what PHP settings are possible, including whether they can be set at 589 | * runtime (by using ini_set()), read the PHP documentation: 590 | * http://php.net/manual/ini.list.php 591 | * See \Drupal\Core\DrupalKernel::bootEnvironment() for required runtime 592 | * settings and the .htaccess file for non-runtime settings. 593 | * Settings defined there should not be duplicated here so as to avoid conflict 594 | * issues. 595 | */ 596 | 597 | /** 598 | * If you encounter a situation where users post a large amount of text, and 599 | * the result is stripped out upon viewing but can still be edited, Drupal's 600 | * output filter may not have sufficient memory to process it. If you 601 | * experience this issue, you may wish to uncomment the following two lines 602 | * and increase the limits of these variables. For more information, see 603 | * http://php.net/manual/pcre.configuration.php. 604 | */ 605 | # ini_set('pcre.backtrack_limit', 200000); 606 | # ini_set('pcre.recursion_limit', 200000); 607 | 608 | /** 609 | * Active configuration settings. 610 | * 611 | * By default, the active configuration is stored in the database in the 612 | * {config} table. To use a different storage mechanism for the active 613 | * configuration, do the following prior to installing: 614 | * - Create an "active" directory and declare its path in $config_directories 615 | * as explained under the 'Location of the site configuration files' section 616 | * above in this file. To enhance security, you can declare a path that is 617 | * outside your document root. 618 | * - Override the 'bootstrap_config_storage' setting here. It must be set to a 619 | * callable that returns an object that implements 620 | * \Drupal\Core\Config\StorageInterface. 621 | * - Override the service definition 'config.storage.active'. Put this 622 | * override in a services.yml file in the same directory as settings.php 623 | * (definitions in this file will override service definition defaults). 624 | */ 625 | # $settings['bootstrap_config_storage'] = ['Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage']; 626 | 627 | /** 628 | * Configuration overrides. 629 | * 630 | * To globally override specific configuration values for this site, 631 | * set them here. You usually don't need to use this feature. This is 632 | * useful in a configuration file for a vhost or directory, rather than 633 | * the default settings.php. 634 | * 635 | * Note that any values you provide in these variable overrides will not be 636 | * viewable from the Drupal administration interface. The administration 637 | * interface displays the values stored in configuration so that you can stage 638 | * changes to other environments that don't have the overrides. 639 | * 640 | * There are particular configuration values that are risky to override. For 641 | * example, overriding the list of installed modules in 'core.extension' is not 642 | * supported as module install or uninstall has not occurred. Other examples 643 | * include field storage configuration, because it has effects on database 644 | * structure, and 'core.menu.static_menu_link_overrides' since this is cached in 645 | * a way that is not config override aware. Also, note that changing 646 | * configuration values in settings.php will not fire any of the configuration 647 | * change events. 648 | */ 649 | # $config['system.file']['path']['temporary'] = '/tmp'; 650 | # $config['system.site']['name'] = 'My Drupal site'; 651 | # $config['system.theme']['default'] = 'stark'; 652 | # $config['user.settings']['anonymous'] = 'Visitor'; 653 | 654 | /** 655 | * Fast 404 pages: 656 | * 657 | * Drupal can generate fully themed 404 pages. However, some of these responses 658 | * are for images or other resource files that are not displayed to the user. 659 | * This can waste bandwidth, and also generate server load. 660 | * 661 | * The options below return a simple, fast 404 page for URLs matching a 662 | * specific pattern: 663 | * - $config['system.performance']['fast_404']['exclude_paths']: A regular 664 | * expression to match paths to exclude, such as images generated by image 665 | * styles, or dynamically-resized images. The default pattern provided below 666 | * also excludes the private file system. If you need to add more paths, you 667 | * can add '|path' to the expression. 668 | * - $config['system.performance']['fast_404']['paths']: A regular expression to 669 | * match paths that should return a simple 404 page, rather than the fully 670 | * themed 404 page. If you don't have any aliases ending in htm or html you 671 | * can add '|s?html?' to the expression. 672 | * - $config['system.performance']['fast_404']['html']: The html to return for 673 | * simple 404 pages. 674 | * 675 | * Remove the leading hash signs if you would like to alter this functionality. 676 | */ 677 | # $config['system.performance']['fast_404']['exclude_paths'] = '/\/(?:styles)|(?:system\/files)\//'; 678 | # $config['system.performance']['fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; 679 | # $config['system.performance']['fast_404']['html'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; 680 | 681 | /** 682 | * Load services definition file. 683 | */ 684 | $settings['container_yamls'][] = $app_root . '/' . $site_path . '/services.yml'; 685 | 686 | /** 687 | * Override the default service container class. 688 | * 689 | * This is useful for example to trace the service container for performance 690 | * tracking purposes, for testing a service container with an error condition or 691 | * to test a service container that throws an exception. 692 | */ 693 | # $settings['container_base_class'] = '\Drupal\Core\DependencyInjection\Container'; 694 | 695 | /** 696 | * Override the default yaml parser class. 697 | * 698 | * Provide a fully qualified class name here if you would like to provide an 699 | * alternate implementation YAML parser. The class must implement the 700 | * \Drupal\Component\Serialization\SerializationInterface interface. 701 | */ 702 | # $settings['yaml_parser_class'] = NULL; 703 | 704 | /** 705 | * Trusted host configuration. 706 | * 707 | * Drupal core can use the Symfony trusted host mechanism to prevent HTTP Host 708 | * header spoofing. 709 | * 710 | * To enable the trusted host mechanism, you enable your allowable hosts 711 | * in $settings['trusted_host_patterns']. This should be an array of regular 712 | * expression patterns, without delimiters, representing the hosts you would 713 | * like to allow. 714 | * 715 | * For example: 716 | * @code 717 | * $settings['trusted_host_patterns'] = array( 718 | * '^www\.example\.com$', 719 | * ); 720 | * @endcode 721 | * will allow the site to only run from www.example.com. 722 | * 723 | * If you are running multisite, or if you are running your site from 724 | * different domain names (eg, you don't redirect http://www.example.com to 725 | * http://example.com), you should specify all of the host patterns that are 726 | * allowed by your site. 727 | * 728 | * For example: 729 | * @code 730 | * $settings['trusted_host_patterns'] = array( 731 | * '^example\.com$', 732 | * '^.+\.example\.com$', 733 | * '^example\.org$', 734 | * '^.+\.example\.org$', 735 | * ); 736 | * @endcode 737 | * will allow the site to run off of all variants of example.com and 738 | * example.org, with all subdomains included. 739 | */ 740 | 741 | /** 742 | * The default list of directories that will be ignored by Drupal's file API. 743 | * 744 | * By default ignore node_modules and bower_components folders to avoid issues 745 | * with common frontend tools and recursive scanning of directories looking for 746 | * extensions. 747 | * 748 | * @see file_scan_directory() 749 | * @see \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory() 750 | */ 751 | $settings['file_scan_ignore_directories'] = [ 752 | 'node_modules', 753 | 'bower_components', 754 | ]; 755 | 756 | /** 757 | * The default number of entities to update in a batch process. 758 | * 759 | * This is used by update and post-update functions that need to go through and 760 | * change all the entities on a site, so it is useful to increase this number 761 | * if your hosting configuration (i.e. RAM allocation, CPU speed) allows for a 762 | * larger number of entities to be processed in a single batch run. 763 | */ 764 | $settings['entity_update_batch_size'] = 50; 765 | 766 | /** 767 | * Load local development override configuration, if available. 768 | * 769 | * Use settings.local.php to override variables on secondary (staging, 770 | * development, etc) installations of this site. Typically used to disable 771 | * caching, JavaScript/CSS compression, re-routing of outgoing emails, and 772 | * other things that should not happen on development and testing sites. 773 | * 774 | * Keep this code block at the end of this file to take full effect. 775 | */ 776 | # 777 | # if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) { 778 | # include $app_root . '/' . $site_path . '/settings.local.php'; 779 | # } 780 | 781 | $config_directories[CONFIG_SYNC_DIRECTORY] = $app_root . '/../files/sync'; 782 | 783 | if (getenv('LANDO') === 'ON') { 784 | $lando_info = json_decode(getenv('LANDO_INFO'), TRUE); 785 | $databases['default']['default'] = [ 786 | 'database' => $lando_info['database']['creds']['database'], 787 | 'username' => $lando_info['database']['creds']['user'], 788 | 'password' => $lando_info['database']['creds']['password'], 789 | 'prefix' => '', 790 | 'host' => $lando_info['database']['internal_connection']['host'], 791 | 'port' => $lando_info['database']['internal_connection']['port'], 792 | 'driver' => 'mysql', 793 | ]; 794 | } 795 | 796 | /** 797 | * File paths. 798 | */ 799 | $settings['file_private_path'] = '../files/private'; 800 | $config['system.file']['path.temporary'] = '../files/tmp'; 801 | 802 | /** 803 | * Show all error messages, with backtrace information. 804 | * 805 | * In case the error level could not be fetched from the database, as for 806 | * example the database connection failed, we rely only on this value. 807 | */ 808 | $config['system.logging']['error_level'] = 'verbose'; 809 | 810 | /** 811 | * Skip file system permissions hardening. 812 | * 813 | * The system module will periodically check the permissions of your site's 814 | * site directory to ensure that it is not writable by the website user. For 815 | * sites that are managed with a version control system, this can cause problems 816 | * when files in that directory such as settings.php are updated, because the 817 | * user pulling in the changes won't have permissions to modify files in the 818 | * directory. 819 | */ 820 | $settings['skip_permissions_hardening'] = TRUE; 821 | 822 | /** 823 | * Trusted Hosts. 824 | */ 825 | $local_hostname = getenv('LANDO_APP_NAME') . '.' . getenv('LANDO_DOMAIN'); 826 | $settings['trusted_host_patterns'] = array( 827 | '^127\.0\.0\.1$', 828 | '^localhost$', 829 | "^$local_hostname$", 830 | ); 831 | --------------------------------------------------------------------------------