Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Run Laravel and PHPUnit in a pipeline

Michael Dzjaparidze September 1, 2016

We want to use a pipeline to run phpunit for our Laravel project every time something is committed. I've tried to set this up, but had no luck. I guess it doesn't really help that I am not that familiar with Docker.

Some questions:

  • Is it necessary to run `composer install` every time? We have a moderately large project and I noticed this can take up to 7 minutes. I vaguely know what Docker images are, but can't quite figure out if they would be of any help here.

  • Even though `composer install` finishes successfully, running `artisan` results in an `artisan: command not found` error. Not really sure why this would be... I had hoped that `composer install` would take care of it all.

Is there perhaps anyone who has managed to successfully set up a Bitbucket pipeline for a Laravel project?

Thanks in advance,




2 answers

1 accepted

0 votes
Answer accepted
Tom Bradshaw
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 1, 2016

Hi Michael,

A docker image is effectively a snapshot of a system at a specific point. Once you run it it works a little like a virtual machine and can be modified and edited as you wish. Because of this using a specific docker image could cut down on the time to install composer or php but it will not also have your dependencies downloaded. You will have to continue to run 'composer install'. I would definitely recommend checking out the docker docs located here:

As for the problem of not being able to run artisan after the command finishes I have a few suggestions. If you're not installing artisan globally that might explain not being able to run the command. The first step is to get the docke rimage running locally and then executing the commands on the docker image and seeing whether the problem persists and whether there is a way to diagnose the problem. If this does not work you can raise a support ticket at


Michael Dzjaparidze September 2, 2016

Thanks for your answer Tom. I guess delving into Docker a bit more is unavoidable. Will do when I get the time.

0 votes
Paul van Hemmen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 13, 2016

Hey Michael, we have successfully set up a working laravel development pipeline, where artisan works without problems. A few suggestions:

  • make sure your docker image has a working php version installed. We are using `image: phpunit/phpunit:5.0.3`as the docker image, it comes with everything preconfigured to run laravel deployments. Since composer already works, it could be the wrong php version or something else related to your php version.

  • be sure to run `php artisan ...` instead of just `artisan ...`
  • cd into the right directory before triggering the command, otherwise artisan will not run

If you want, I can paste a working laravel deployment queue for a target linux machine for you somewhere. Just let me know.

Michael Dzjaparidze September 14, 2016

Yes, `php artisan` instead of just `artisan` made the difference. There are still some issues to be resolved though. Like for instance disabling xdebug for composer. I suppose this has to be done from the command line somehow. Furthermore, although both the command `composer install` and `php artisan` finish successfully now, we get the following error when expanding the log for each of these two steps:

{"error":{"type":"ErrorException","message":"file_put_contents(\/meta\/services.json): failed to open stream: No such file or directory","file":"\/opt\/atlassian\/bitbucketci\/agent\/build\/vendor\/laravel\/framework\/src\/Illuminate\/Filesystem\/Filesystem.php","line":70}}


It would be great if you could share your laravel setup. I would appreciate this very much.

James Fairhurst
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 17, 2016

I've just been experimenting with getting this in place with a fresh Laravel 5.3 install, my pipelines file is this which seems to work:

# This is a sample build configuration for PHP.
# Check our guides at for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: phpunit/phpunit:5.0.3

    - step:
        script: # Modify the commands below to build your repository.
          - php -r "file_exists('.env') || copy('.env.example', '.env');"
          - composer install
          - php artisan key:generate
          - phpunit

Next step is database testing.

David Macias
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 21, 2016

@Paul van Hemmen and @James Fairhurst I'm trying to do the same thing as you guys, but can't find a lot of documentation to help a newb out. I have a Laravel 5.1 app in Bitbucket and would love to use Pipelines to push it out to my Beanstalk instance. Can you guys provide a bit more detail or resources to try and get this working? Thank you!


Testing Matrix
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 21, 2023

@Michael Dzjaparidze 

i used this one

image: wagnerstephan/bitbucket-git-ftp:latest

- step:
name: Deploy to staging
deployment: staging
- pipe: atlassian/sftp-deploy:0.5.7
REMOTE_PATH: '/srv/users/sandbox/apps/sandbox'
SSH_KEY: '/opt/atlassian/pipelines/agent/ssh/id_rsa'

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events