Skip to the main content
{}
Back to all articles

Technical article

Deploying Laravel 13 on shared hosting

A practical deployment approach for Laravel 13 and PHP 8.5 on shared hosting, with managed-runtime steps only where workers are actually available.

By Codegenie3 minute read
  • Deployment & operations
  • Deploying
  • Laravel
  • shared
  • hosting
Release process with successive steps and a validation marker.
In this article

On shared hosting, prebuild the release when Composer or Node are unavailable on the server. Only the public directory should be web-accessible. Configuration, vendor, logs and backups belong outside the document root.

Check PHP, extensions, document root, writable paths, mail, cache, sessions and execution limits before release. Without shell access, use a controlled artifact; normal user flows must not require Composer, Node or a permanent worker.

  • Build from lockfiles and never include production secrets in a public artifact.
  • Validate cache and configuration through the permitted release process; do not blindly overwrite runtime data.
  • After release test a read route and the relevant user journey, not just /up.

A Laravel 13 release on shared hosting starts with the hosting capabilities: supported PHP and extensions, a safe public document root, writable runtime paths and an allowed deployment procedure. Prepare dependencies and frontend assets before upload if the destination has no build or command tools. PHP 8.5 is one possible compatible runtime, not Laravel 13’s minimum requirement.

Keep build tools outside normal requests

The deployed application must serve its agreed flows without running Composer or Node during a visitor request. If the host provides no permanent workers, do not queue a critical action and leave it unprocessed. Longer work may need a different design or hosting rather than being forced into a request timeout.

  • Build frontend assets and install locked production dependencies in a suitable release environment.
  • Keep .env, vendor, logs and backups outside the public document root.
  • Preserve runtime data and secrets during upload.
  • Generate deployment caches through the permitted procedure and verify the actual destination configuration.

Separate the public directory from the application

These two existing illustrative fragments show a public_html entry point and a Laravel application in its sibling laravel-app directory. They are not a complete replacement bootstrap. Keep the installed Laravel entry point’s maintenance handling and any project-specific routing; verify absolute paths and public asset paths on your own host.

Use public_html only as the front controllerpublic/index.phpphp
<?php

use Illuminate\Foundation\Application;
use Illuminate\Http\Request;

define('LARAVEL_START', microtime(true));

$laravelRoot = dirname(__DIR__).'/laravel-app';

require $laravelRoot.'/vendor/autoload.php';

/** @var Application $app */
$app = require_once $laravelRoot.'/bootstrap/app.php';
$app->handleRequest(Request::capture());
Point Laravel to the real public directorybootstrap/app.phpphp
$app = Application::configure(basePath: dirname(__DIR__))
    ->withRouting(web: __DIR__.'/../routes/web.php')
    ->create();

$publicPath = dirname(__DIR__).'/../public_html';

if (is_dir($publicPath)) {
    $app->usePublicPath($publicPath);
}

return $app;

Make database changes and rollback compatible

Review every migration separately from file upload. Prefer an expand/contract transition when old and new code must coexist. Preserve a known working release and a tested backup. Restoring old files does not reverse destructive schema changes or preserve writes made after the change. Define when to stop and who approves recovery.

Use managed workers only where provided

A managed runtime may support workers for exports, imports or notifications. Provision, restart and monitor them explicitly, including retries and duplicate processing. Do not copy worker commands into a shared-hosting procedure that cannot run them.

Accept the release with a real flow

  • Confirm dependencies, PHP extensions, writable storage and available backup.
  • Inspect public paths and verify no private files were exposed.
  • Check a read route, assets and a safe instance of the relevant form or application flow.
  • Review failures and recovery before marking the release accepted.

The PHP fragments illustrate layout decisions for a Laravel application, not the implementation of this static Astro website. No hosting publication or Laravel end-to-end deployment was executed for this article.

Last updated:

Need technical context for your own project?

Codegenie helps with Laravel applications, existing codebases, shared-hosting deployments and technical improvements.