codeliner/php-ddd-cargo-sample
48.8
Weak · 20 September 2026
17k
lines of production code
JavaScript
with PHP
4
measurements over time
What this system is
This system is a PHP-based cargo tracking and shipping application built on the Zend Expressive framework with a Doctrine ORM persistence layer. It manages the end-to-end lifecycle of cargo shipments, including booking, route specification, and itinerary assignment, while delegating complex graph traversal for route calculation to an external service. The architecture features a PSR-15 middleware stack, immutable domain models, and a Riot.js single-page interface for user interaction.
How it got here
2013 — PHP 7 DDD Cargo Sample initial release
8 changes.
This period marks the initial release of the PHP 7 port of the DDD Cargo sample application, built on the Zend Expressive framework with Docker and CI support. The work established the core architecture, including PSR-7/PSR-15 middleware, Doctrine ORM persistence, and a Riot.js frontend, alongside comprehensive Behat test coverage for cargo booking workflows.
2015–2016 — Domain-driven architecture and UI rewrite
12 changes.
The project established a core domain-driven architecture for cargo tracking, introducing immutable DTOs, Doctrine-based persistence, and an external graph traversal service for route calculation. Simultaneously, the frontend was rebuilt as a Riot.js single-page application to support booking and shipment management, while the backend infrastructure was standardized on PSR-11 and PSR-15 interfaces.
Features
Added Apache rewrite rules and Bootstrap 3 CSS assets
The public directory now includes an .htaccess file that configures Apache to serve existing files directly and rewrite all other requests to index.php, enabling a single-page application routing structure. Additionally, Bootstrap 3 CSS files (including theme and minified variants) have been added to provide the frontend styling foundation.
public · high confidence
Added dedicated CLI entry point for Doctrine Migrations
The application now includes a dedicated \bin/migrations.php\ script to manage database schema changes. This entry point bootstraps the environment, loads the dependency injection container, and registers the full suite of Doctrine DBAL Migrations console commands (such as migrate, diff, and status), providing a standardized way for users to execute database migrations from the command line.
bin · high confidence
Initial Graph Traversal Backend for Route Calculation
Introduces the GraphTraversalBackend module, which provides the core logic for finding transit paths between locations. This includes the GraphTraversalService that processes route specifications to return lists of TransitPathDto objects containing EdgeDto details (origin, destination, and ISO8601 timestamps). The service is wired via a PSR-11 compliant factory (GraphTraversalServiceFactory) that injects itinerary configuration, and is supported by unit tests verifying the correct generation of multi-stop transit paths.
GraphTraversalBackend · high confidence
Initial Zend Expressive application configuration
The application has been migrated to the Zend Expressive framework, introducing a new configuration structure in \config/autoload\. This includes dependency injection definitions for application actions (such as booking and cargo management), infrastructure services (Doctrine ORM, routing), and UI components, alongside pipeline middleware setup for error handling and routing. The configuration also defines global data for shipping locations and itineraries, and provides a local development template with database connection details and debug settings.
config/autoload · high confidence
Initial Zend Expressive configuration and Behat test setup
The application is now configured using the Zend Expressive framework, introducing a new configuration structure in the \config/\ directory. This includes \config.php\ for merging global and local settings with optional caching, \container.php\ for dependency injection via Zend ServiceManager, \pipeline.php\ defining the middleware stack (including JSON payload handling and routing), and \routes.php\ which registers API endpoints for managing cargos (GET, POST, PUT) and locations. Additionally, Behat testing infrastructure is added with \behat.yml.dist\ and \behat.yml.travis\ to configure feature suites and Mink sessions for browser-based testing.
config · high confidence
Initial release of PHP 7 DDD Cargo Sample with Docker and CI support
This commit introduces the initial codebase for the PHP 7 port of the DDD Cargo sample, featuring a PSR-7/PSR-15 middleware layer built on zend-expressive, Doctrine ORM for persistence, and a Riot.js single-page UI. It includes configuration for Docker Compose (nginx, PHP-FPM, MariaDB, Adminer), Travis CI integration for PHP 7.1 with Behat and PHPUnit testing, and environment variable definitions for local development ports.
(repo-wide) · high confidence
Introduce Riot.js tag compilation and main UI middleware
The CargoUI application layer now includes a new Main middleware that serves the HTML5 layout, optionally caching the compiled output to improve response times. It relies on a new RiotCompiler component to process .html files from the view/riot directory, extracting embedded JavaScript functions and HTML templates to generate valid riot.tag() statements for the client-side single-page application.
CargoUI/src · high confidence
Introduce core Cargo domain model and routing interface
The CargoBackend/src/Model directory now contains the foundational domain classes for the cargo tracking system. This includes the central Cargo entity, which manages tracking IDs, origins, route specifications, and itineraries, along with supporting value objects like Itinerary, Leg, RouteSpecification, and TrackingId (backed by UUIDs). A CargoRepositoryInterface is provided for persistence operations, and a RoutingServiceInterface defines the contract for fetching route candidates based on a specification.
CargoBackend/src/Model · high confidence
Behavioural changes
Added database migration for the cargo table
A new database migration (Version20151206122755) has been added to create the 'cargo' table on MySQL. This table stores shipment details including a unique tracking ID, origin, route information, and itinerary legs, enabling the application to persist cargo data in the database.
migrations · high confidence
HTTP actions now implement PSR-15 RequestHandlerInterface
The HTTP action classes in CargoBackend/src/Http/Action (CreateCargo, GetCargo, GetCargos, GetLocations, GetRouteCandidates, UpdateCargo) have been refactored to implement the PSR-15 RequestHandlerInterface. This changes how these endpoints handle requests, moving from any previous custom handling mechanism to the standard PSR-15 interface, which affects how they are routed and executed within the application's HTTP middleware stack.
CargoBackend/src/Http · high confidence
Integration with external graph traversal service for route calculation
The routing infrastructure now delegates route finding to an external Graph Traversal service. A new ExternalRoutingService class implements the RoutingServiceInterface, translating domain RouteSpecification objects into requests for the external API and mapping the returned transit paths back into domain Itinerary and Leg objects. This replaces any previous local or stubbed routing logic with a dependency on the external graph traversal context.
CargoBackend/src/Infrastructure/Routing · high confidence
Introduces Doctrine-based persistence for Cargo tracking
The CargoBackend now persists Cargo entities using Doctrine ORM, replacing the previous storage mechanism. This change adds a Doctrine-specific repository (DoctrineCargoRepository) and mapping files for the Cargo, Itinerary, and RouteSpecification models. It also introduces custom Doctrine types to handle TrackingId (via UUID) and Itinerary Legs (serialized as JSON), and provides a new TransactionManager implementation to wrap database operations in transactions.
CargoBackend/src/Infrastructure/Persistence · high confidence
Introduction of MainFactory for dependency injection
A new MainFactory class has been added to the Container component to facilitate the creation of the Main application instance. This factory implements the PSR-11 ContainerInterface contract, allowing it to be used as a service factory within the application's dependency injection container. It retrieves configuration settings for view caching and layout paths, and injects a RiotCompiler instance, ensuring that the Main object is constructed with the necessary dependencies in a standardized way.
CargoUI/src/Container · high confidence
Migrated service factories to PSR-11 container interface
The application's dependency injection factories have been refactored to implement the PSR-11 \\_\_invoke\ pattern, replacing previous instantiation methods. This change updates the factory classes for the Booking service, Transaction Manager, Doctrine Entity Manager, and various repositories to accept a \Psr\\Container\\ContainerInterface\, ensuring compatibility with modern PSR-11 compliant containers and preparing the codebase for the Expressive 2.0 framework upgrade.
CargoBackend/src/Infrastructure/Container · high confidence
New Riot.js-based booking interface for cargo shipping
The CargoUI view layer has been replaced with a new single-page application built on Riot.js and Bootstrap. Users can now book new cargo by selecting origin and destination locations, view a list of all cargo shipments, inspect individual cargo details including assigned itineraries, and assign new cargo to suggested route candidates. The interface manages state via Flux-style stores and handles client-side routing between the home page, the booking application, and specific cargo actions.
CargoUI/view · high confidence
Refactored application layer with immutable DTOs and transaction management
The application layer in CargoBackend/src/Application has been restructured to use immutable Data Transfer Objects (DTOs) and a dedicated transaction manager. New classes include CargoRoutingDto, LegDto, LocationDto, and RouteCandidateDto, which replace previous mutable structures to ensure data integrity. Assembler classes (CargoRoutingDtoAssembler, RouteCandidateDtoAssembler) handle the conversion between domain models and these DTOs. The BookingService now relies on the new TransactionManager interface to wrap operations like booking new cargo and assigning routes in explicit transaction blocks (begin/commit/rollback), improving reliability. Exception handling is also standardized with a new CargoNotFoundException and ApiException marker interface.
CargoBackend/src/Application · high confidence
Test coverage
Add feature test for booking new cargo; Initial Behat feature test context for cargo booking; Initial unit and integration test suite for CargoBackend.
Dependencies
Upgrade to Zend Expressive 3 and PHP 7.1
The application dependencies have been updated to require PHP 7.1 and upgrade the core framework to Zend Expressive 3.2. This change also introduces several supporting library updates, including Doctrine ORM 2.5.11, Doctrine Migrations 1.5, and the adoption of PSR-15 middleware standards via psr/http-server-middleware 1.0. Development tooling has been adjusted to use Behat 3.0 and PHPUnit 5.0, while security monitoring is enabled via the roave/security-advisories package.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 55 → 49 (-6.3)
- Rubric changed (rubric-2026.08.17 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 99 → 99 (-0.1)
- Architecture 100 → 97 (-3.2)
- Maturity 72 → 76 (+4.1)
- Readiness 51 → 41 (-10.6)
- Security 100 → 94 (-6.0)
- Accessibility 38 → 31 (-7.9)
Resolved (7)
- Coverage not included — suite not readable by the collector
- Dependency hygiene not measured — no supported dependency manifest was read
- Duplicated block (13 lines × 2) (GraphTraversalBackend/src/GraphTraversalService.php)
- LLM evaluation failed
- No exposed public API
- Test reliability not included
- dormant codebase — no living knowledge left to concentrate
New (23)
- Abandoned package: zendframework/zend-config
- Abandoned package: zendframework/zend-config-aggregator
- Abandoned package: zendframework/zend-diactoros
- Abandoned package: zendframework/zend-expressive
- Abandoned package: zendframework/zend-expressive-aurarouter
- Abandoned package: zendframework/zend-servicemanager
- Abandoned package: zendframework/zend-stdlib
- Critical CVE: [GHSA redacted] (composer.lock)
- Documentation: no installation or build instructions (README.md)
- Duplicated block (10 lines × 2) (GraphTraversalBackend/src/GraphTraversalService.php)
- Duplicated block (16 lines × 2) (CargoBackend/src/Infrastructure/Persistence/Doctrine/DoctrineORMTransactionManager.php)
- High CVE: [GHSA redacted] (composer.lock)
- High CVE: [GHSA redacted] (composer.lock)
- High IaC: WD-COMPOSE-0002 (docker-compose.yml)
- Low CVE: [GHSA redacted] (composer.lock)
- Low CVE: [GHSA redacted] (composer.lock)
- Medium CVE: [GHSA redacted] (composer.lock)
- Medium CVE: [GHSA redacted] (composer.lock)
- Medium IaC: WD-COMPOSE-0002 (docker-compose.yml)
- Medium IaC: WD-COMPOSE-0002 (docker-compose.yml)
- …and 3 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
codeliner/php-ddd-cargo-sample was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 32315bd10eca3c359f28cb764c20cf13664bc729 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-28e75b8e3254.