Files
merchbay/LOCAL_DEVELOPMENT.md
Frank John Begornia e8d21d22f8
All checks were successful
Deploy Development / deploy (push) Successful in 2m30s
Add local environment configuration and setup documentation for development
2025-12-18 16:30:14 +08:00

2.8 KiB

Local Development Setup for Merchbay

Quick Start

  1. Copy local environment file:

    cp .env.local .env
    
  2. Build and start containers:

    docker-compose -f docker-compose.local.yml up -d --build
    
  3. Generate application key:

    docker exec merchbay_app_local php artisan key:generate
    
  4. Run migrations:

    docker exec merchbay_app_local php artisan migrate
    
  5. Access the application:

Development Commands

View logs

# Application logs
docker exec merchbay_app_local tail -f storage/logs/laravel.log

# Apache logs
docker logs -f merchbay_app_local

Run artisan commands

docker exec merchbay_app_local php artisan [command]

Access container shell

docker exec -it merchbay_app_local bash

Database access

docker exec -it merchbay_db_local mysql -u merchbay -psecret merchbay

Clear caches

docker exec merchbay_app_local php artisan cache:clear
docker exec merchbay_app_local php artisan config:clear
docker exec merchbay_app_local php artisan view:clear

Stop containers

docker-compose -f docker-compose.local.yml down

Stop and remove volumes (clean slate)

docker-compose -f docker-compose.local.yml down -v

Debugging

Enable Xdebug (if needed)

Add to Dockerfile:

RUN pecl install xdebug-2.9.8 && docker-php-ext-enable xdebug

Check container status

docker-compose -f docker-compose.local.yml ps

View all logs

docker-compose -f docker-compose.local.yml logs -f

Hot Reload Development

For live code changes without rebuilding:

  • Code changes in .php files are reflected immediately (via volume mount)
  • View changes are reflected immediately
  • Config/route changes require cache clearing

Database Management

Import SQL dump

docker exec -i merchbay_db_local mysql -u merchbay -psecret merchbay < dump.sql

Export database

docker exec merchbay_db_local mysqldump -u merchbay -psecret merchbay > dump.sql

Troubleshooting

Permission issues

docker exec merchbay_app_local chown -R www-data:www-data storage bootstrap/cache
docker exec merchbay_app_local chmod -R 775 storage bootstrap/cache

Reset everything

docker-compose -f docker-compose.local.yml down -v
docker rmi merchbay_app:local
rm .env
cp .env.local .env
docker-compose -f docker-compose.local.yml up -d --build

Notes

  • The local setup uses a separate MySQL container
  • All code changes are live-mounted for easy development
  • Mail is logged to storage/logs/laravel.log instead of being sent
  • phpMyAdmin is available for easy database management