PHP developers are makers at heart. The core strength of PHP has always been in creating a tight feedback cycle between developers and their audiences. That strength is the reason why PHP powers so many of the world’s biggest and best web properties such as Facebook and Etsy. But as developers of those and similar apps know, PHP hasn’t always enjoyed some of the runtime, management or infrastructure elements its peer communities like Ruby on Rails, Python with Django, and Node have had for some time.
As one of the web’s largest PHP shops, Facebook has been an advocate and innovator for the language, but it’s been hard for PHP developers beyond Facebook’s walls to take advantage of that innovation. We’ve been fortunate to work with Facebook on a variety of occasions, and with their F8 Conference next door to our office here in San Francisco, we thought it would be a great opportunity to help bring some of their and the PHP communities’ latest innovations to developers everywhere, by announcing today full Heroku support for the new PHP. If you are in town for F8, please join us tonight for a pre-conference PHP meetup at our office right next door to the main venue.
This new PHP is built on new runtimes and frameworks, marrying the familiarity and productivity of the popular language with the best practices of other modern frameworks – letting PHP developers take their favorite language further than ever. The new PHP is perfectly suited for modern development and deployment Heroku helped create, and is available today. More specifically, Heroku is making available in public beta today:
At the foundation of the new PHP is Facebook’s HipHop VM, a modern, high-performance runtime for PHP that promises orders of magnitude speed improvements while retaining compatibility. With help from the Facebook team, this VM is now available as part of the Heroku buildpack, so developers can quickly deploy their PHP code onto this new VM just as they would Rails or Python. Specifying running with the traditional VM or HHVM is now a trivial switch for PHP apps on Heroku.
Declarative and explicit dependency management is a core facet of building apps in this new world. This ensures:
- A clean development pipeline
- Ease in onboarding new developers to your project
- Parity between development and production closer thus making running production apps easier.
This form of structured dependency management has been available in other Heroku supported languages for years, and now PHP via Composer has copied the best of breed from all of them. Further the new PHP brings with it many new frameworks such as Symfony and Laravel which bring forward this new type of development.
Together dependency management and these newer frameworks help to better deliver apps that can both be brought to market quickly, but also maintained and scaled in a predictable fashion today on Heroku.
With these enhancements, PHP can take advantage of the benefits Heroku introduced with XL, offering a complete path for companies to deploy and scale PHP in high scale, high performance contexts. PX Dyno compatibility brings even greater performance to PHP apps running on Heroku, and coupling with HHVM support delivers performance for even the highest scale sites. And with premium support for PHP, developers and enterprises both can deploy their PHP apps with the confidence of having 24 x 7 technical resources available to them.
Enough talk though, let's give it a try. First let’s create our standard hello world application with an
<?php echo "Hello World!"; ?>
Now we’re going to create our composer.json file, which in this case will be empty because we’re not using any dependencies at all for our application:
Finally let’s commit it to git, create our heroku application, and deploy.
$ git init Initialized empty Git repository in ~/hello_heroku_php/.git/ $ git add . $ git commit -m "Initial import of Hello Heroku" [master (root-commit) 06ba0a7] Initial import of Hello Heroku 2 files changed, 5 insertions(+) create mode 100644 composer.json create mode 100644 index.php $ heroku create Creating safe-ridge-5356... done, stack is cedar http://safe-ridge-5356.herokuapp.com/ | email@example.com:safe-ridge-5356.git $ git push heroku master ... $ heroku open
And now we have a working PHP app.
We’d like to thank so much of the community for helping drive so much innovation in PHP, from the creators of Composer to the Facebook team working on HHVM. We look forward to seeing what you build with this new PHP support on Heroku and welcome any feedback or comments as you dig in.