On this page

PHP

Guara Cloud fully supports PHP applications, including frameworks like Laravel, Symfony, and plain PHP projects running with Apache or Nginx.

Supported versions

The following PHP versions are auto-detected:

  • PHP 8.1
  • PHP 8.2
  • PHP 8.3

The version is auto-detected from the require.php field in your composer.json.

{
  "require": {
    "php": ">=8.3"
  }
}

Deploy with Dockerfile

For full control over your build, provide a Dockerfile in the root of your repository. PHP applications typically use Apache or Nginx + FPM as a process manager.

FROM php:8.3-apache

WORKDIR /var/www/html

RUN a2enmod rewrite

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader

COPY . .

RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf

EXPOSE 3000

ENV PORT=3000

CMD ["apache2-foreground"]

Deploy with Buildpack

If your repository does not contain a Dockerfile, Guara Cloud automatically detects your PHP project by the presence of a composer.json or index.php file.

The auto-detection will:

  1. Detect the PHP version from composer.json
  2. Run composer install automatically
  3. Detect Laravel projects with first-class support (artisan caching, FrankenPHP + Caddy)
  4. Configure Caddy as the web server automatically
  5. Start the application

Port configuration

Your PHP application does not read the port directly in code — the web server (Apache or Nginx) must be configured to listen on the port configured in your service settings. The default is 3000, but you can change it at any time.

For Apache, update your virtual host or use the $PORT variable in configuration:

Listen ${PORT}

<VirtualHost *:${PORT}>
    DocumentRoot /var/www/html/public
</VirtualHost>

For Nginx, update your server block:

server {
    listen ${PORT};
    root /app/public;
    index index.php;
}

Example project structure

my-php-app/
  composer.json
  composer.lock
  public/
    index.php
  src/
    Controllers/
    Models/
  Dockerfile          # optional — omit to use Buildpack

Environment variables

These environment variables are commonly used with PHP deployments:

VariableRecommended valueDescription
APP_ENVproductionSets the application environment (Laravel/Symfony)
PORTSet by platformThe port your web server must listen on
APP_KEYYour keyRequired by Laravel for encryption
APP_DEBUGfalseDisables debug mode in production

Common pitfalls