Skip to main content

Extracting Lineage from Doctrine (ORM for PHP)

Updated over a week ago

Introduction

Doctrine is a powerful PHP ORM (Object-Relational Mapping) library that simplifies database interactions by mapping PHP objects to database tables. It enables developers to perform database operations without writing complex SQL, which leads to more maintainable and scalable code. Doctrine also offers direct database access through its Database Abstraction Layer (DBAL) for cases where more granular control is required.


Why this framework matters in your data stack

Doctrine often serves as the backbone for managing operational databases. In modern data workflows, these databases may feed into data warehouses such as BigQuery or Snowflake through ETL pipelines like Fivetran. Once the data lands in the warehouse, it is transformed with tools such as dbt and later consumed by BI tools like Tableau or by data science teams.

Changes made to upstream Doctrine entities can ripple through the entire data stack, affecting everything from BI dashboards to machine-learning workflows. Downstream teams must be aware of these changes so they can take appropriate steps to avoid data-quality issues.


How Foundational analyzes this framework

Foundational automates the extraction of schema and lineage information directly from Doctrine code. This approach allows users to preview changes during the development phase, including in pending Pull Requests, and evaluate potential downstream effects before deployment.


Foundational’s process to extract schema and lineage

Foundational uses a different approach compared to traditional database-based schema extraction.

Foundational’s Code Engine scans repositories to detect Doctrine definitions, such as dcm.yml files. It processes these files to extract relevant information, including table names, column names, column types, and other metadata from the definitions.

See this example of Doctrine definitions. Foundational analyzes this YAML file, extracts the definitions and creates the correct schema.

Example of Doctrine definitions

Example of Doctrine definitions


​Advantages of Foundational’s approach

Unlike traditional applications that pull schema information from databases after deployment, Foundational extracts Doctrine schema directly from the codebase. This approach allows teams to evaluate the downstream impact and prevent breaking changes even before a change is made. This allows teams to avoid data incidents and maintain high data quality.

If the engineering team changes the operational database in a way that may break downstream processing, Foundational detects the potential issue and alerts both the engineering team and the data engineering team. They can then prevent the breaking change by fixing the issue or by updating downstream consumers so they can handle the new structure.


Set up Doctrine lineage in Foundational

To set up Doctrine lineage in Foundational, connect the repository that contains your Doctrine entity definitions. Once connected, Foundational’s Code Engine automatically detects the Doctrine schema files and extracts the structure, lineage, and metadata required for impact analysis.

To connect to your source control, check out the relevant How-to article from the Help Center Connectors and Integrations category.

No additional configuration is required.


Useful links

Did this answer your question?