Deploy

View saved

Goal

This snapshot advances Marlowe Gazette by teaching you to deploy Marlowe Gazette with Railway MySQL and production settings.

Every numbered folder is complete and independently runnable, so you can inspect this stage without rebuilding earlier lessons.

Prerequisites

Use PHP 8.2 or newer, Composer, Docker, and a terminal. Basic PHP, HTML, and SQL familiarity will help.

The Laravel development server uses port 8000. Root Docker Compose exposes MySQL 8 on port 3307 and each snapshot has a separate database.

  • PHP and Composer
  • Docker
  • A code editor and terminal

Concepts

Production separates code from secrets, uses Railway's assigned PORT, runs forced migrations before start, disables debug output, and checks health.

Laravel keeps HTTP routes, controllers, Eloquent models, validation, authorization, and Blade presentation in explicit layers.

Walkthrough

Connect the final snapshot to Railway MySQL, map database variables, set APP_KEY and APP_URL, configure persistent media, and verify auth and reset flows.

Inspect the matching snapshot around the example. The repository includes validation, errors, CSRF protection, and the surrounding application structure.

php artisan migrate --force
php artisan serve --host=0.0.0.0 --port=${PORT:-8000}

Run and verify

Start MySQL from the repository root, enter 12-Deploy, install dependencies, copy the environment file, generate an application key, migrate, seed, and serve.

Open http://localhost:8000. From data lessons onward, Ada and Grace are deterministic accounts with password password123.

docker compose up -d
git clone https://github.com/michaeldunga1/fcc-laravel-blog.git
cd fcc-laravel-blog/12-Deploy
composer install
cp .env.example .env
php artisan key:generate
php artisan migrate --seed
php artisan storage:link
php artisan serve --host=0.0.0.0 --port=8000

Troubleshooting

A build that succeeds but fails health checks usually has a missing APP_KEY, incorrect DB mapping, migration failure, or wrong start port.

If MySQL fails, verify Docker is healthy, port 3307 is free, and this snapshot's DB_DATABASE matches its unique marlowe_XX database.

  • Read the first exception
  • Clear cached config after environment changes
  • Never commit .env, vendor, or node_modules

Try this

Deploy, open /health, sign in as a seeded user, publish a story, and complete a reset.

Exercise both a successful request and a validation or authorization failure before moving to the next snapshot.

  • Make one focused change
  • Test it in the browser
  • Compare the next snapshot after it works

Comments

One comment per signed-in account. Comments are saved with this page’s URL.