A simplified project to explore event sourcing using a CQRS architecture pattern.
Below are the required steps to start development.
- Install Docker and Docker Compose.
Create a .env
file from the existing .env.dist
included in the repository.
$ cp .env.dist .env
Edit DEV_UID
to match the uid from your host machine, which will make permission management easier between docker
and your host machine.
$ sed -i "s/\(^DEV_UID=\)[^=]*$/\1$(id -u)/" .env
Run the containers in the background.
$ docker-compose up -d
Run composer through the app container to download the projects dependencies. This will also run some important post-install commands such as database migrations.
$ docker-compose exec app composer install
If everything went successfully you should now be able to access the application on http://localhost:8080.
This project uses a customised version of the Doctrine coding standard that should be followed at all times. If you're using PHPStorm you can make following this standard easier by enabling the Code Sniffer inspection.
- Navigate to
Settings > Editor > Inspections
and selectPHP > Quality Tools > PHP Code Sniffer validation
from the list. - Enable the inspection.
- Set the severity to
ERROR
and check the show warning as checkbox with the optionWEAK WARNING
. - Select the coding standard
Custom
and point the rule set path to thephpcs.xml.dist
file at the root of the project.
To check conformance to the standard, run the following command:
$ docker-compose exec app composer cs
There are some errors that can be automatically fixed by running the command below:
$ docker-compose exec app composer cs:fix
To use Xdebug update your .env
file by uncommenting the XDEBUG_CONFIG
variable and setting the remote_host
value
to the ip address of your host machine.
Next go to Settings > Languages & Frameworks > PHP > Server
and create a new server named pollhq-dev
. Set the host
to localhost
, the port to 80
, and the debugger to Xdebug
. Check the box labelled Use path mappings
and map the
project root to /var/www
.
Now create a new PHP Remote Debug
configuration (see here for details)
and name it Xdebug
. Check the box labeled Filter debug configuration by IDE key
and set the server as the one you just
created and the IDE key as PHPSTORM
.
You should now be able to debug the application using Xdebug. Add a breakpoint, navigate to PollHQ in your browser and check to see if it is caught in PHPStorm.