Deploying a PHP application (Composer, Laravel and frameworks)

How to deploy a Composer-based PHP app such as Laravel or Symfony on shared hosting: building locally, keeping code outside public_html and environment files.

How-to guideAdvanced2 min readUpdated

Frameworks like Laravel expect only their public/ folder to be web-accessible. On Traxio, public_html is the web root, so you place the application outside it and put only the public files inside.

1. Prepare the build locally

composer install --no-dev --optimize-autoloader
npm ci && npm run build   # if the app has front-end assets

This creates the vendor/ folder and compiled assets you’ll upload. Building locally keeps the deployment predictable and avoids using your account’s shared resources for the build. If you prefer to work on the server, you can connect with SSH. How to connect to your hosting with SSH

2. Upload the app outside the web root

Upload everything except the public folder’s contents to a folder in your home directory:

/home/USERNAME/apps/myapp/          ← app, vendor, config, storage, .env
/home/USERNAME/domains/yourdomain.co.uk/public_html/  ← contents of public/

Zip, upload and extract to save time. How to upload and extract a zip file

3. Point index.php at the app

Edit public_html/index.php so its paths reach the app folder. In Laravel:

require __DIR__.'/../../../apps/myapp/vendor/autoload.php';
$app = require_once __DIR__.'/../../../apps/myapp/bootstrap/app.php';

Count the ../ from public_html up to your home folder and adjust to your paths.

4. Configure the environment

Create .env in the app folder with production settings:

APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.co.uk
DB_HOST=localhost
DB_DATABASE=acme_myapp
DB_USERNAME=acme_myapp
DB_PASSWORD="your-password"

Storing configuration and secrets outside public_html

5. Database and migrations

Create the database (How to create a MySQL database in DirectAdmin). Without shell access, run migrations locally against an exported copy and import the result, or use your framework’s schema dump and import it through phpMyAdmin.

6. Writable folders

Make sure storage/ and bootstrap/cache/ are writable by the app (755 folders). File permissions explained (644, 755 and why never 777)

7. PHP version and scheduler

Match the domain’s PHP version to the app’s requirements (How to change the PHP version in DirectAdmin), and run the framework’s scheduler with a cron job. Running PHP scripts from cron: paths, output and common mistakes

Updating

Build locally, upload changed files (or a new release folder and swap), clear framework caches by deleting the cached config files in bootstrap/cache/.

Traxio accounts include SSH, Git, cron and PHP 7.4 to 8.3. Try the PHP hosting is free for 30 days with no card, then £0.99 a month.

Popular

Tip: press / to search from any pageSee all results