Project Documentation
The project has documentation on different levels:
- Markdown files in the
documentationdirectory - API documentation that PHPDoc generates in the
/web/landing/build/documentation/directory - Usage examples in the
web/landing/content/examplesdirectory, in groups by topic
Project structure
This project is a monorepo. One repository contains many packages. The structure of the project is:
├── bin
├── build
├── documentation
├── phpdoc
├── src
│ ├── adapter
│ ├── bridge
│ ├── cli
│ ├── core
│ ├── extension
│ ├── lib
│ └── tools
├── tools
├── var
├── vendor
└── web
└── landing
bincontains the executable scripts for development.buildcontains the build artifact. At this time, this is only the PHAR file. To build the PHAR file, runjust phar.documentationcontains the documentation files of the full project and of each package. The documentation website is generated from these markdown files, which are converted into html.phpdoccontains the phpDocumentor XML configuration.just docs-apigenerates the API documentation intoweb/landing/build/documentation/api/.srccontains the source code of the project, in these packages:adapterpackages give implementations of the DataFrame building blocks, for exampleExtractor,LoaderandTransformer.bridgecontains bridges that connect flow libs with other libraries and frameworks.clicontains the command line interface application.corecontains the core of the project. It holds the full DataFrame.extensioncontains PHP extensions in other languages (Rust, C) for the parts where performance is critical.libcontains standalone libraries that you can use without the rest of the project, for exampledoctrine-dbal-bulkandparquet.toolscontains tools for development.
toolscontains tools for development, for examplemagoandphpunit. They are outside of the project dependencies, so they do not add classes to the project autoloader.varcontains temporary files, for example cache and logs.vendorcontains the dependencies of the project. Composer manages them.weblandingcontains the landing page of the project. It is a symfony application. The build dumps it to static HTML files, and GitHub Pages serves them. It has its own composer.json with the dependencies for the landing page and its commands.
Monorepo packages
All packages have almost the same structure:
src/core
└── etl
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── composer.json
├── src
│ └── Flow
└── tests
└── Flow
Tests are usually in two groups:
Unit:src/core/etl/tests/Flow/ETL/Tests/UnitIntegration:src/core/etl/tests/Flow/ETL/Tests/Integration
Some packages also have test helpers on that level, for example:
Doubles: mocks, stubs and fakes that many tests use
Packages Dependencies
Keep the number of dependencies as small as possible. When you add a dependency, make its version constraint as wide as possible, so that our constraints do not block other projects.
Packages from this monorepo can depend on each other, with strict rules:
lib: libraries can depend only on otherlibpackages, never on anything else.adapter: adapters can depend onlib/bridge, and they always depend oncore. Adapters must not depend oncli.bridge: bridges can depend only onlib.cli: CLI can depend oncore,lib,adapterandbridge.clialways depends oncore.core: core can depend onliborbridge. It must never depend onadapterorcli.
These rules also apply to namespaces. For example, the CSV adapter cannot depend on the Parquet adapter.
PHP Versions
This project supports only the latest three PHP versions, at this time 8.3, 8.4 and 8.5. Development uses the lowest supported version, at this time PHP 8.3. The tests run on all three versions, so you can use any of them for development.
Tools
The project uses different tools for development, tests and builds.
Each tool has a just recipe. Run just --list to see all available tasks.
just lintruns all linters:lint-mago(Mago format check and lint),lint-monorepo(monorepo validation) andlint-actions(GitHub Actions audit).just analyzerunsmago guardand the Mago static analysis.just fixruns Mago to fix coding standard and lint issues in the code.just testruns all tests in the project. To run fewer tests, give phpunit arguments, for examplejust test --testsuite=lib-parquet-unitorjust test --filter=my_test_method. To see the available testsuites, runtools/phpunit/vendor/bin/phpunit --list-suites.just test-websiteruns the tests for the website.just test-mutationruns the mutation tests, which measure the quality of the tests.just buildruns the full pipeline: lint + analyze + tests + mutation tests.
Coding Standards
The full project is object oriented code that follows clean code principles. Mago defines the coding standards and enforces them.
Each package has a DSL (Domain Specific Language), a functional API that is easy to use.
All DSL functions (usually in functions.php files) follow the same coding standards as the other PHP code.
DSL function names and arguments use snake_case. The only other place that uses snake_case is the tests, for test
method names.
To make sure that the full project follows the coding standards, run these commands:
just fix
just lint
just analyze
Commit your changes only after all three commands pass.
Testing
- The tests in the project are in two groups:
Unittests one behavior in isolation, without dependencies.Integrationtests one behavior with dependencies, for example a database or external services.
- The test cases of all packages must extend the
\Flow\ETL\Tests\FlowTestCaseclass. The only exceptions are thelibandbridgepackages, which can use their own test cases. - Each test method tests only one scenario. To test one behavior with different input data, use the
PHPUnit\Framework\Attributes\TestWithorPHPUnit\Framework\Attributes\DataProviderattributes.
Found a typo or an outdated section? Edit this page on GitHub