Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 35 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
composer global require soyuka/pmu
composer global config allow-plugins.soyuka/pmu true --no-interaction
composer global link .
composer require --dev doctrine/mongodb-odm-bundle
- run: composer check-dependencies

php-cs-fixer:
Expand Down Expand Up @@ -89,7 +90,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
extensions: intl, bcmath, curl, openssl, mbstring
ini-values: memory_limit=-1
tools: composer
coverage: none
Expand Down Expand Up @@ -149,6 +150,7 @@ jobs:
composer global require soyuka/pmu
composer global config allow-plugins.soyuka/pmu true --no-interaction
composer global link .
composer require --dev doctrine/mongodb-odm-bundle
- name: Cache PHPStan results
uses: actions/cache@v4
with:
Expand Down Expand Up @@ -200,7 +202,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
coverage: pcov
ini-values: memory_limit=-1
- name: Get composer cache directory
Expand All @@ -217,6 +219,9 @@ jobs:
composer global require soyuka/pmu
composer global config allow-plugins.soyuka/pmu true --no-interaction
composer global link .
- name: Force PHPUnit 11.5 for PHP 8.2
if: matrix.php == '8.2'
run: composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run PHPUnit tests
Expand Down Expand Up @@ -288,12 +293,17 @@ jobs:
with:
php-version: ${{ matrix.php.version }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
ini-values: memory_limit=-1
- name: PMU
run: |
composer global require soyuka/pmu
composer global config allow-plugins.soyuka/pmu true --no-interaction
- name: Force PHPUnit 11.5 for PHP 8.2
if: matrix.php.version == '8.2'
run: |
cd $(composer ${{matrix.component}} --cwd)
composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies
- name: Linking
if: ${{ !matrix.php.lowest && !matrix.php.minimal-changes }}
run: |
Expand Down Expand Up @@ -368,7 +378,7 @@ jobs:
with:
php-version: ${{ matrix.php.version }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
ini-values: memory_limit=-1
- name: Linking
run: |
Expand Down Expand Up @@ -408,7 +418,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
coverage: pcov
ini-values: memory_limit=-1
- name: Get composer cache directory
Expand All @@ -425,6 +435,9 @@ jobs:
composer global require soyuka/pmu
composer global config allow-plugins.soyuka/pmu true --no-interaction
composer global link .
- name: Force PHPUnit 11.5 for PHP 8.2
if: matrix.php == '8.2'
run: composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run Behat tests (PHP ${{ matrix.php }})
Expand Down Expand Up @@ -492,7 +505,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_pgsql, mongodb
extensions: intl, bcmath, curl, openssl, mbstring, pdo_pgsql
coverage: none
ini-values: memory_limit=-1
- name: Get composer cache directory
Expand Down Expand Up @@ -543,7 +556,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_mysql, mongodb
extensions: intl, bcmath, curl, openssl, mbstring, pdo_mysql
coverage: none
ini-values: memory_limit=-1
- name: Get composer cache directory
Expand Down Expand Up @@ -825,7 +838,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
extensions: intl, bcmath, curl, openssl, mbstring
coverage: none
ini-values: memory_limit=-1
- name: Get composer cache directory
Expand Down Expand Up @@ -878,7 +891,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
extensions: intl, bcmath, curl, openssl, mbstring
coverage: none
ini-values: memory_limit=-1
- name: Get composer cache directory
Expand Down Expand Up @@ -918,7 +931,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
extensions: intl, bcmath, curl, openssl, mbstring
coverage: none
ini-values: memory_limit=-1
- name: Get composer cache directory
Expand Down Expand Up @@ -957,7 +970,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
extensions: intl, bcmath, curl, openssl, mbstring
coverage: none
ini-values: memory_limit=-1
- name: Get composer cache directory
Expand Down Expand Up @@ -1000,7 +1013,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
extensions: intl, bcmath, curl, openssl, mbstring
coverage: none
ini-values: memory_limit=-1
- name: Install additional packages
Expand Down Expand Up @@ -1048,7 +1061,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, fileinfo, mongodb
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, fileinfo
coverage: none
ini-values: memory_limit=-1
- name: Get composer cache directory
Expand Down Expand Up @@ -1098,7 +1111,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
extensions: intl, bcmath, curl, openssl, mbstring
coverage: none
ini-values: memory_limit=-1
- name: Get composer cache directory
Expand Down Expand Up @@ -1142,7 +1155,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
extensions: intl, bcmath, curl, openssl, mbstring
coverage: none
ini-values: memory_limit=-1
- name: Install additional packages
Expand Down Expand Up @@ -1314,7 +1327,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
ini-values: memory_limit=-1
- name: Setup node
uses: actions/setup-node@v4
Expand Down Expand Up @@ -1369,8 +1382,12 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
ini-values: memory_limit=-1
- name: Force PHPUnit 11.5 for PHP 8.2
if: matrix.php == '8.2'
working-directory: 'src/Laravel'
run: composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies
- name: Update project dependencies
run: |
composer global require soyuka/pmu
Expand All @@ -1395,7 +1412,7 @@ jobs:
with:
php-version: 8.4
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
ini-values: memory_limit=-1
- name: Update project dependencies
run: |
Expand Down
47 changes: 47 additions & 0 deletions CRUSH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# API Platform Core Development

This document provides guidelines for developing on the API Platform core.

## Laravel development:

Everything goes inside `src/Laravel`.
Tests need to run at `src/Laravel/vendor/bin/phpunit`.

## Development Commands

- **Run all tests:**
```bash
vendor/bin/phpunit
```

- **Run a single test file:**
```bash
vendor/bin/phpunit tests/Path/To/YourTest.php
```

- **Lint files:**
```bash
vendor/bin/php-cs-fixer fix --dry-run --diff
```

- **Fix linting issues:**
```bash
vendor/bin/php-cs-fixer fix
```

- **Run static analysis:**
```bash
vendor/bin/phpstan analyse
```

## Code Style

- **Standard:** Follow PSR-12 and the rules in `.php-cs-fixer.dist.php`.
- **Imports:** Use `use` statements for all classes, and group them by namespace.
- **Naming:**
- Classes: `PascalCase`
- Methods: `camelCase`
- Variables: `camelCase`
- **Types:** Use strict types (`declare(strict_types=1);`) in all PHP files. Use type hints for all arguments and return types where possible.
- **Error Handling:** Use exceptions for error handling.

39 changes: 39 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# To run this make sure you have php zts installed
# In the `php.ini` set output_buffering = Off (or else you may not get the same measures)
# Run `php-fpm -F` (it should default to 127.0.0.1:9000)
# Run `frankenphp start --config Caddyfile` (do not use `run` or printing in the terminal will slow down the server)
# You now have 2 servers:
# - localhost:8080 with PHP FPM
# - localhost:8081 with FrankenPHP
#
# Note that with no worker mode the performances on HTTP Request (sequentially !) will be likely the same.
{
frankenphp
}

localhost:8080 {
header {
Access-Control-Allow-Origin *
Access-Control-Allow-Credentials true
Access-Control-Allow-Methods *
Access-Control-Allow-Headers *
defer
}
root * public/
php_fastcgi 127.0.0.1:9000
file_server
}

localhost:8081 {
header {
Access-Control-Allow-Origin *
Access-Control-Allow-Credentials true
Access-Control-Allow-Methods *
Access-Control-Allow-Headers *
defer
}
root * public/
file_server
log
php_server
}
38 changes: 38 additions & 0 deletions GEMINI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
You are a code assistant that only writes tests on the API Platform code base. You do not need to fix bugs only write the test we ask for. You do not need to run the test.

Language is PHP, project is API Platform. User will always specify either Symfony or Laravel as tests are not in the same directories.

IMPORTANT: avoid changing existing fixtures as they may alter current tests behavior. If a fixture already exist just invent new names, we don't really care about business logic here we only do tests for a framework.

# API Platform Core Development

This document provides guidelines for developing on the API Platform core.

## Laravel development:

Everything goes inside `src/Laravel`.
Tests need to run at `src/Laravel/vendor/bin/phpunit`.
Fixtures are located at `src/Laravel/workbench/app/` you can either write a DTO as ApiResource inside the `ApiResource` directory in the workbench, or add an Eloquent `Model` that gets declared as a resource with the correct attribute.

You'll add only functional testing inside `src/Laravel/Tests/`, we recommend to inspire from @src/Laravel/Tests/EloquentTest.php or @src/Laravel/Tests/JsonLdTest.php.

## Symfony development:

Fixtures are located at `tests/Fixtures/TestBundle/ApiResource/`
Entities at `tests/Fixtures/TestBundle/Entity/` and they almost always see their equivalent in `tests/Fixtures/TestBundle/Document/`
Functional tests at `tests/Functional`, unit tests are in more specific directories of each component inside `src/Component/Tests`.

## Development Commands

You can not run command only the user can. Don't attempt to run phpunit or else.

## Code Style

- **Standard:** Follow PSR-12 and the rules in `.php-cs-fixer.dist.php`.
- **Imports:** Use `use` statements for all classes, and group them by namespace.
- **Naming:**
- Classes: `PascalCase`
- Methods: `camelCase`
- Variables: `camelCase`
- **Types:** Use strict types (`declare(strict_types=1);`) in all PHP files. Use type hints for all arguments and return types where possible.
- **Error Handling:** Use exceptions for error handling.
11 changes: 2 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,11 @@
"willdurand/negotiation": "^3.1"
},
"require-dev": {
"ext-mongodb": "^1.21 || ^2.0",
"behat/behat": "^3.11",
"behat/mink": "^1.9",
"doctrine/cache": "^1.11 || ^2.1",
"doctrine/common": "^3.2.2",
"doctrine/dbal": "^4.0",
"doctrine/doctrine-bundle": "^2.11 || ^3.1",
"doctrine/mongodb-odm": "^2.10",
"doctrine/mongodb-odm-bundle": "^5.0",
"doctrine/orm": "^2.17 || ^3.0",
"elasticsearch/elasticsearch": "^7.17 || ^8.4 || ^9.0",
"friends-of-behat/mink-browserkit-driver": "^1.3.1",
Expand All @@ -156,7 +152,7 @@
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "11.5.x-dev",
"phpunit/phpunit": "^12.2",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"ramsey/uuid": "^4.7",
"ramsey/uuid-doctrine": "^2.0",
Expand Down Expand Up @@ -216,8 +212,5 @@
"symfony/json-streamer": "To use the JSON Streamer component.",
"webonyx/graphql-php": "To support GraphQL."
},
"type": "library",
"repositories": [
{"type": "vcs", "url": "https://github.com/soyuka/phpunit"}
]
"type": "library"
}
Loading
Loading