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%" (
|
if exist "src\.env.%DB%" (
|
||||||
copy /y "src\.env.%DB%" "src\.env" >nul
|
copy /y "src\.env.%DB%" "src\.env" >nul
|
||||||
|
|
||||||
REM Append port configurations to .env
|
REM Append port configurations to .env (for reference only, not used by Laravel)
|
||||||
echo APP_PORT=%APP_PORT% >> src\.env
|
REM Note: DB_PORT is NOT appended - Laravel uses internal Docker port (3306/5432)
|
||||||
echo MAIL_DASHBOARD_PORT=%MAIL_DASHBOARD_PORT% >> src\.env
|
REM These are for docker-compose external port mapping only
|
||||||
echo MAIL_PORT=%MAIL_PORT% >> src\.env
|
echo. >> src\.env
|
||||||
echo REDIS_PORT=%REDIS_PORT% >> src\.env
|
echo # Port Configuration ^(auto-assigned by setup^) >> src\.env
|
||||||
if defined DB_PORT echo DB_PORT=%DB_PORT% >> 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%
|
echo Environment configured for %DB%
|
||||||
) else (
|
) else (
|
||||||
|
|||||||
15
setup.sh
15
setup.sh
@@ -106,12 +106,15 @@ echo -e "${YELLOW}→ Configuring environment...${NC}"
|
|||||||
if [ -f "src/.env.${DB}" ]; then
|
if [ -f "src/.env.${DB}" ]; then
|
||||||
cp "src/.env.${DB}" "src/.env"
|
cp "src/.env.${DB}" "src/.env"
|
||||||
|
|
||||||
# Append port configurations to .env
|
# Append port configurations to .env (for reference only, not used by Laravel)
|
||||||
echo "APP_PORT=$APP_PORT" >> src/.env
|
# Note: DB_PORT is NOT appended - Laravel uses internal Docker port (3306/5432)
|
||||||
echo "MAIL_DASHBOARD_PORT=$MAIL_DASHBOARD_PORT" >> src/.env
|
# These are for docker-compose external port mapping only
|
||||||
echo "MAIL_PORT=$MAIL_PORT" >> src/.env
|
echo "" >> src/.env
|
||||||
echo "REDIS_PORT=$REDIS_PORT" >> src/.env
|
echo "# Port Configuration (auto-assigned by setup)" >> src/.env
|
||||||
[ -n "$DB_PORT" ] && echo "DB_PORT=$DB_PORT" >> 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}"
|
echo -e "${GREEN}✓ Environment configured for ${DB}${NC}"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user