Zaher Ghaibeh
PHP Backend developer
I've experience in a few PHP Frameworks, such as Laravel, Lumen and Slim (The last two are used for building Microservices/API services).
Two tips to speed up bitbucket pipelines
Published at Sunday, March 4, 2018

In the past few days, I was playing around with pipelines to see what can I do with it, and how much can I squeeze it to get as much as I can from the functionality they offer. And I wanted to point out to two main things that you can do to speed up your PHP testing a bit, not much but a bit which counts.

First of all, if you don't use the built-in composer cache functionality, then you need to do that right away, and enabling it is just a small line of code that you add to the test section like

caches:
  - composer

Nothing else, once you have done that you will use the cache they offer and no need to redownload the packages from the internet and the cache will be invalidated automatically after 7 days (if am not mistaken), but this does not mean you don't have the ability to delete the cache manually. But keep in your mind that each section should use the caches tag otherwise it won't be useful, sadly Bitbucket pipeline does not offer a global cache feature.

Secondly, remember to install and use hirak/prestissimo package globally, which will give you a nice speed as we all know.

so your file can have something like:

clone:           # the 'clone' section
  depth: 1       # the depth, in this case the clone will contain last commit

options:
  max-time: 10
  docker: true

image: zaherg/php-7.1-xdebug-alpine:latest

pipelines:

  default:
    - step:
        name: Build and push the image
        deployment: staging
        caches:
          - composer
        script:
          - composer config -g github-oauth.github.com $GITHUB_TOKEN
          - composer global require hirak/prestissimo
          - composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader