Files
Laravel-Docker-Dev-Template/setup.bat
theRADcozaDEV 97acc5e8ea CRITICAL FIX: Move composer install after containers start
The previous setup scripts ran 'composer install' in a temporary container
before starting the actual containers. This caused vendor/ directory to be
created inside the temporary container and then deleted, leaving the host
filesystem without dependencies.

Changes:
- setup.bat: Move composer install to Step 4 (after containers start)
- setup.sh: Move composer install to Step 4 (after containers start)
- Use 'docker-compose exec' instead of 'docker-compose run --rm'
- This ensures vendor/ is written to the host filesystem via volume mount
- Added TEST_SETUP.md with comprehensive testing procedures

Now the vendor/ directory will persist correctly on Windows/WSL2 and the
app will load without 'vendor/autoload.php not found' errors.

This was the root cause of the setup not being truly '2-minute ready'.
2026-03-09 18:35:56 +02:00

127 lines
3.2 KiB
Batchfile

@echo off
REM Laravel Docker Development Template - Quick Setup (Windows)
REM Everything is pre-installed! This just starts Docker and sets up the database.
REM Usage: setup.bat [mysql|pgsql|sqlite]
setlocal enabledelayedexpansion
set DB=%1
if "%DB%"=="" set DB=mysql
REM Validate database choice
if not "%DB%"=="mysql" if not "%DB%"=="pgsql" if not "%DB%"=="sqlite" (
echo Error: Invalid database '%DB%'
echo Usage: setup.bat [mysql^|pgsql^|sqlite]
echo Example: setup.bat mysql
exit /b 1
)
echo ========================================================
echo Laravel Docker Development Template
echo Quick Setup - Everything Pre-Installed!
echo ========================================================
echo.
echo Setting up with %DB%...
echo.
REM Step 1: Configure environment
echo Configuring environment...
if exist "src\.env.%DB%" (
copy /y "src\.env.%DB%" "src\.env" >nul
echo Environment configured for %DB%
) else (
echo ERROR: Template file src\.env.%DB% not found
exit /b 1
)
REM Step 2: Build containers
echo Building Docker containers...
docker-compose build
echo Containers built
echo.
REM Step 3: Start containers
echo Starting Docker containers...
docker-compose --profile %DB% up -d
echo Containers started
echo.
REM Step 4: Install composer dependencies
echo Installing composer dependencies...
docker-compose exec app composer install --no-interaction
echo Dependencies installed
echo.
REM Step 5: Wait for database
if "%DB%"=="mysql" (
echo Waiting for database...
timeout /t 5 /nobreak >nul
echo Database ready
echo.
)
if "%DB%"=="pgsql" (
echo Waiting for database...
timeout /t 5 /nobreak >nul
echo Database ready
echo.
)
REM Step 6: Generate app key
echo Generating application key...
docker-compose exec app php artisan key:generate --force
echo App key generated
echo.
REM Step 7: Run migrations
echo Running database migrations...
docker-compose exec app php artisan migrate --force
echo Migrations completed
echo.
REM Step 8: Seed database
echo Seeding database (roles, permissions, admin user)...
docker-compose exec app php artisan db:seed --force
echo Database seeded
echo.
REM Step 9: Create storage link
echo Creating storage symlink...
docker-compose exec app php artisan storage:link
echo Storage linked
echo.
REM Done
echo.
echo ========================================================
echo Setup Complete!
echo ========================================================
echo.
echo Your Laravel application is ready!
echo.
echo Laravel App: http://localhost:8080
echo Admin Panel: http://localhost:8080/admin
echo Mailpit: http://localhost:8025
echo.
echo Admin Login:
echo Email: admin@example.com
echo Password: password
echo.
echo What's Included:
echo - Laravel 11 with Breeze authentication
echo - Filament admin panel with user management
echo - Pest testing framework
echo - Laravel Pint code style
echo - Queue workers ^& scheduler (optional profiles)
echo.
echo Common Commands:
echo docker-compose exec app php artisan [command]
echo docker-compose exec app composer [command]
echo docker-compose exec app ./vendor/bin/pest
echo docker-compose logs -f app
echo.
echo Stop containers:
echo docker-compose down
echo.
endlocal