Setting Up Bamboo for Continuous Integration in PHP Projects

Learn how to set up Bamboo for seamless continuous integration in PHP projects. Automate testing, streamline deployment, and boost efficiency!

Get Started free
Home Guide Setting Up Bamboo for Continuous Integration in PHP Projects

Setting Up Bamboo for Continuous Integration in PHP Projects

As PHP projects scale in complexity, ensuring consistent code quality and rapid delivery becomes increasingly difficult without automation. Continuous Integration (CI) addresses this challenge by enabling teams to automatically build, test, and validate code every time a change is committed.

Bamboo, Atlassian’s CI/CD server, is well-suited for teams that require customizable pipelines, integration with the Atlassian toolset, and control over their build infrastructure. While it’s commonly associated with Java environments, Bamboo can support PHP workflows with the right configuration.

This article explains why Bamboo is well-suited for PHP projects. It covers the prerequisites, setup process, integration with development tools, connecting to a cloud-based Selenium Grid, and running CI tests using BrowserStack.

Why Use Bamboo for PHP Projects?

Bamboo stands out as a CI tool for PHP projects due to its seamless integration with Atlassian tools, customizable pipelines, and scalability. Here’s why it’s a great choice:

  • Tight Integration with Bitbucket & Jira: Bamboo connects seamlessly with Bitbucket for version control and Jira for issue tracking, streamlining the development workflow.
  • Parallel Testing: Bamboo allows running tests in parallel, reducing execution time and speeding up feedback.
  • Customizable Pipelines: With flexible build configurations, teams can define custom stages and jobs tailored to PHP applications.
  • Docker Support: Bamboo supports Docker-based builds, making it easier to create reproducible environments for PHP applications.
  • Deployment Automation: With built-in deployment tools, Bamboo enables automated releases to different environments.

Prerequisites for Setting Up Bamboo CI

To set up Bamboo for PHP projects, ensure the following prerequisites are met:

1. System Requirements

Before setting up Bamboo for your PHP project, ensure the following system requirements are met:

  • Operating System: Bamboo supports Windows, macOS, and Linux. Linux is recommended for production environments due to its better performance and stability.
  • Hardware: For faster builds, you need a minimum of 8GB RAM (16GB+ is recommended for larger pipelines), a 4-core CPU, and SSD storage.
  • Java Installation: Bamboo requires Java 11 or Java 17 (either OpenJDK or Oracle JDK). Run java -version to check the installed version.

2. Database Configuration

Bamboo needs a database to store build configurations and results. Supported databases include:

  • PostgreSQL (Recommended)
  • MySQL 5.7+ or MariaDB 10+
  • Microsoft SQL Server 2016+
  • Oracle 12c+

Bamboo provides an internal H2 database for small-scale setups, but it’s not recommended for production use.

3. Version Control System (VCS) Integration

Bamboo supports multiple VCS options, ensuring seamless integration for automated builds:

  • Git: Fully compatible with GitHub, GitLab, and Bitbucket. Ideal for collaborative and modern development workflows.
  • Mercurial: Still supported by Bamboo but deprecated in Bitbucket, which officially removed Mercurial support in June 2020.
  • Subversion (SVN): Supported for legacy projects but rarely used in current CI practices.

4. PHP Development Environment

Ensure the Bamboo server and agents have a properly configured PHP environment:

  • PHP Version: Install PHP 8.0 or higher (depending on project compatibility). Check with php -v.
  • Composer: Install Composer for dependency management (composer -V).
  • PHP Extensions: Ensure required extensions (like pdo_mysql, curl, mbstring, and xml) are installed.

5. Testing & Code Quality Tools

Set up PHP testing frameworks for automated testing within Bamboo:

  • PHPUnit: For unit testing. (composer require –dev phpunit/phpunit)
  • Behat: For behavior-driven testing.
  • Codeception: For functional, API, and acceptance testing.
  • PHPStan/Psalm: For static analysis and catching errors early.

6. Bamboo Agents for Distributed Builds

Bamboo uses local agents (on the Bamboo server) or remote agents (on separate machines) to run builds:

  • Local Agents: Suitable for small-scale projects.
  • Remote Agents: Recommended for parallel builds and large teams. Ensure agents have PHP, Composer, and other dependencies installed.

7. Docker (Optional for Containerized Builds)

Install Docker if you plan to run PHP builds in containers. For projects with multiple services (such as PHP, MySQL, and Redis), use Docker Compose to manage them efficiently.

Bamboo also integrates with Docker Hub and Kubernetes, enabling automated builds and deployments in containerized environments.

8. Additional Tools for CI/CD Efficiency

To enhance your CI/CD pipeline and streamline workflows, consider integrating the following additional tools:

  • Jira Integration: If using Jira, link it to Bamboo to track builds linked to issues.
  • AWS/GCP/Azure (Optional): If deploying PHP applications to the cloud, configure Bamboo for cloud deployments.
  • Slack/Webhooks: For build notifications and monitoring.

With these prerequisites in place, you can set up Bamboo for PHP projects effectively, enabling a smooth and reliable Continuous Integration and Deployment process.

How to Set Up Bamboo

Setting up Bamboo for CI/CD in a PHP project includes several straightforward steps to ensure a smooth workflow. Here’s how to get started:

1. Install Bamboo:

  • Download Bamboo from the official Atlassian page.
  • Choose between Cloud or Server installation depending on your infrastructure needs.

2. Set Up Bamboo Server:

  • After installation, initiate Bamboo’s setup wizard.
  • Configure the database (MySQL, PostgreSQL) and define admin credentials during setup.

3. Bamboo Agent:

  • Configure Bamboo agents to run your builds. Use pre-configured agents or set up your own based on the tools needed (like PHP or Composer).

4. Create Your First Plan:

  • Go to the dashboard and select Create Plan.
  • Choose your Source Repository (Git, Bitbucket, etc.) where your PHP project is located.
  • Set up Plan Tasks, such as running unit tests, packaging the app, and deployment tasks.

Code Example: To integrate a PHP project into Bamboo, use the following script in the build plan to run Composer and PHPUnit:

# Install Composer dependencies

composer install



# Run tests with PHPUnit

./vendor/bin/phpunit --configuration phpunit.xml

Configuring and Integrating Bamboo CI with PHP (Tools)

This section explains how to configure Bamboo to integrate with key PHP development tools, such as Composer, PHPUnit, and optionally Docker, to create a robust and isolated CI environment.

1. Install Composer and PHPUnit:

  • Add Composer and PHPUnit as tasks in Bamboo to automate dependency management and testing.
  • You can install Composer via a command task in Bamboo with:
curl -sS https://getcomposer.org/installer | php

2. Create Build Tasks:

  • Composer Install: Automate dependency installation with the following Bamboo task:
# Bamboo Script Task: Composer Install

php composer.phar install
  • PHPUnit Tests: Add a task to run PHPUnit tests:
# Bamboo Script Task: Run PHPUnit Tests

php vendor/bin/phpunit
  • Docker (Optional): If using Docker for PHP app containerization, add Docker tasks:
# Bamboo Script Task: Docker Build

docker build -t php-app .

docker run --rm php-app

Configuration in Bamboo UI:

  • Add these scripts under Plan Tasks in Bamboo’s UI.
  • Ensure your Bamboo agent has PHP, Composer, and PHPUnit installed.

Environment Variables:

  • Bamboo allows you to define environment variables for credentials or API keys needed during tests or deployments.

How to Integrate Bamboo Pipeline With Cloud Selenium Grid

The next step is to set up Bamboo to work with a Cloud-based Selenium Grid like BrowserStack to run browser automation tests as part of the CI/CD pipeline.

1. Set Up Cloud Selenium Grid:

2. Add Selenium Grid Task in Bamboo:

Modify your Bamboo build plan to include a task to run Selenium tests on the cloud grid.

Example Bamboo Script to run Selenium tests on BrowserStack:

# Example Selenium script to run tests on BrowserStack

export BROWSERSTACK_USERNAME="your_username"

export BROWSERSTACK_ACCESS_KEY="your_access_key"

# Run the Selenium tests

java -jar selenium-server-standalone.jar -browser "browserstack" -hub "http://hub-cloud.browserstack.com/wd/hub"

3. Configure Bamboo to Trigger Selenium Tests:

  • Use Selenium WebDriver to connect to the cloud grid and run tests.
  • Set up triggers in Bamboo to initiate tests when code is pushed.

4. Run Tests in Parallel:

With a cloud-based Selenium Grid like BrowserStack, you can run multiple tests in parallel on different browsers. Configure Bamboo to distribute tests across different browser configurations, reducing overall test time.

BrowserStack Automate Banner

Why Choose BrowserStack to Run Bamboo CI Tests

BrowserStack enhances your Bamboo CI pipeline by providing a cloud-based testing infrastructure tailored for modern development needs. Here’s why it’s an ideal choice:

  1. Cloud-Based Cross-Browser Testing: Instantly test your application on a real-device cloud with 3,500+ browser and device combinations without the need to set up or maintain any infrastructure.
  2. Scalability: Easily scale test execution as your team and test coverage grow.
  3. Parallel Testing: Run multiple tests simultaneously to significantly reduce build times and speed up release cycles.
  4. Seamless Bamboo Integration: Connect Bamboo to BrowserStack using remote WebDriver endpoints and environment variables with minimal setup.
  5. Real Device Testing: Validate functionality and performance on real mobile and desktop devices to ensure accurate, user-level test results.
  6. Test Across Multiple Environments: Run tests on different OS, browser, and device combinations to ensure consistent performance everywhere.
  7. Real-Time Debugging: Access video recordings, console logs, and network traffic for every test session to quickly diagnose and fix issues.

Talk to an Expert

Conclusion

Bamboo brings control, flexibility, and deep integration capabilities to PHP projects, making it a reliable choice for continuous integration. With the right setup and supporting tools, you can automate builds, run tests efficiently, and maintain code quality across environments.

With cloud-based testing solutions like BrowserStack, Bamboo enables faster feedback, real-device coverage, and smoother releases, helping your team deliver reliable PHP applications.

Tags
Automation Testing CI CD Tools DevOps

Get answers on our Discord Community

Join our Discord community to connect with others! Get your questions answered and stay informed.

Join Discord Community
Discord