# How to Deploy a PHP App Without Manual Setup in 2026

> Deploy your PHP app from GitHub in 2026 with Composer, secure env vars, MySQL or PostgreSQL, HTTPS, logs, troubleshooting, and Kuberns agentic AI today.
- **Author**: parth-kanpariya
- **Published**: 2026-04-20
- **Modified**: 2026-09-18
- **Category**: Deployment Guides
- **URL**: https://kuberns.com/blogs/deploy-php-app/

---

The easiest way to deploy a PHP app is to connect its GitHub repository to Kuberns, provide the required secure environment variables and start the deployment. Kuberns agentic AI analyses the repository and prepares the application deployment configuration, removing the need to configure Apache, Nginx, PHP-FPM, SSL or a deployment pipeline manually.

This guide shows how to prepare and deploy a plain PHP or Composer-based application, connect MySQL or PostgreSQL, compare PHP deployment platforms and resolve the errors that commonly appear after a project leaves localhost.

## TL;DR

To deploy a PHP app on Kuberns:

1. Push the completed PHP project to GitHub.
2. Confirm the PHP version, required extensions, public directory and Composer files.
3. Connect the repository to Kuberns.
4. Review the deployment configuration prepared by agentic AI.
5. Provide the required secure environment variables.
6. Deploy the application and verify its routes, database connection, HTTPS and logs.

Kuberns is the best fit for developers who want a GitHub-to-production workflow without maintaining a server or writing the infrastructure configuration themselves.

## Prepare Your PHP App for Deployment

A deployable PHP project needs a clear entry point, reproducible dependencies and configuration that can be supplied outside the repository. Review these items before connecting the project to Kuberns.

### Confirm the public entry point

Plain PHP applications commonly use `index.php` in the repository root or inside a `public/` directory. Framework applications normally use a public front controller such as `public/index.php`.

```text
my-php-app/
├── public/
│   └── index.php
├── src/
├── composer.json
├── composer.lock
└── .env.example
```

The public document root must expose application assets and the front controller without exposing source files, local environment files or private configuration.

### Declare the PHP version and extensions

Composer can document both the PHP version and the extensions required by the application:

```json
{
  "require": {
    "php": "^8.2",
    "ext-pdo": "*",
    "ext-pdo_mysql": "*",
    "vlucas/phpdotenv": "^5.6"
  },
  "autoload": {
    "psr-4": {
      "App\\": "src/"
    }
  }
}
```

Commit both `composer.json` and `composer.lock`. Composer recommends committing the lockfile for applications so development, CI and production install consistent dependency versions. Do not commit the generated `vendor/` directory unless the project has an unusual requirement that makes this necessary. See the official <a href="https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies" target="_blank" rel="noopener noreferrer">Composer dependency installation guidance</a>.

### Keep production secrets outside Git

Use environment variables for database credentials, signing secrets and private API keys. Commit an `.env.example` file containing variable names and safe placeholder values, but never commit a populated production `.env` file.

```php
<?php
$host = $_ENV['DB_HOST'] ?? getenv('DB_HOST');
$name = $_ENV['DB_NAME'] ?? getenv('DB_NAME');
$user = $_ENV['DB_USER'] ?? getenv('DB_USER');
$pass = $_ENV['DB_PASSWORD'] ?? getenv('DB_PASSWORD');
```

The developer provides the required secure values during deployment. The application should validate required variables at startup and fail with a useful log message when a value is missing.

### Push the finished project to GitHub

Make sure the intended production branch contains the application code, dependency manifests and any reviewed database migrations. Test the same commit you intend to deploy rather than making untracked production changes afterward.

## Deploy a PHP App the Easier Way

Kuberns turns the prepared GitHub repository into a running application without requiring the developer to configure the underlying PHP server manually.

### Step 1: Connect the GitHub repository

Sign in to Kuberns and start a new application deployment. Connect the GitHub account that owns the PHP project, authorize access to the required repository and select the branch intended for production.

![Connect a GitHub repository to Kuberns for PHP deployment](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/kuberns-registration.png)

Before continuing, confirm that the selected branch contains the exact release you want to deploy. It should include the application code, `composer.json`, `composer.lock`, database migrations and any safe configuration examples the deployment needs. Keep local-only files, populated `.env` files and production secrets out of the repository.

### Step 2: Review the PHP deployment configuration

Kuberns agentic AI analyses the connected repository and prepares the application deployment configuration. Review the detected PHP requirements, dependency installation, application entry point and public document root before deployment.

The repository should clearly express anything the application requires. PHP versions and extensions belong in `composer.json`, while framework-specific commands or background processes should be represented in the project configuration instead of being assumed. If the application serves requests through `public/index.php`, verify that the prepared document root reflects that structure.

Check these items before moving forward:

- PHP version constraint
- Required PHP extensions
- Composer dependency installation
- Public document root and front controller
- Application start behavior
- Framework-specific requirements

Correct a repository or configuration issue before deploying rather than compensating for it with an undocumented server change.

### Step 3: Provide secure environment variables

Add only the values required by the application. A database-backed PHP project may need:

![Provide secure PHP environment variables in Kuberns](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/environment-variable-kuberns.png)

- `APP_ENV`
- `APP_SECRET`
- `DB_HOST`
- `DB_PORT`
- `DB_NAME`
- `DB_USER`
- `DB_PASSWORD`

Use the same variable names expected by the code and keep development, staging and production values separate. Do not expose private credentials through client-side scripts, application responses or logs. If the PHP code expects `DB_PASSWORD`, adding a differently named value such as `DATABASE_PASSWORD` will not fix the connection unless the application supports both names.

Review every value before deployment, especially database hosts, callback URLs, allowed origins and application secrets. For a deeper workflow, see the guide to [managing environment variables in production](https://kuberns.com/blogs/environment-variables-in-production/).

### Step 4: Deploy the PHP application

Start the deployment and review the build output. Confirm that the required PHP version is available, Composer installs successfully and the application process starts without repeated failures.

![Review the PHP application deployment process in Kuberns](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/kuberns-ai-deploying.png)

The logs should show whether the repository was fetched successfully, dependency installation completed and the application reached its runtime stage. When a build fails, use the first relevant error rather than retrying unchanged configuration. A Composer platform-requirement error, for example, normally points to an incompatible PHP version or missing extension declared by a dependency.

Do not treat a completed build as proof that the application works. A successful deployment can still contain an incorrect document root, missing environment variable, failed database connection or broken route.

### Step 5: Verify the live application

Open the production URL and test the behavior users depend on:

![Verify the deployed PHP application from the Kuberns dashboard](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/deployed-dashboard.png)

- The homepage and application routes return the correct content.
- Static assets load without mixed-content or path errors.
- Login, forms, API requests and database writes work.
- HTTPS is active.
- Runtime logs contain no unexplained exceptions or restart loops.
- Error responses do not expose credentials, paths or stack traces.

This verification closes the gap between “the deployment completed” and “the PHP app is ready for users.”

If a check fails, review the build or runtime logs, correct the repository or environment configuration and deploy the corrected version. Avoid making an undocumented production-only change that cannot be reproduced from the repository.

## PHP Deployment Platform Comparison for 2026

PHP applications can run on several types of hosting, but the amount of manual setup differs significantly. This comparison focuses on the deployment workflow rather than temporary prices or promotional credits.

| Platform | PHP deployment workflow | Manual configuration | Composer workflow | Database connection | Best fit |
|---|---|---|---|---|---|
| [**Kuberns**](https://kuberns.com/) | Connect GitHub and deploy with agentic AI | Minimal developer configuration | Project dependencies prepared from the repository | Secure environment variables | PHP applications that need production deployment without manual DevOps |
| [**Heroku**](https://devcenter.heroku.com/articles/php-support) | Git-based PHP buildpack deployment | Application and process configuration may be required | Composer dependencies are installed by the PHP buildpack | Add-on or external database | Teams familiar with buildpack workflows |
| [**Render**](https://render.com/docs/deploy-php-laravel-docker) | Repository connected to a Docker-based web service | A Dockerfile and service settings are required for PHP | Defined inside the container build | Managed or external database | Teams comfortable maintaining a PHP container |
| [**Railway**](https://docs.railway.com/builds/railpack) | Repository deployment through Railpack or a Dockerfile | Automatic detection with optional overrides | Installed through the detected PHP build | Managed or external database | PHP services that fit an automated build workflow |
| [**DigitalOcean App Platform**](https://docs.digitalocean.com/products/app-platform/reference/buildpacks/php/) | Repository deployment through a PHP buildpack or Dockerfile | Build and runtime settings can be customized | Installed through the PHP buildpack | Managed database or external service | Teams already using DigitalOcean |
| **Shared hosting or cPanel** | Upload files or use a control-panel Git workflow | Application, document root and database setup | Availability varies by host | Commonly configured through the control panel | Basic PHP sites and conventional hosting workflows |
| **Self-managed VPS** | Install and operate the complete server stack | High | Installed and run by the operator | Self-managed or external database | Teams that need infrastructure-level control |

Managed platforms reduce server administration, while shared hosting and a VPS give the developer more responsibility for runtime configuration and maintenance. Kuberns is the strongest fit when the goal is to deploy a complete PHP application from GitHub without building and operating the deployment infrastructure.

## Deploy PHP With MySQL or PostgreSQL

Use PDO so the database connection remains portable and credentials stay outside the codebase.

```php
<?php

function getDatabaseConnection(): PDO
{
    $host = $_ENV['DB_HOST'] ?? getenv('DB_HOST');
    $port = $_ENV['DB_PORT'] ?? getenv('DB_PORT');
    $name = $_ENV['DB_NAME'] ?? getenv('DB_NAME');
    $user = $_ENV['DB_USER'] ?? getenv('DB_USER');
    $pass = $_ENV['DB_PASSWORD'] ?? getenv('DB_PASSWORD');

    $dsn = "mysql:host={$host};port={$port};dbname={$name};charset=utf8mb4";

    return new PDO($dsn, $user, $pass, [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_EMULATE_PREPARES => false,
    ]);
}
```

For PostgreSQL, use a PostgreSQL DSN:

```php
$dsn = "pgsql:host={$host};port={$port};dbname={$name}";
```

Before launch, confirm that the database accepts connections from the hosted application and that the selected credentials have only the permissions the application needs. Run migrations against a safe production-like database first, review destructive changes and verify backups before accepting important user data.

When a connection fails, check the host, port, database name, username, password, TLS requirements and network access before changing the PHP code. A local hostname such as `localhost` usually does not refer to an external production database after deployment.

## Why Kuberns Is the Best Way to Deploy a PHP App

![Kuberns homepage showing an Agentic AI platform for application deployment](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/kuberns-home-page-new.png)

[Kuberns](https://kuberns.com/) is an Agentic AI platform for deployment built for full-stack and complex backend projects. It gives PHP developers a direct workflow from a GitHub repository to a hosted application without requiring them to assemble a web server, CI/CD pipeline, certificate workflow, logging system and deployment dashboard separately.

Its agentic AI analyses the repository and prepares the application deployment configuration. The developer reviews that configuration and provides the secure environment variables required by the code. This division keeps application-specific decisions with the developer while removing repetitive infrastructure configuration from the deployment process.

Kuberns is especially useful when the PHP project includes Composer dependencies, private configuration, a relational database, API routes or a framework with a public front controller. Deployment output and runtime logs remain available in the same workflow, making it easier to diagnose a failed build, missing variable or broken route without managing a server over SSH.

## Common PHP Deployment Errors and Fixes

### The application returns a blank page or HTTP 500

Review the runtime logs first. Common causes include an uncaught exception, missing extension, failed autoloading, incorrect PHP version, unavailable environment variable or filesystem permission problem. Do not leave `display_errors` enabled in production because responses may expose sensitive implementation details.

### Composer installation fails

Commit `composer.lock` and confirm that it matches `composer.json`. Declare PHP and extension requirements explicitly. A package that needs GD, PDO, Intl or another extension should express that dependency through an `ext-*` Composer requirement.

### The deployed PHP version is incompatible

Use a clear Composer constraint such as `"php": "^8.2"` and make sure the application and its dependencies support that version. Avoid using an unnecessarily broad constraint when the project has only been tested against a narrower release range.

### The database connection is refused

Confirm the production host, port and credentials. Check whether the database requires TLS or an approved network source. Make sure the application is not trying to connect to a database available only on the developer's machine.

### Every route except the homepage returns 404

Verify the public document root and front controller. Framework and custom-router applications generally need requests routed through `public/index.php`. Also check that asset paths and base URLs do not assume the application is running from a local subdirectory.

### Uploaded files disappear after a deployment

Do not assume the application filesystem is permanent. Store user uploads in persistent object storage or another persistent service when the hosting environment can replace application instances during deployment.

### Can php -S -t public run the production app?

The command below is useful for checking a public document root locally:

```bash
php -S localhost:8000 -t public
```

It is not a production deployment method. The <a href="https://www.php.net/manual/en/features.commandline.webserver.php" target="_blank" rel="noopener noreferrer">PHP manual for the built-in web server</a> states that it is intended for development, testing and controlled demonstrations, not as a full-featured server on a public network.

## Deploy Your PHP App Without Manual Server Setup

Deploying a PHP application should not require every developer to become the operator of an Apache or Nginx server. A prepared repository, explicit Composer requirements and secure environment variables provide the application contract. Kuberns agentic AI then prepares the deployment configuration and gives the developer one workflow for deployment, HTTPS, logs and ongoing releases.

For plain PHP applications, Composer projects and database-backed services, Kuberns provides the clearest route from GitHub to production without manual server configuration.

[Deploy your PHP application with Kuberns](https://dashboard.kuberns.com)

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/CTA_banner.png" alt="Deploy your PHP application with Kuberns" style={{ width: "100%", height: "auto" }} />
</a>

## Frequently Asked Questions

### What is the easiest way to deploy a PHP app?

The easiest route is to connect the PHP application's GitHub repository to a managed deployment platform such as Kuberns, provide the required secure environment variables and deploy. Kuberns agentic AI prepares the deployment configuration so the developer does not have to configure a production server manually.

### How do I deploy a PHP app from GitHub?

Push the finished PHP project, `composer.json` and `composer.lock` to GitHub. Connect the repository to Kuberns, review the prepared PHP configuration, provide the application's secure environment variables, start the deployment and verify the live URL.

### Do I need Apache or Nginx to deploy PHP on Kuberns?

You do not need to install or configure Apache or Nginx manually when deploying through Kuberns. The platform prepares the web-serving configuration needed by the application as part of the deployment workflow.

### Do I need a Dockerfile to deploy a PHP app?

A standard PHP or Composer application does not need a Dockerfile for the Kuberns workflow described in this guide. A custom container may still be appropriate when the application needs a specialized operating-system package or runtime configuration.

### How do I deploy PHP with MySQL or PostgreSQL?

Provide the database host, port, name, user and password as secure environment variables. Build the correct PDO DSN for MySQL or PostgreSQL, confirm that the database accepts connections from the hosted application and run reviewed migrations before serving production traffic.

### How do I specify the PHP version and required extensions?

Declare the PHP version and required extensions in `composer.json`. For example, the `require` object can include a PHP constraint and packages such as `ext-pdo` or `ext-pdo_mysql`. Commit `composer.lock` so the deployment installs consistent dependency versions.

### Can I use php -S -t public in production?

No. PHP documents its built-in server as a development and controlled-testing tool, not a full production web server or a service for public networks. Use it to check the public document root locally, then deploy through a production hosting environment.

### Why does my PHP app return a 500 error after deployment?

Common causes include a missing PHP extension, incompatible PHP version, failed Composer installation, incorrect public directory, unavailable environment variable, database connection failure or filesystem permission problem. Review the build and runtime logs before changing code.

### Can I deploy Laravel, Symfony or CodeIgniter on Kuberns?

PHP frameworks can use the same repository-based deployment workflow when their runtime, dependency, public-directory, environment-variable, database and background-process requirements are correctly represented in the project and deployment configuration.

---
- [More Deployment Guides articles](https://kuberns.com/blogs/category/deployment-guides/1/)
- [All articles](https://kuberns.com/blogs/)