What I built: Using Railway for a Multi-Client Laravel App

alanmcginnis
PROOP

2 months ago

Railway community! I recently rebuilt a legacy portal using Laravel, Inertia, and Vue, and needed a deployment solution that could handle a specific challenge.

The Problem

I needed to serve two clients (a company and its subsidiary) using a single codebase while maintaining separate data. Both required their own production and staging environments, but I wanted parity and an easy way to keep all environments in sync.

What Worked Well

  1. Environment Management: Railway's environment variables made it simple to configure the same app differently for each client without code duplication. Variable references were clutch.

  2. Database Proxy System: Railway's proxy connections allowed me to create a custom script for targeting specific environments. This meant I could perform maintenance on any environment without needing to change configurations or link to a different Railway CLI project.

php railway-db-connect.php --env=client1_staging migrate

  1. Redis Integration: Using Railway's Redis service worked well for session management across environments; however, I encountered challenges implementing proper cache clearing for Laravel's tagged caches. Everything is ironed out now

  2. Automated Deployments: The GitHub integration ensured all environments stayed in sync with each deployment, maintaining parity between clients.

  3. Railway CLI: - Overall, the CLI is a champ. I struggled with some Laravel specifics and ultimately resorted to scripting my way around them to move forward with my project - see #2

  4. Bonus: It was easy to navigate between services, thanks to domain and variable references being readily available, which saved me many logins to my password manager.

The Outcome

The setup now runs smoothly across multiple environments with a single codebase. The ability to maintain separate client data while keeping application features in sync has been the key benefit of using Railway.

Railway made it extremely easy for me to solo this project, and it was less complicated and more affordable than other products, such as DigitalOcean.

The screenshots are only a tiny glimpse of the transformation.

Cheers, have fun building,

Alan

0 Replies

Loading...
What I built: Using Railway for a Multi-Client Laravel App - Railway Help Station