Skip to content

Commit

Permalink
updated readme and defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
finnef committed Jun 26, 2019
1 parent 08bf40a commit f144db8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ recipe: drupal8
# Add some default configuration for the recipe here. Which will be passed to all the services within the recipe.
# https://docs.devwithlando.io/recipes/drupal8.html
config:
# Set the php version.
php: 7.3
# Set the webroot dir.
webroot: web
# Enable xdebug using "lando xdebug-on" tooling defined below.
Expand Down
Binary file added README.images/docker-container.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README.images/test-framework.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ The purpose of this lando "recipe" is to provide an easy setup for Drupal 8 core
## Setup

### To start:
1. Make sure your software stack is installed and up to date: you need [lando](https://github.com/lando/lando/releases), Docker, Chrome and java.
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.
2. Download the the repo to a new empty dir.
3. Run lando start from inside this dir.
3. Start docker and run lando start from inside this dir.

### Run!

Expand All @@ -30,16 +30,24 @@ NNNB: Sometimes testing becomes very slow. It can help to restart docker, or eve

The test output files can be found in various locations under the /files directory.

### Running tests and debugging in PHPStorm: check your PHPStorm debug settings:
- Register Docker so you can register its PHP interpreter: Preferences > Build, Execution, Deployment > Docker ![docker](README.images/docker.png)
### Debugging in PHPStorm: check your PHPStorm debug settings:
- 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)

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.

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'.

### Running tests in PHPStorm: check your PHPStorm debug settings:
- 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)
- 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)
- Configure the PHP debug settings, especially the max simultaneous connections: Preferences > Languages & Frameworks > PHP > Debug ![debug](README.images/debug.png)
- Configure a server with 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)
- Configure the test framework so PHPStorm can run tests using the PHPStorm GUI (right click a test and select "run"). Add a PHPUnit by Remote Interpreter and choose the Docker interpreter. Make sure you set the config file and bootstrap file using paths that are local to the PHPStorm docker helper container as shown: Preferences > Languages & Frameworks > PHP > Test Frameworks ![test-framework](README.images/test-framework.png)
- 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)
- 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)

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.

Try and enable your debug listener in PHPStorm, setting a breakpoint in a test and running a test (CLI or GUI). You should now be able to debug your tests.
- 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)



### The files in this package do the following:
- **.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.
Expand All @@ -51,7 +59,6 @@ Try and enable your debug listener in PHPStorm, setting a breakpoint in a test a

## Future imporvements
- run functional and fjs tests via PHPStorm GUI
- find out why we cannot use phpunit 7
- export and import PHPStorm settings
- enable Test module by default
- use Chromedriver without Selenium
Expand Down

0 comments on commit f144db8

Please sign in to comment.