- MailDev SMTP Server + Web Interface for viewing and testing emails during development.
- PHP 7.4.x (CLI) with Composer, PHP CodeSniffer, phpDocumentor, phpunit and XDebug for development.
- Clone or download and extract this repo
- Rename the
.env.example
file to.env
and check the contained settings - Open the project main folder (the folder containing this README) with vscode
- Build the docker container with
docker-compose build
and start it withdocker-compose up -d
in the terminal or use the context menu over thedocker-compose.yml
file (right click > compose up) from vscode - Keep an eye at bottom right and confirm when you are asked to reopen the project in the dev container
The Visual Studio Code Remote - Containers extension lets you use a Docker container as a full-featured development environment. It allows you to open any folder or repository inside a container and take advantage of Visual Studio Code's full feature set. The devcontainer.json file tells VS Code how to access (or create) the development container with well-defined tool and runtime stack.
Since everything that has to do with the stack, only runs in the container, you have to put the commands into the corresponding container. Check the provided wrappers in the folder ./bin/
.
The local folder code
is mapped to /opt/code
in the phpdev container
Read more:
- PHP_CodeSniffer is a set of two PHP scripts; the main
phpcs
script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a secondphpcbf
script to automatically correct coding standard violations. - phpDocumentor is the de-facto documentation application for PHP projects.
- PHPUnit is a programmer-oriented testing framework for PHP.
- Xdebug - Debugger and Profiler Tool for PHP
The configured coding standard used by PHP_CodeSniffer is the PSR-12 coding standard. To check a file against the PEAR coding standard, use the --standard
command line argument: phpcs --standard=PEAR /path/to/code-directory
The name of the trigger is XDEBUG_TRIGGER, and Xdebug checks for its presence in either $_ENV (environment variable), $_GET or $_POST variable, or $_COOKIE (HTTP cookie name).
- PHP Debug: Debug support for PHP with Xdebug
- phpcs: PHP CodeSniffer for Visual Studio Code.
- phpcbf: PHP Code Beautifier and Fixer.
- PHP DocBlocker: A simple, dependency free PHP specific DocBlocking package.
- Git File History: Modern, fast and intuitive tool for browsing the history and files in any git repository.
- Git Graph: View a Git Graph of your repository, and perform Git actions from the graph.
- gitignore: Add file to .gitignore.
- GitLens: Supercharge the Git capabilities built into Visual Studio Code.
- Error Lens: Improve highlighting of errors, warnings and other language diagnostics.
- Path Intellisense: Visual Studio Code plugin that autocompletes filenames.
- Resource Monitor: Displays current CPU stats, memory/disk consumption, and battery percentage remaining.
To build the container, enter the following command in the terminal:
docker-compose build --compress --force-rm --no-cache
To start/stop the stack, enter the following command in the terminal:
docker-compose up -d
docker-compose down
To open a shell in the application's container, use:
docker exec -it <container> /bin/bash
To test if email works
docker exec -i maildev echo -n 'Subject: test\n\nTesting Email' | sendmail -v [email protected]
To execute a PHP script:
cd code
docker exec -i phpdev php example.php
Copy the bin
folder to your local computer and add the local folder to your PATH environment variable.
If you are using powershell add following command into your vscode settings.json:
"phpcs.executablePath": "phpcs.bat",
"php.executablePath": "php.bat",
"php.validate.executablePath": "php.bat"
If you are using git bash add following command into your vscode settings.json:
"phpcs.executablePath": "phpcs",
"php.executablePath": "php",
"php.validate.executablePath": "php"