silverbackis / api-components-bundle
Creates a flexible API for a website's structure, reusable components and common functionality.
Package info
github.com/components-web-app/api-components-bundle
Type:symfony-bundle
pkg:composer/silverbackis/api-components-bundle
Requires
- php: >=8.5
- ext-exif: *
- ext-fileinfo: *
- ext-json: *
- ext-pdo: *
- ext-simplexml: *
- api-platform/core: ^4.4 || ^5.0
- cocur/slugify: ^4.7
- doctrine/dbal: ^4.4
- doctrine/doctrine-bundle: ^3.3
- doctrine/doctrine-migrations-bundle: ^3.7 || ^4.0
- doctrine/orm: ^3.7
- imagine/imagine: ^1.5
- lcobucci/clock: ^3.0
- lexik/jwt-authentication-bundle: ^3.2
- liip/imagine-bundle: ^2.17
- nelmio/cors-bundle: ^2.6
- ocramius/package-versions: ^2.12
- phpdocumentor/reflection-docblock: ^5.6 || ^6.0
- ramsey/collection: ^1.3 || ^2.1
- ramsey/uuid: ^4.9
- ramsey/uuid-doctrine: ^2.1
- symfony/asset: ^7.4 || ^8.1
- symfony/console: ^7.4 || ^8.1
- symfony/doctrine-bridge: ^7.4 || ^8.1
- symfony/event-dispatcher: ^7.4 || ^8.1
- symfony/expression-language: ^7.4 || ^8.1
- symfony/form: ^7.4 || ^8.1
- symfony/framework-bundle: ^7.4 || ^8.1
- symfony/mailer: ^7.4 || ^8.1
- symfony/mercure: ^0.7.1 || ^0.8
- symfony/mercure-bundle: ^0.4.3 || ^0.5
- symfony/property-access: ^7.4 || ^8.1
- symfony/property-info: ^7.4 || ^8.1
- symfony/security-bundle: ^7.4 || ^8.1
- symfony/serializer: ^7.4 || ^8.1
- symfony/twig-bundle: ^7.4 || ^8.1
- symfony/type-info: ^7.4 || ^8.1
- symfony/validator: ^7.4 || ^8.1
- symfony/var-exporter: ^7.4 || ^8.1
- twig/cssinliner-extra: ^3.26
- twig/extra-bundle: ^3.29
- twig/inky-extra: ^3.26
- twig/twig: ^3.29
Requires (Dev)
- behat/behat: ^3.33
- behat/mink: ^1.13
- behat/mink-browserkit-driver: ^2.3
- behatch/contexts: dev-master
- dama/doctrine-test-bundle: ^8.6
- doctrine/doctrine-fixtures-bundle: ^4.3
- friends-of-behat/mink-extension: ^2.7.5
- friends-of-behat/symfony-extension: ^2.7
- friendsofphp/php-cs-fixer: ^3.95
- justinrainbow/json-schema: ^5.4
- league/flysystem: ^3.36
- league/flysystem-memory: ^3.31
- monolog/monolog: ^3.12
- phpspec/prophecy: ^1.26
- phpstan/extension-installer: ^1.4
- phpstan/phpdoc-parser: ^2.3
- phpstan/phpstan: ^2.2
- phpstan/phpstan-doctrine: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^13.3
- rector/rector: ^2.6
- roave/security-advisories: dev-master
- symfony/browser-kit: ^7.4 || ^8.1
- symfony/css-selector: ^7.4 || ^8.1
- symfony/dotenv: ^7.4 || ^8.1
- symfony/http-client: ^7.4 || ^8.1
- symfony/maker-bundle: ^1.68
- symfony/messenger: ^7.4 || ^8.1
- symfony/monolog-bundle: ^3.11 || ^4.1
- symfony/phpunit-bridge: ^7.4 || ^8.1
- symfony/stopwatch: ^7.4 || ^8.1
- symfony/web-profiler-bundle: ^7.4 || ^8.1
Suggests
- ext-pdo_mysql: To use MySQL 8.0 or above, or MariaDB 10.10 or above
- ext-pdo_pgsql: To use PostgreSQL 12 or above
- ext-pdo_sqlite: To use SQLite 3.8.3 or above
Provides
None
Conflicts
- doctrine/collections: <1.7
- symfony/serializer: <=6.1.2
- symfony/var-exporter: <6.1
- symfony/web-link: <=6.0
- willdurand/negotiation: ^2
Replaces
None
- dev-main / 2.x-dev
- 2.0.0-alpha.7
- 2.0.0-alpha.6
- 2.0.0-alpha.5
- 2.0.0-alpha.4
- 2.0.0-alpha.3
- 2.0.0-alpha.2
- 2.0.0-alpha.1
- v1.x-dev
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.0.1
- dev-feat/374-liveness-endpoint
- dev-fix/365-null-recipients
- dev-docs/readme-testing
- dev-fix/361-recipient-name-address
- dev-chore/infection-pr-diff
- dev-chore/behat-speed
- dev-fix/357-orphan-descendants
- dev-fix/355-orphan-alert-baseline
- dev-feat/348-orphan-alerts-and-storage
- dev-feat/345-clean-orphaned-uses-detector
- dev-fix/345-page-data-component-match
- dev-fix/350-redirect-alias
- dev-fix/341-344-fixtures
- dev-fix/339-340-user-lookup-and-mailer
- dev-fix/336-user-password-lookup
- dev-feat/319-idempotent-append
- dev-chore/324-phpstan-method-not-found
- dev-fix/331-resend-throttle
- dev-feat/190-orphaned-resources-report
- dev-fix/326-password-reset-token
- dev-fix/323-mapped-superclass-discriminator
- dev-feat/312-health-endpoint
- dev-fix/email-link-host
- dev-fix/313-route-purge-tags
- dev-fix/311-purge-failure
- dev-feat/287-api-platform-5
- dev-fix/286-removed-class-references
- dev-chore/update-dependencies
- dev-fix/283-mercure-publish-failure
- dev-fix/prepend-symfony-listeners
- dev-fix/270-mercure-prod
- dev-fix/276-form-post-full-submit
- dev-fix/278-move-sortvalue-collisions
- dev-fix/253-rename-migration-location
- dev-fix/253-rename-migration-json-match
- dev-fix/254-user-create-violations
- dev-fix/272-ci-network-fetches
- dev-fix/230-live-at-exposure
- dev-fix/content-type-charset-assertions
- dev-worktree-agent-a6e33d822feaa21d1
- dev-feat/orm3
- dev-apip-4
- dev-apip3
- dev-feat/url-generator
- dev-feat/metadata-object
- dev-feature/maker
This package is auto-updated.
Last update: 2026-10-01 10:03:44 UTC
README
PHPUnit Testing Only
Creates a flexible API for a website's structure, reusable components and common functionality.
Read the documentation
Requirements
- PHP 8.5
- Symfony
^7.4 || ^8.1 - API Platform
^4.4 || ^5.0 - Doctrine ORM 3
The bundle code supports Symfony 8. The Behat tooling (behat/behat 3.x, friends-of-behat/mink-extension 2.x) still caps some Symfony components at 7.4 in the test environment only.
Testing
Run everything from the repository root after composer install.
Setting up the test database
The Behat suite creates its own SQLite database on each run. To create one by hand, for example to inspect the schema:
php tests/Functional/app/bin/console -e test doctrine:database:create php tests/Functional/app/bin/console -e test doctrine:schema:create php tests/Functional/app/bin/console -e test doctrine:schema:validate
PHPUnit (unit tests)
php -d memory_limit=512M vendor/bin/phpunit
Unit tests cover pure logic and service wiring. They never boot a kernel: wiring is asserted by loading the bundle's config into a bare ContainerBuilder. Tests that need a database use an in-memory SQLite EntityManager.
Behat (API behaviour)
php -d memory_limit=-1 bin/behat-parallel # the whole suite in concurrent shards (what CI runs) php -d memory_limit=-1 vendor/bin/behat # the whole suite, sequentially php -d memory_limit=-1 vendor/bin/behat features/main/route.feature # one feature
bin/behat-parallel splits the feature files across shards (by default one per CPU, at most 4) and runs them at the same time. Each shard gets its own cache, SQLite database and upload directory (BEHAT_SHARD=<n>, under tests/Functional/app/var/shard-<n>/), so shards can't interfere with each other.
--shards=Nsets the number of shards.--listshows which feature files go to each shard.- Everything after
--is passed to every Behat process, e.g.bin/behat-parallel -- --tags='~@wip'.
The full suite takes about 40 seconds on a 10-core machine, compared with about 100 seconds run sequentially.
If a shard fails but the same feature passes on its own, two scenarios probably depend on the order they run in. Reproduce it sequentially with that shard's files: vendor/bin/behat <files from --list>.
Prefer Behat scenarios for API behaviour and PHPUnit for pure logic. Every new behaviour or bug fix starts with a test that fails first.
Coverage
php -d memory_limit=-1 -d pcov.enabled=1 bin/behat-parallel -- --profile=default-coverage
The shards' coverage is merged into one Clover report at build/logs/behat/clover.xml. CI fails the Behat coverage job if fewer than 1000 statements are covered, and uploads the report to Codecov alongside the PHPUnit coverage.
Mutation testing (Infection)
Infection runs in CI on the PHPUnit coverage job, with a covered-code MSI gate of 80%. It is not a Composer dependency. Download the signed phar at the version pinned in .github/workflows/ci.yml (INFECTION_VERSION) and run it against PHPUnit's coverage:
php -d pcov.enabled=1 vendor/bin/phpunit --configuration=phpunit.coverage.xml.dist \ --coverage-xml=build/logs/phpunit/coverage-xml --log-junit=build/logs/phpunit/junit.xml php infection.phar --coverage=build/logs/phpunit --min-covered-msi=80
In CI, a pull request runs Infection only on the lines it adds or changes in src/ (--git-diff-lines), with the same 80% gate applied to those lines. A PR with no PHP changes passes. Every push to main runs the full mutation set, and only that run updates the Stryker badge.
Infection only scores PHPUnit coverage, so a class covered only by Behat gets no mutation testing. Give new classes unit tests as well.
Static analysis and coding standards
vendor/bin/phpstan analyse --memory-limit=1G # level 5, against phpstan-baseline.neon vendor/bin/php-cs-fixer fix # run before every commit; CI fails on violations
A PHPStan fix that removes a baselined finding must also remove its entry: regenerate the baseline with vendor/bin/phpstan analyse --memory-limit=1G --generate-baseline phpstan-baseline.neon.
What CI runs
Every pull request and every push to main runs these checks:
- Behat on six Symfony and API Platform combinations, including lowest dependencies. Each job runs the suite in 4 shards.
- PHPUnit on four Symfony versions. The Symfony 7.4 job also collects coverage and runs Infection.
- PHPStan, php-cs-fixer and GitGuardian.
- Codecov patch and project coverage.
Sponsors
Contributors ✨
Thanks goes to these wonderful people (emoji key):
Vincent 💻 🤔 👀 |
Pierre Rebeilleau ⚠️ |
Robin Chalas 💻 |
Antoine Bluchet 🐛 |
Maxime Helias 📖 |
This project follows the all-contributors specification. Contributions of any kind are welcome!