VOOZH about

URL: https://deepwiki.com/rudderlabs/rudder-php-sdk/6-development-guide

⇱ Development Guide | rudderlabs/rudder-php-sdk | DeepWiki


Loading...
Menu

Development Guide

This guide provides contributors with the necessary information to set up their local environment, adhere to coding standards, and follow the release process for the rudder-php-sdk.

The SDK development lifecycle is managed primarily through a Makefile which orchestrates dependency management, linting, and testing to ensure code quality across the supported PHP 7.4+ environments CHANGELOG.md58-60

Local Environment Setup

The SDK uses Composer for dependency management. A Makefile is provided to automate the bootstrapping process and manage local development tasks.

Initialization and Dependencies

To get started, developers can use the following targets:

  • make bootstrap: Runs the initial setup script Makefile1-2
  • make dependencies: Downloads composer.phar and installs all required runtime and development packages Makefile4-11
  • make clean: Removes the vendor directory, lock files, and build artifacts Makefile40-45

For a detailed breakdown of the required PHP extensions and package metadata, see Dependencies and Package Metadata.

Build System Overview

The build system ensures that the environment is consistent for both local development and CI/CD pipelines.

TaskCommandDescription
Installmake dependenciesInstalls Composer and dev tools like phplint and phpcs.
Testmake testsExecutes PHPUnit and generates coverage reports.
Lintmake lintRuns static analysis and style checks.
Verifymake smoke-testRuns a sanity check using the file consumer.

For a complete reference of all available targets and the lifecycle of the build system, see Build System and Makefile.

Sources: Makefile1-45 README.md10-13

Coding Standards and Linting

The project enforces strict coding standards to maintain readability and reduce technical debt. Since version 2.0.0, the codebase has transitioned to PSR-12 standards with strict typing CHANGELOG.md49-52

Standards Configuration

  • PSR-12: The primary coding standard, enforced via phpcs phpcs.xml8-9
  • Slevomat Coding Standard: Used to enforce specific PHP features like declare(strict_types=1), property type hints, and alphabetized imports phpcs.xml15-37
  • Static Analysis: The project uses phplint for syntax checking and phpcs for style enforcement Makefile20-23

Development Workflow Diagram

The following diagram illustrates how the development tools interact with the source code entities.

Code Quality Pipeline


Sources: phpcs.xml1-38 Makefile20-28 phpunit.xml1-40

Release Process

Releases are semi-automated. The process involves updating the version in both the PHP source and the package metadata.

  1. Version Update: The make release command requires a VERSION variable. It performs the following:
    • Updates lib/Version.php with the new version string Makefile31
    • Updates the version field in composer.json using a node script Makefile32
  2. Changelog: All notable changes must be documented in CHANGELOG.md following standard-version guidelines CHANGELOG.md1-3
  3. PR Requirements: Contributors must ensure that any PR passes the checklist, which includes verification across all 4 Consumers and 100% unit test coverage for new code .github/pull_request_template.md9-17

Release Command Entity Mapping


Sources: Makefile29-33 CHANGELOG.md1-61 .github/pull_request_template.md1-21

Security Policy

Security is a high priority. Vulnerabilities should never be reported via public GitHub issues.

  • Reporting: Email security@rudderstack.com for any security concerns SECURITY.md5
  • Supported Versions: Only the latest major.minor version (currently 2.x) is officially supported for security fixes SECURITY.md9-18
  • Automated Checks: The project uses roave/security-advisories to prevent the installation of known vulnerable dependencies CHANGELOG.md54

Sources: SECURITY.md1-21 CHANGELOG.md54