CI/CD: Automatic deployment for TYPO3 Projects

Continuous Integration (CI) and Continuous Deployment/Delivery (CD) are development practices that automate the process of building, testing, and deploying code. Implementing CI/CD for TYPO3 projects ensures higher quality releases, faster feedback loops, and lower risk of introducing bugs.

Why CI/CD for TYPO3?

TYPO3 is a powerful, enterprise-level CMS written in PHP. TYPO3 projects often involve custom extensions, configuration management (TypoScript, YAML config), and complex deployment workflows. Manual deployment increases the risk of human error, environment inconsistencies, and delayed releases. CI/CD automates these concerns.

Common CI/CD Stages in TYPO3 Projects

Code Quality Checks

Unit and Functional Testing

Building Artifacts

  • Installing required extensions and other PHP packages via Composer
  • Compile frontend assets (e.g., SCSS, JavaScript) using tools like Webpack, Gulp or Vite.

Deployment

  • File Synchronization: Deploy code and assets using tools like Rsync, Deployer, or Git-based workflows.
  • Database Migrations: Run database migrations using TYPO3’s vendor/bin/typo3 extension:setup or vendor/bin/typo3 database:updateschema if helhum/typo3-console is installed.
  • Cache Clearing: Clear TYPO3 caches (vendor/bin/typo3 cache:flush).

Environment configuration

Manage environment-specific settings using .env / dotenv files or Plain PHP configuration files.

Typical CI/CD Tools Used

CI/CD Platforms
GitHub Actions, GitLab CI, Jenkins, or CircleCI
Code Quality
PHP-CS-Fixer, PHPstan, and TypoScript-Lint
Testing
PHPUnit with the TYPO3 Testing Framework
Build Tools
Docker or Podman, Composer, Webpack, Gulp, or Vite
Deployment Tools
Deployer, Rsync, Helm, Ansible, GitOps

CI/CD Platforms

Using GitLab CI

The t3start:gitlab-template provides a predefined .gitlab-ci.yml and a Deployer recipe that you can customize to your needs.

Even if you already set up your project you can find valuable examples there.

Using GitHub Actions

In the following code-block you find a very simplified example of what a deployment workflow with GitHub Actions might look like.

For a more life like example see the .github-ci.yml of Stefan Frömken's TYPO3 Lexicon.

.github/workflows/.github-ci.yml
name: TYPO3 CI/CD Pipeline

on:
  push:
    branches: [ "main" ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Set up PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.3'

      - name: Install Dependencies
        run: composer install --prefer-dist

      - name: Lint PHP
        run: find . -name "*.php" -exec php -l {} \;

      - name: Run PHPStan
        run: vendor/bin/phpstan analyse

      - name: Run PHPUnit Tests
        run: vendor/bin/phpunit

      - name: Deploy (Example)
        run: |
          ssh user@server 'cd /var/www/html && git pull && composer install \
          --no-dev && ./vendor/bin/typo3 cache:flush'
Copied!

Best practices during CI/CD

  1. Version Control Everything
    Include composer.json, composer.lock, config/, packages, and deployment scripts.
  2. Use Environment Variables
    Never hardcode environment-specific values.
  3. Keep Builds Reproducible
    Lock dependencies with composer.lock.
  4. Automate Database Migrations
    Apply migrations as part of the deployment step.
    #. Fail Fast
    Ensure the pipeline stops on errors in quality checks or tests.
    #. Use Staging Environments
    Test changes in staging before promoting to production.