r/PHPhelp • u/00ProBoy00 • Mar 19 '25
Laravel Sail does not reflect code changes.
I use Windows 11 / WSL2 / Laravel Sail.
When I make changes in code, they do not reflect in real time.
To make them reflect, I have to run sail artisan view:clear and sometimes I must restart the container.
Is it a Laravel, WSL, or Docker's issue?
Does anyone have this issue as well? how did you fix it? I don't think I am the only one having it because I found some posts on the internet about it.
I don't have any cache, I already tried running sail artisan view:clear, sail artisan cache:clear and sail artisan optimize:clear.
I noticed something, the folder storage/framework/cache/data is empty but storage/framework/views is full of .php and .blade.php files which when I run sail artisan view:clear they be deleted, does this have a relation to my issue?
Edit: include my docker-compose.yml file
services:
laravel.test:
build:
context: './vendor/laravel/sail/runtimes/8.4'
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: 'sail-8.4/app'
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
IGNITION_LOCAL_SITES_PATH: '${PWD}'
volumes:
- '.:/var/www/html'
- "../../laravel-packages/ssp:/var/www/laravel-packages/ssp"
networks:
- sail
depends_on:
- mysql
mysql:
image: 'mysql/mysql-server:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: '%'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- 'sail-mysql:/var/lib/mysql'
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
networks:
- sail
healthcheck:
test:
- CMD
- mysqladmin
- ping
- '-p${DB_PASSWORD}'
retries: 3
timeout: 5s
networks:
sail:
driver: bridge
volumes:
sail-mysql:
driver: local
3
u/ArchMob Mar 19 '25
Your web server/browser is caching probs
1
u/32gbsd Mar 19 '25
how do you define real time? because you know they have to cache things deep down just to get everything to run fast.
1
u/zolom214 Mar 19 '25
Try: php artisan optimize
1
u/SpinakerMan Mar 21 '25
Does your issue happen when trying to run something that is using a job queue? If so, you have to restart the queue worker first. I use PHPstorm and have an action on save set that does it automatically.
1
u/dave8271 Mar 21 '25
What Docker Desktop version precisely are you on?
1
u/majferson Mar 22 '25
Have you tried use different browsers in incognito mode?
1
u/benz738 Oct 20 '25
Ensure your local env is not caching configurations/view by running `sail artisan optimize:clear`.
Using caching when developing can cause this issues.
BTW you can also experience some delay before changes are propagated to the container, but that must take only seconds, if it requires you to run `artisan *:clear`, then it's laravel's caching.
0
u/[deleted] Mar 19 '25
[deleted] — view deleted comment