Laravel reverb on production server to local development server

Updated: Feb 12, 2025

Laravel reverb on production server to local development server

To set up Laravel reverb (or any other development tool) on a production server and a local development server, you'll need to follow these steps:

  1. Install Laravel and Laravel reverb on both servers:

    • Install Laravel using Composer on both servers by running the command composer create --prefer-dist laravel/laravel <project-name>.
    • Install Laravel reverb using Composer on both servers by running the command composer require laravel/reverb.
  2. Configure Laravel on both servers:

    • Set up the environment variables for both servers by creating a .env file in the root directory of your Laravel project and adding the necessary variables. For example, you'll need to set the DB_DATABASE, DB_USERNAME, and DB_PASSWORD variables to match your production and development databases.
    • Set up the .env.production and .env.local files to separate configuration values for production and development environments.
    • Run the Laravel installation command php artisan install on both servers.
  3. Configure Laravel reverb on both servers:

    • Run the Laravel reverb installation command php artisan reverb:install on both servers.
    • Configure the reverb.php file in the config directory of your Laravel project to match your development and production environments. For example, you may want to set different cache and session drivers for development and production.
  4. Set up SSH access between the servers:

    • Configure SSH access from your local development server to your production server. This will allow you to run commands on the production server from your local development environment.
  5. Use Laravel reverb to sync your development and production environments:

    • Run the command php artisan reverb:sync on your local development server to sync your development environment with your production environment. This will update your production database schema and files with the latest changes from your development environment.
    • Run the command php artisan reverb:deploy on your production server to deploy the latest code changes from your development environment.

By following these steps, you should be able to set up Laravel reverb on both your production server and local development server, and use it to sync and deploy changes between the two environments. It's important to note that using Laravel reverb for production deployments is not recommended for large applications or mission-critical systems, as it may introduce additional complexity and potential for errors. For these cases, it's recommended to use a dedicated deployment tool or service.