• Overview
    Key features
    • Observability
    • Auto-scaling
    • Multi-framework
    • Security
    Frameworks
    • Django
    • Next.js
    • Drupal
    • WordPress
    • Symfony
    • Magento
    • See all frameworks
    Languages
    • PHP
    • Python
    • Node.js
    • Ruby
    • Java
    • Go
  • Industries
    • Consumer Goods
    • Media/Entertainment
    • Higher Education
    • Government
    • Ecommerce
  • Pricing
  • Overview
    Featured articles
    • Switching to Platform.sh can help IT/DevOps organizations drive 219% ROI
    • Organizations, the ultimate way to manage your users and projects
  • Support
  • Docs
  • Login
  • Request a demo
  • Free Trial
Blog

Drupal 8 starter kit now with PHP 7 and Composer!

symfonydrupalphp
07 June, 2016
Larry Garfield
Larry Garfield
Director of Developer Experience

Drupal 8.1 has made a significant shift toward embracing Composer as the standard way to install and manage a Drupal site. Starting today, with Drupal 8.1.2, Platform.sh’s Drupal 8 templates are also Composer-based, and default to using PHP 7.

Wait, what about my existing sites?

Absolutely nothing changes for sites already hosted with Platform.sh. If you’re using Drush Make or just checking your entire Drupal site into Git, you can continue to do so. Nothing in this post applies to you (unless you want it to).

Oh good. So what actually changes?

When you create a new site with Platform.sh, you’re given the opportunity to select a “template” for a site. The template is really just a starter Git repository, complete with a recommended .platform.app.yaml file and .platform directory for a given application. Until now, the template for Drupal 7 and Drupal 8 used Drush Make as their build script. The Drupal 8 template now uses Composer, just like our Symfony template and most other PHP applications.

The Composer template is closely based on the (excellent) Drupal-Composer project built by the Drupal community. It adds only two patches to make Drupal install cleanly on a read-only file system, both of which have already gone through the Drupal issue queues and are just waiting to be committed. Once they’ve been incorporated into a point release we’ll drop those patches from our composer.json file.

As Drupal 8 is also fully tested with PHP 7, we’ve defaulted to PHP 7.0 for all newly created Drupal 8 sites.

As Platform.sh containers are always “production ready”, the composer command we use is optimized for production. Specifically, we run:

composer install --no-progress --prefer-dist --optimize-autoloader

Neat. But wait, which Composer repository are you using for Drupal?

Drupal currently has two different Composer services, a legacy one hosted at https://packagist.drupal-composer.org and a new, experimental one at https://packages.drupal.org/. We’ve been in contact with the Drupal.org Infrastructure team, and they’ve given us the go-ahead to default to the new, official service.

If you want to switch back to the legacy service, be sure to check the Drupal.org documentation page for notes on the different way it handles module versions.

But, but, I have legacy code that doesn’t work with PHP 7 yet!

Not to worry! If you need to start a new Drupal 8 site but want to run it on PHP 5.6 instead, simply edit your  .platform.app.yaml  file and change the line

type: "php:7.0"

to

type: "php:5.6"

Then  git push . Yes, it really is that easy.

(PHP versions before 5.6 are not supported by the PHP development team. We only provide those images to support legacy projects. Please use PHP 5.6 or, preferably, PHP 7 for all new projects. Security experts around the world thank you.)

I already have a Drupal 8 project using Composer. Will it still work?

Absolutely! Simply go to the template Git repository and copy the  .platform.app.yaml  file and  .platform  directory, then stick those in your project’s Git root. If you used the Drupal-Composer project to create it initially, all of the paths should still work fine. You will also need the  settings.php  and  settings.platformsh.php  files to ensure your site gets the correct database credentials and such. You can tweak the  .platform.app.yaml  file if needed, such as if your files are organized differently.

You can also tweak those files as needed to configure your cluster exactly how you need. See the documentation for more details.

What about Drupal 7?

We’re still investigating whether we want to switch our Drupal 7 template over to Composer. (If you have thoughts on the matter, let us know.) Currently, Drupal 7’s test suite doesn’t fully pass under PHP 7 as there’s still a few edge case bugs, and a number of contrib modules need minor tweaks. We may default Drupal 7 to PHP 7 in the future when we feel it’s safe to do so. For now, we recommend PHP 5.6 for Drupal 7 sites.

Wow, thanks, this is great!

Happy to help! See you in the Cloud…

Get the latest Platform.sh news and resources
Subscribe

Related Content

DrupalCamp Florida 2024: sharing takeaways from the experts

DrupalCamp Florida 2024: sharing takeaways from the experts

Company
AboutSecurity and complianceTrust CenterCareersPressContact us
Thank you for subscribing!
  •  
Field required
Leader Winter 2023
System StatusPrivacyTerms of ServiceImpressumWCAG ComplianceAcceptable Use PolicyManage your cookie preferencesReport a security issue
© 2024 Platform.sh. All rights reserved.
Supported by Horizon 2020's SME Instrument - European Commission 🇪🇺