Skip to content

Laravel

A Laravel application is a PHP application with Laravel’s defaults. Create a Laravel server first, then add an application to it.

  • A database, always created with the application: MySQL (MariaDB), MySQL 8 or PostgreSQL, whichever you chose in the Database step when you created the server. The engine can’t be changed later. Its name, user and password are shown under Database › Databases. See PostgreSQL databases.
  • The public folder as the web root. Visitors never see the rest of the project.
  • Composer on the server, for builds and for the application’s SSH shell.
  • Laravel’s scheduler, run every minute for you once the project is in place. You don’t need to add a cron job for php artisan schedule:run.
  • Nginx only as the web server, so .htaccess files are ignored.
  • A queue worker you can turn on once the application is deployed from Git. See Queue worker.

Git deploy is the easiest way to run Laravel. Open Deployments and connect your repository. The Laravel preset fills in:

  • Build commands: composer install --no-dev --optimize-autoloader --no-interaction
  • Shared paths: .env and storage, kept between releases
  • Publish directory: public. A Laravel application always publishes a folder of its repository, so this can’t be left empty.
  • Before and after each deploy: Cache config, routes and views before the switch is on. Run php artisan migrate --force before the switch is off; tick it if you want migrations to run on every deploy.

Migrations run before the application switches to the new release: if they fail, the application stays on the release it was on. The caches are built in the new release before the switch: if that fails, the application stays on the release it was on.

Before migrations run, Netkeel copies the database. If a deploy fails partway through its migrations, or a release turns out to need the old schema, open Database › Database restores and click Restore database on that copy to put it back. Rolling back a release doesn’t undo migrations. See Restore the database.

If your app builds front-end assets, add npm ci and npm run build to the build commands. Node.js is available to the build when a build command uses npm, npx or node.

Once the project is deployed, the scheduler runs from the live release. Laravel › Scheduler shows its last run, its result and its recent output.

Set your .env values under Laravel › Environment (.env). They apply when you save: with Cache config, routes and views before the switch on, saving rebuilds Laravel’s configuration cache.

  • APP_KEY: Laravel needs one. If the application’s shared/.env has none when you deploy, Netkeel generates one before the deploy, the way php artisan key:generate does, and the deployment shows APP_KEY generated. The key’s value is never shown or logged. You can also set your own: create it on your computer with php artisan key:generate --show and add it here. An APP_KEY already in shared/.env (generated, made over SSH or carried over from your files) is kept: saving the list changes only the variables listed.
  • Database settings: if you don’t set any DB_* values (or DATABASE_URL) yourself, Netkeel adds the application’s own database to shared/.env for you. For PostgreSQL that is DB_CONNECTION=pgsql with DB_HOST=/var/run/postgresql. If you set them yourself for MySQL, use localhost as the host with DB_SOCKET=/run/mysqld/mysqld.sock, not 127.0.0.1.

If you change the database user’s password under Database › Databases, update DB_PASSWORD under Laravel › Environment (.env) too: Netkeel doesn’t change the settings it added afterwards.

If a deploy fails, see Troubleshooting.

Once the application is deployed from Git, Laravel › Queue worker runs php artisan queue:work from the live release. It is off until the Owner or a Super admin clicks Turn on.

  • Connection: a connection from config/queue.php, such as database or redis. Leave it empty to use QUEUE_CONNECTION from .env.
  • Queues: comma-separated, highest priority first, such as high,default.
  • Tries: 1 to 25, how often a failing job is tried before it goes to failed_jobs.

The worker restarts after every deploy, rollback and environment change, restarts itself every hour and stops while the application is turned off. The page shows its status and recent log.

If the worker keeps stopping, for example because of a wrong database setting in the environment variables or a missing table, you get a Queue worker stopping alert, and queued jobs wait until it runs again. Its recent log on the Deployments page shows why. Fix the cause, then save the queue worker settings to start it again. The alert is emailed with the Failed operations switch. See Notifications and activity.

You can also upload the whole project into htdocs with SFTP or the file manager. The public folder inside it is served, and the scheduler starts once the project’s artisan file is there. The queue worker needs Git deploy.

Staging, cloning, moving to another server and import and export are WordPress-only for now. Backups work as for every application. To bring a site from another host, see Move a site to Netkeel.