Heroku uses Composer for dependency management in PHP projects, and the composer.json file indicates to Heroku that your application is written in PHP. Heroku uses Composer for dependency management in PHP projects, and the composer.json file indicates to Heroku that your application is written in PHP. The official buildpack comes with PHP 5.5.11-5.5.14, so it'll never say 'This program requires PHP 5.5.11 or newer; check your 'php' command.' On boot, and it will reject pushes with heroku/heroku-buildpack-php as a non-dev dependency.
This is the official Heroku buildpack for PHP applications.
It uses Composer for dependency management, supports all recent versions of PHP as runtimes, and offers a choice of Apache2 or Nginx web servers.
You'll need to use at least an empty
composer.json in your application.
If you also have files from other frameworks or languages that could trigger another buildpack to detect your application as one of its own, e.g. a
package.json which might cause your code to be detected as a Node.js application even if it is a PHP application, then you need to manually set your application to use this buildpack:
This will use the officially published version. To use the default branch from GitHub instead:
Please refer to Dev Center for further usage instructions.
Custom Platform Repositories
The buildpack uses Composer repositories to resolve platform (
ext-something, ...) dependencies.
To use a custom Composer repository with additional or different platform packages, add the URL to its
packages.json to the
HEROKU_PHP_PLATFORM_REPOSITORIES config var:
To allow the use of multiple custom repositories, the config var may hold a list of multiple repository URLs, separated by a space character, in ascending order of precedence.
If the first entry in the list is '
-' instead of a URL, the default platform repository is disabled entirely. This can be useful when testing development repositories, or to forcefully prevent the use of unwanted packages from the default platform repository.
For instructions on how to build custom platform packages (and a repository to hold them), please refer to the instructions further below.
Please note that Heroku cannot provide support for issues related to custom platform repositories and packages.
The following information only applies if you're forking and hacking on this buildpack for your own purposes.
Please submit all pull requests against
develop as the base branch.
Heroku Mysql Pricing
Custom Platform Packages and Repositories
Please refer to the README in
support/build/ for instructions.
The history of PHP is the history of the web. Long-time developers will remember how PHP changed the universe of web development. PHP brought two key innovations to the table when it first launched. First, it was interpreted, which meant you could edit a file in place, then refresh the page and see the result. This quick feedback loop was why so many started with PHP and is still a cornerstone of what makes the language so useful. Second, it was the first widespread templating language which enabled intermixing of HTML and PHP code. Every other major web language and framework since PHP has followed suit.
Over time, PHP became a cornerstone of the “LAMP stack”. The LAMP stack consisted of Linux, Apache, MySQL, and PHP, and helped to define the world of open source we all take for granted today. The ubiquity of open-source software in web development is near-absolute now, but it was the success of these technologies that redefined an industry.
Of course PHP wasn’t perfect and other languages and their frameworks came along to contend with PHP as the years went by. In fact, Heroku’s founders ran a PHP consultancy called Bitscribe which focused on PHP development before founding Heroku. They eventually moved from PHP on to Ruby on Rails, which led to the creation of Heroku when they discovered that the Rails ecosystem lacked good hosting options.
A Modern PHP
The best way to get someone to do the right thing is to make it the easiest thing to do. That’s why we’ve built Heroku to support and encourage the best practices of modern software development out of the box. We’ve captured a lot of this experience in the Twelve-Factor App Manifesto, and now we’ve also applied it to our new PHP support on the platform. Here’s a look at just of the few of they ways they apply:
The days of live on-server editing along with all the late nights and outages it inevitably leads to are fortunately behind us. Version control is ubiquitous today, and it’s rare to meet a development team not collaborating using a tool like Phabricator or GitHub. Unfortunately, it’s still far too common for system libraries, web servers, and extensions to be mismatched between dev, staging, and production environments. On Heroku, your git integrated deployment pipeline allows you to “git push” to deploy code with confidence whether it’s to your development environment or to production. We’ll use Composer to automatically ensure you get exactly the right version of all your code’s dependencies every time, including configuring either Apache or Nginx, and all your system dependencies.
Although many other languages have grown their own rudimentary native web servers, it’s still most common to pair PHP with a dedicated web server. Apache is the most common choice and very well understood, but Nginx is certainly growing in popularity. We support both, and in order to improve dev-prod parity, we’ve built a composer package that lets you, the developer, choose which one you prefer, receive a sensible configuration out-of-the-box, and further configure them with ease whether you’re running on Heroku, your local machine, or anywhere you please.
Today and Tomorrow
In today's world, PHP developers choose from a huge variety of technology options. These include modern data stores like PostgreSQL, Redis, and MongoDB, front-end frameworks like Angular, and platforms like, of course, Heroku.
Heroku Php Version
In fact, for many modern PHP applications the notion of the LAMP stack seems limiting. Fortunately, PHP developers on Heroku can fearlessly take advantage of just about any technology they can imagine. For example, every PHP app on Heroku includes a free PostgreSQL database with support for a wide variety of powerful features like full-text search, and native JSON types. If Postgres isn’t to your liking our add-on marketplace brings the entire ecosystem to your fingertips. If you’ve got a technology need, you’ll probably find just the add-on you’re looking for.
One piece of future direction we’re incredibly excited about is Hack. Hack brings a whole host of new developments to PHP. Many PHP developers have heard about HHVM, Facebook’s high performance PHP virtual-machine project. Hack is another project from that team, and it includes great new features like an improved collections library, asynchronous method calls, and even the world’s friendliest type-system - all while supporting vanilla PHP code and enabling you to adopt it incrementally as you discover the features you need. And Hack is available for you to try directly on Heroku today with this new PHP support.
We should note though, Hack is quite new, and we encourage you to give it a try, but at this point support for Hack should definitely be considered
experimental and we would encourage you to test it thoroughly before putting anything into production.
When you put all these pieces together, it’s inarguable: PHP’s future is bright. Hundreds of thousands of PHP developers ship code every day. From Facebook to Etsy to Wordpress: big companies continue to invest in PHP. Between the long-term stewardship of Zend and the new creative energies Facebook’s
Hack language have brought to the community, it’s clear that no matter what flavor of PHP you choose there’s an ever more powerful, flexible future… with lots of fast feedback.
Whether you’re engineering high-scale mission-critical systems every day or you’re just making things for yourself and your friends, try the new PHP in public beta on Heroku today.
How Does Heroku Work
Happy making, and welcome to Heroku.