Fix MySQL connection and DatabaseSeeder BOM issues
Two critical fixes: 1. DB_PORT was being appended to Laravel .env file - Setup script was writing DB_PORT=3307 (external port) - Laravel needs internal Docker port (3306) - Now ports are commented out in .env (reference only) - Docker-compose uses env vars, Laravel uses fixed internal ports 2. DatabaseSeeder.php had UTF-8 BOM (Byte Order Mark) - Caused 'Namespace declaration must be first statement' error - Removed invisible BOM bytes from file These fixes ensure: - MySQL connections work from within Docker network - Database seeding completes successfully - Fresh setup works end-to-end
This commit is contained in:
15
setup.bat
15
setup.bat
@@ -114,12 +114,15 @@ echo Configuring environment...
|
||||
if exist "src\.env.%DB%" (
|
||||
copy /y "src\.env.%DB%" "src\.env" >nul
|
||||
|
||||
REM Append port configurations to .env
|
||||
echo APP_PORT=%APP_PORT% >> src\.env
|
||||
echo MAIL_DASHBOARD_PORT=%MAIL_DASHBOARD_PORT% >> src\.env
|
||||
echo MAIL_PORT=%MAIL_PORT% >> src\.env
|
||||
echo REDIS_PORT=%REDIS_PORT% >> src\.env
|
||||
if defined DB_PORT echo DB_PORT=%DB_PORT% >> src\.env
|
||||
REM Append port configurations to .env (for reference only, not used by Laravel)
|
||||
REM Note: DB_PORT is NOT appended - Laravel uses internal Docker port (3306/5432)
|
||||
REM These are for docker-compose external port mapping only
|
||||
echo. >> src\.env
|
||||
echo # Port Configuration ^(auto-assigned by setup^) >> src\.env
|
||||
echo # APP_PORT=%APP_PORT% >> src\.env
|
||||
echo # MAIL_DASHBOARD_PORT=%MAIL_DASHBOARD_PORT% >> src\.env
|
||||
echo # MAIL_PORT=%MAIL_PORT% >> src\.env
|
||||
echo # REDIS_PORT=%REDIS_PORT% >> src\.env
|
||||
|
||||
echo Environment configured for %DB%
|
||||
) else (
|
||||
|
||||
15
setup.sh
15
setup.sh
@@ -106,12 +106,15 @@ echo -e "${YELLOW}→ Configuring environment...${NC}"
|
||||
if [ -f "src/.env.${DB}" ]; then
|
||||
cp "src/.env.${DB}" "src/.env"
|
||||
|
||||
# Append port configurations to .env
|
||||
echo "APP_PORT=$APP_PORT" >> src/.env
|
||||
echo "MAIL_DASHBOARD_PORT=$MAIL_DASHBOARD_PORT" >> src/.env
|
||||
echo "MAIL_PORT=$MAIL_PORT" >> src/.env
|
||||
echo "REDIS_PORT=$REDIS_PORT" >> src/.env
|
||||
[ -n "$DB_PORT" ] && echo "DB_PORT=$DB_PORT" >> src/.env
|
||||
# Append port configurations to .env (for reference only, not used by Laravel)
|
||||
# Note: DB_PORT is NOT appended - Laravel uses internal Docker port (3306/5432)
|
||||
# These are for docker-compose external port mapping only
|
||||
echo "" >> src/.env
|
||||
echo "# Port Configuration (auto-assigned by setup)" >> src/.env
|
||||
echo "# APP_PORT=$APP_PORT" >> src/.env
|
||||
echo "# MAIL_DASHBOARD_PORT=$MAIL_DASHBOARD_PORT" >> src/.env
|
||||
echo "# MAIL_PORT=$MAIL_PORT" >> src/.env
|
||||
echo "# REDIS_PORT=$REDIS_PORT" >> src/.env
|
||||
|
||||
echo -e "${GREEN}✓ Environment configured for ${DB}${NC}"
|
||||
else
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user