https://github.com/Orphail/laravel-ddd
For launch, run Laravel Sail first
docker compose build --no-cache
docker compose up -d
docker compose exec laravel.test bash
In the laravel.test container,
composer install
cp .env.example .env
php artisan key:generate
npm install
npm run build
For new domains, use this command: php artisan make:domain {Bounded Context} {Domain}
(e.g. php artisan make:domain Blog Post
)
In order to enable xDebug with Laravel Sail
- add below in /docker/8.2/php.ini
[XDebug]
zend_extension = xdebug.so
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.discover_client_host = true
xdebug.idekey = VSC
xdebug.client_host = host.docker.internal
xdebug.client_port = 9003
- update Docker file
...
ARG XDEBUG
...
RUN if [ ${XDEBUG}] ; then \
apt-get install -y php-xdebug; \
fi;
...
- update supervisord.conf The Swoole server doesn't support xDebug at the moment. So, in order to use xDebug, we need to use php default server.
[program:octane]
command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan octane:start --server=swoole --host=0.0.0.0 --port=80 --watch
user=sail
environment=LARAVEL_SAIL="1"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:php-xdebug]
command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=8000
user=sail
environment=LARAVEL_SAIL="1"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
- rebuild docker with
docker compose build --no-cache
- add launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug on Docker App",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
},
"hostname": "localhost",
"xdebugSettings": {
"max_data": 65535,
"show_hidden": 1,
"max_children": 100,
"max_depth": 5
}
}
]
}
- update .env
SAIL_XDEBUG_MODE=develop,debug
- run docker
docker compose up -d
- debug code Debug with http://localhost:8000/