/modular-monolith-laravel

Sample application for Laracon Online 2022.

Primary LanguagePHP

Modular Monolith Laravel

The sample e-commerce application for Laracon Online Winter 2022. You can also find the slides here.

System requirements

Docker is installed on your machine.

Setup local environment

Copy example env file

cp .env.example .env

Install composer dependencies

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v $(pwd):/var/www/html \
    -w /var/www/html \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs

This repository uses Laravel Sail for the local docker environment. You can use the sail command by configuring a bash alias below.

alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'

Start docker containers

sail up -d

Generate app key and places inside the .env file

sail artisan key:generate

Run DB migration

sail artisan migrate:fresh --seed

Now you can access the app via http://localhost.

Running tests

sail composer test

Static code analysis for domain boundaries

Deptrac is a static code analysis tool for PHP that helps you define architectual layers over classes and rules on which layer can access which layer.

You can run deptrac with the command below.

sail exec app deptrac

You can also visualize the dependency graph by exporting the analysis result as an image.

sail exec app deptrac --formatter=graphviz-image --output="./deptrac.png"