Deploying Laravel Applications

2 min read Updated 4 days ago

Laravel on Ploi Cloud

Ploi Cloud is optimized for Laravel applications, providing automatic configuration and best practices out of the box.

Automatic Configuration

When you create a Laravel application, Ploi Cloud automatically:

  • Sets up the correct PHP version and extensions

  • Installs your Composer dependencies

  • Runs database migrations during deployment

  • Generates a secure APP_KEY for encryption

  • Configures Laravel scheduler (when enabled)

Environment Secrets

Essential environment variables for Laravel applications:

  APP_ENV=production
  APP_DEBUG=

Database connection variables are automatically injected when you add a database service.

Database Migrations

Migrations run automatically as init container commands during deployment:

  • The default command is php artisan migrate --force

  • Migrations run before your application starts

  • If migrations fail, the deployment stops to prevent issues

Queue Workers

To process Laravel queues, add a Worker service:

  1. Navigate to your application's Services section

  2. Click "Add service" and select "Worker"

  3. Enter a descriptive name (e.g., "queue-worker")

  4. Set the command to php artisan queue:work --sleep=3 --tries=3

  5. Deploy your application to start the worker

Workers use the same code and storage as your main application.

Laravel Scheduler

The Laravel scheduler runs your scheduled tasks automatically:

  1. Go to your application's Settings tab

  2. Find the "Laravel scheduler" section

  3. Toggle "Enable scheduler" to activate it

  4. Deploy your application to apply the change

The scheduler executes php artisan schedule:run every minute.

Build Commands

Default build commands for Laravel applications:

  • composer install --no-interaction --optimize-autoloader --no-dev

  • If you enable frontend builds: npm ci and npm run build

You can customize these in the Build Configuration section.