Skip to content
Docs

PHP

Run PHP two ways. A PHP site keeps its files like a classic host, with .htaccess. A PHP app from GitHub is built fresh on every deploy, Symfony included.

Updated 17 Oct 20263 min read

PHP runs on Tanzahost in two ways. Pick the one that fits how your code changes:

WhatA PHP siteA PHP app
Add it withAdd a service, then PHP siteAdd a service, then App
Its filesKept, and changed in place: by the site itself, the file manager or a ZIPRebuilt from GitHub or a ZIP on every deploy
Good forClassic PHP sites, sites moved from cPanelSymfony, Laravel and any PHP with Composer
.htaccessWorks as you expectNot used

Both choose from the same PHP versions, extensions and settings.

PHP versions

VersionNotes
PHP 8.5Supported
PHP 8.4What new sites and apps get when they don't ask
PHP 8.3Supported
PHP 8.2Supported
PHP 8.1No more security fixes from its makers: a warning, and builds move to a supported version after 2027-12-31
PHP 8.0The same as 8.1

PHP 7.4 isn't offered for new sites or apps.

A PHP site

  1. Open your project, choose Add a service, then PHP site.

  2. Give it a name and choose its PHP version. You can change it later on the site's page: the site restarts on the new version with no downtime, and its files stay.

  3. Under Start with, choose An empty site, or A ZIP file.

  4. Choose Create site.

From a cPanel backup, the ZIP's top public_html folder becomes the site, and the rest of the ZIP is kept aside in a from-zip folder for you to look at. Later, Replace the files with a ZIP on the site's page does the same again; the files it replaces stay in the trash for 7 days.

Edit any file in the file manager, and run scripts on a timetable with scheduled tasks, like cPanel's cron jobs:

Terminal
php scripts/report.php

A PHP app from code

We see PHP when the code has composer.json, index.php or public/index.php. With composer.json, we run:

Terminal
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader --no-progress

We recognise Laravel and Symfony. The site is served from public/ when your code has one, from web/ when it has web/index.php, and otherwise from the top folder. If package.json has a build script, we install Node.js and build your assets too. For Laravel, follow Deploy a Laravel app.

The version comes from require.php in composer.json: we pick the newest supported version that meets it, so "php": ">=8.2" builds with 8.5. To pin one, choose it in Build and run, or in tanzahost.json.

Extensions

Every PHP already has the common extensions, like ctype, curl, dom, fileinfo, mbstring, openssl, pdo, pdo_sqlite, session, sodium and xml. You can add these:

bcmath, bz2, calendar, exif, gd, gmp, imagick, intl, mysqli, opcache, pcntl, pdo_mysql, pdo_pgsql, pgsql, redis, soap, sockets, xsl, zip.

A PHP app gets the ones its composer.json requires ("ext-gd": "*") by itself. Tick others under PHP extensions in Build and run, or on a site's PHP settings.

PHP settings

Like cPanel's INI editor, from an allowed list:

SettingAllowed
upload_max_filesize, post_max_sizeUp to 2G
memory_limitUp to the app's memory limit
max_execution_time, max_input_timeUp to 600 seconds
max_input_varsUp to 100,000
display_errors, opcache.enableOn or Off
date.timezoneA time zone, like Europe/London or UTC
session.gc_maxlifetimeUp to 30 days, in seconds

Others are refused, so nothing can switch off what keeps your app safe. On a site, saving restarts it with no downtime and your files stay as they are. On an app, they're added when it next builds.

Example: Asha's old order form

Before duka moved to Laravel, Asha had a small order form in plain PHP on her old cPanel host. She downloads its backup, adds a PHP site named orders with PHP 8.4, and chooses A ZIP file. Its public_html becomes the site, and her .htaccess rewrites work as before. In PHP settings she raises the largest upload to 20M for her product photos.