[go: up one dir, main page]

Search overlay panel for performing site-wide searches

Boost Performance & Scale with Postgres Advanced. Join Pilot Now!

A blue oval logo with the letters "PHP" in the center.

Build beautiful apps with PHP

The elegant platform for modern PHP apps

Deploy

When you push your code, Heroku automatically detects, installs and enables the PHP version and PHP extensions required by your app’s composer.lock.

Heroku’s PHP support docs

Customize

Whether you prefer Apache HTTPD or Nginx, they work out of the box, or with your own configuration. Need custom php.ini settings? You have full control!

Configuring PHP and Web Servers

Scale

Scale your dynos horizontally by simply dragging a slider. Heroku automatically configures PHP-FPM workers based on dyno RAM and configured PHP memory_limit.

Optimizing PHP Application Concurrency

Get started now with PHP on Heroku

Deploying PHP apps with Heroku

  • Initialize the local Git repository
  • Create an index.php file to respond to requests with “Hello Heroku!”
  • Specify the PHP version with composer require
  • Create and deploy the app to Heroku
  • We’re live! curl https://fathomless-atoll-28375-776e6265b2bf.herokuapp.com

View PHP Docs

Heroku gives you simple, easy ways to…

Be in the Flow

Collaborating easily, testing early, and deploying often are all part of Heroku FlowHeroku Pipelines streamline your workflow, Heroku Review Apps auto-deploy your PRs, Heroku CI tests anything you push to GitHub, and much more.

Continuous Delivery on Heroku

Architect and scale

The Heroku runtime makes it easy to deploy loosely coupled services that run in lightweight, isolated Linux containers known as dynos. The architecture of the Heroku platform encourages best practices that ensure durability and scalability.

Heroku Platform Principles

Extend and grow

Extend your app with relational databases like PostgreSQL or MySQL, leverage NoSQL data stores such as Redis® or MongoDB, stream events into Apache Kafka or an AMQP server, send emails, monitor your app – with 200+ add-ons, the possibilities are limitless.

Heroku Add-ons

The PHP logo, featuring "php" in lowercase letters, is displayed in white within a blue oval.

PHP on Heroku

“PHP developers enjoy the language’s stability, superb performance, and incredible, constantly evolving ecosystem. Powerful frameworks, unrivaled dependency management, and Heroku’s smooth user experience make app developers happy and productive.”

A person with curly hair and glasses is looking to the side, sitting indoors. They are wearing a dark shirt.

David Zuelke

PHP Language Owner

Popular Add-ons

Add-ons are fully-managed services, integrated for use with Heroku, which provide services for logging, caching, monitoring, persistence and more.
View All Add-ons

Heroku Postgres

Data Stores

Red circle with a white horizontal rectangle in the center, resembling a minus sign.

Mailgun

Email/SMS

A geometric design with interlocking green and dark gray rectangular shapes forming a 3D-like structure on a white background.

New Relic APM

Monitoring

Papertrail logo

Papertrail

Logging

Heroku PHP Support FAQ

Heroku manages PHP dependencies using Composer, the standard package manager for PHP. When you deploy your application, the buildpack automatically detects a composer.json file and runs the composer install command for you. This uses your composer.lock file to install the exact versions of your dependencies, ensuring a consistent and reliable environment every time you deploy.

In addition, all platform package requirements (such as for php or an extension like ext-redis) that you or any dependent package specifies are evaluated together and used to determine the PHP versions and extensions to install. This happens using the same resolution rules that Composer employs internally during the installation of your regular dependencies, ensuring that the PHP runtime and extension versions installed by Heroku always match the requirements in your lock file.

The fastest way to get started is by following the official Getting Started on Heroku with PHP guide in the Heroku Dev Center. This tutorial provides a sample application and walks you through the steps of managing dependencies with Composer and deploying your code with a simple git push heroku main command.

Heroku’s PHP support aligns with the PHP Group’s support policy, with support provided for all modern, stable versions (such as 8.2, 8.3 and 8.4). Typically, this support means active updates for two years after an initial x.y.0 version, followed by a year of security updates.

You can specify the version series of PHP your app requires in your composer.json file. For example, to use the latest version of PHP 8.3, you would add a line like "php": "8.3.*" to your require block. It is strongly recommended to declare a version to ensure a consistent and predictable build environment.

Heroku supports the entire modern PHP ecosystem, allowing you to deploy applications built with almost any framework. While industry leaders like Laravel and Symfony are extremely popular on the platform, Heroku’s flexibility also makes it a great choice for other tools. This includes established enterprise frameworks like Laminas (formerly Zend Framework) and lightweight micro-frameworks like Slim.

You can use PHP’s built-in web server for testing, although it is not recommended. It shouldn’t be used for production apps on Heroku because it is not designed to handle the performance or security needs of a live application.

Instead, you should use a production-grade web server like Apache HTTPD or Nginx. Heroku’s official PHP buildpack automatically includes and configures HTTPD and Nginx to serve your application, so for most projects, you don’t need to do any manual web server configuration aside from, for example, project-specific URL rewrite rules. To customize the web server’s behavior, you can specify custom configuration files in your Procfile command, or use .htaccess files (for Apache HTTPD).

You can enable many common PHP extensions by declaring them as dependencies in your composer.json file. The PHP buildpack recognizes the normal ext-<extension_name> package names in the require block and resolves these requirements together with all other platform package requirements to ensure the extensions are installed and enabled.

For example, to enable the gd extension for image processing, you would add the following to composer.json:

"require": {
  "ext-gd": "*"
}

During your next deployment, the buildpack will see this requirement and automatically enable the gd extension in your application’s environment.

You can customize your php.ini settings on Heroku by creating a .user.ini file in your application’s root directory. Any valid php.ini directive placed in this file will override the default PHP settings provided by the platform. For specific examples and additional documentation, you can read more about Customizing Runtime Settings for PHP in the Heroku Dev Center.

Yes, it is possible to deploy PHP applications like WordPress and Drupal on Heroku, but it requires a different approach than a traditional hosting environment. Heroku’s ephemeral filesystem means that any files uploaded directly to the application’s dynos—such as media uploads, themes, or plugins installed via the admin dashboard—will be lost when the dyno restarts or scales. Similarly, any plugins that write to the local filesystem, such as caching plugins like W3 Total Cache, may behave unexpectedly as those file changes are not shared between running dynos.

To run a CMS successfully on Heroku, the entire codebase must be managed in a Git repository. For managing user-uploaded files, cloud-based storage solutions like Amazon S3 are recommended. For Drupal specifically, the Flysystem module is a great tool for integrating with these external storage services. While this workflow is different, it aligns with modern development best practices, providing version control and a more stable, scalable application.

Ready to Get Started?

Stay focused on building great data-driven applications and let Heroku tackle the rest.

Sign Up Now