Skip to content

Commit 0d5f356

Browse files
authored
feat(laravel): laravel component (api-platform#5882)
* feat(laravel): laravel component * try to skip laravel * feat(jsonapi): component * feat(laravel): json api support (needs review) * work on relations * relations (needs toMany) + skolem + IRI to resource * links handler * ulid * validation * slug post * remove deprecations * move classes * fix tests * fix tests metadata * phpstan * missing class * fix laravel tests * fix stan
1 parent d2e2280 commit 0d5f356

File tree

311 files changed

+95730
-1388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

311 files changed

+95730
-1388
lines changed

.commitlintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
2,
77
"always",
88
[
9+
"laravel",
910
"symfony",
1011
"doctrine",
1112
"metadata",

.github/workflows/ci.yml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ jobs:
177177
run: |
178178
./vendor/bin/phpstan --version
179179
./vendor/bin/phpstan analyse --no-interaction --no-progress --ansi
180+
- name: Install Laravel
181+
run: |
182+
composer api-platform/laravel update
183+
composer api-platform/laravel run-script build
184+
- name: Run PHPStan analysis (laravel)
185+
working-directory: 'src/Laravel'
186+
run: |
187+
./vendor/bin/phpstan analyse --no-interaction --no-progress --ansi
180188
181189
phpunit:
182190
name: PHPUnit (PHP ${{ matrix.php }})
@@ -955,7 +963,7 @@ jobs:
955963
with:
956964
php-version: ${{ matrix.php }}
957965
tools: pecl, composer
958-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
966+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, fileinfo
959967
coverage: none
960968
ini-values: memory_limit=-1
961969
# Not in pecl
@@ -1006,7 +1014,7 @@ jobs:
10061014
with:
10071015
php-version: ${{ matrix.php }}
10081016
tools: pecl, composer
1009-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
1017+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, fileinfo
10101018
coverage: none
10111019
ini-values: memory_limit=-1
10121020
# Not in pecl
@@ -1333,3 +1341,38 @@ jobs:
13331341
name: openapi-docs-php${{ matrix.php }}
13341342
path: build/out/openapi
13351343
continue-on-error: true
1344+
1345+
laravel:
1346+
name: Laravel (PHP ${{ matrix.php }})
1347+
runs-on: ubuntu-latest
1348+
timeout-minutes: 20
1349+
strategy:
1350+
matrix:
1351+
php:
1352+
- '8.2'
1353+
- '8.3'
1354+
include:
1355+
- php: '8.2'
1356+
coverage: true
1357+
- php: '8.3'
1358+
coverage: true
1359+
fail-fast: false
1360+
steps:
1361+
- name: Checkout
1362+
uses: actions/checkout@v4
1363+
- name: Setup PHP
1364+
uses: shivammathur/setup-php@v2
1365+
with:
1366+
php-version: ${{ matrix.php }}
1367+
tools: pecl, composer
1368+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
1369+
ini-values: memory_limit=-1
1370+
- name: Run ${{ matrix.component }} install
1371+
run: |
1372+
composer update
1373+
composer api-platform/laravel update
1374+
- name: PHP version tweaks
1375+
run: |
1376+
composer run-script build
1377+
composer run-script test
1378+
working-directory: 'src/Laravel'

composer.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,17 @@
5252
"friends-of-behat/mink-extension": "^2.2",
5353
"friends-of-behat/symfony-extension": "^2.1",
5454
"guzzlehttp/guzzle": "^6.0 || ^7.0",
55+
"illuminate/config": "^10.0||^11.0",
56+
"illuminate/contracts": "^10.0||^11.0",
57+
"illuminate/database": "^10.0||^11.0",
58+
"illuminate/http": "^10.0||^11.0",
59+
"illuminate/pagination": "^10.0||^11.0",
60+
"illuminate/routing": "^10.0||^11.0",
61+
"illuminate/support": "^10.0||^11.0",
5562
"jangregor/phpstan-prophecy": "^1.0",
5663
"justinrainbow/json-schema": "^5.2.1",
64+
"laravel/framework": "^10.0||^11.0",
65+
"orchestra/testbench": "^8.18",
5766
"phpspec/prophecy-phpunit": "^2.0",
5867
"phpstan/extension-installer": "^1.1",
5968
"phpstan/phpdoc-parser": "^1.13",
@@ -141,7 +150,10 @@
141150
"autoload-dev": {
142151
"psr-4": {
143152
"ApiPlatform\\Tests\\": "tests/",
144-
"App\\": "tests/Fixtures/app/var/tmp/src/"
153+
"App\\": "tests/Fixtures/app/var/tmp/src/",
154+
"Workbench\\App\\": "src/Laravel/workbench/app/",
155+
"Workbench\\Database\\Factories\\": "src/Laravel/workbench/database/factories/",
156+
"Workbench\\Database\\Seeders\\": "src/Laravel/workbench/database/seeders/"
145157
}
146158
},
147159
"config": {
@@ -181,7 +193,9 @@
181193
"api-platform/serializer",
182194
"api-platform/state",
183195
"api-platform/symfony",
184-
"api-platform/validator"
196+
"api-platform/validator",
197+
"api-platform/laravel",
198+
"api-platform/json-api"
185199
]
186200
},
187201
"repositories": [
@@ -202,6 +216,8 @@
202216
{"type": "path", "url": "./src/Serializer"},
203217
{"type": "path", "url": "./src/State"},
204218
{"type": "path", "url": "./src/Symfony"},
205-
{"type": "path", "url": "./src/Validator"}
219+
{"type": "path", "url": "./src/Validator"},
220+
{"type": "path", "url": "./src/Laravel"},
221+
{"type": "path", "url": "./src/JsonApi"}
206222
]
207223
}

phpstan.neon.dist

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ parameters:
1616
- src/Symfony/Bundle/Test/Constraint/ArraySubset.php
1717
- tests/Fixtures/app/AppKernel.php
1818
excludePaths:
19+
# uses larastan
20+
- src/Laravel
1921
- src/Symfony/Bundle/Command/OpenApiCommand.php
2022
# Symfony config
2123
- tests/Fixtures/app/config/config_swagger.php
@@ -86,7 +88,7 @@ parameters:
8688
# Expected, due to backward compatibility
8789
-
8890
message: "#Call to function method_exists\\(\\) with ApiPlatform\\\\JsonApi\\\\Serializer\\\\ItemNormalizer and 'setCircularReferenc…' will always evaluate to false\\.#"
89-
path: tests/JsonApi/Serializer/ItemNormalizerTest.php
91+
path: src/JsonApi/Tests/Serializer/ItemNormalizerTest.php
9092
- '#Method GraphQL\\Type\\Definition\\WrappingType::getWrappedType\(\) invoked with 1 parameter, 0 required\.#'
9193
- '#Access to an undefined property GraphQL\\Type\\Definition\\NamedType&GraphQL\\Type\\Definition\\Type::\$name\.#'
9294
# See https://github.com/phpstan/phpstan-symfony/issues/27
@@ -99,5 +101,4 @@ parameters:
99101
# Backward compatibility
100102
- '#Call to method hasCacheableSupportsMethod\(\) on an unknown class Symfony\\Component\\Serializer\\Normalizer\\CacheableSupportsMethodInterface\.#'
101103
- '#Class Symfony\\Component\\Serializer\\Normalizer\\CacheableSupportsMethodInterface not found\.#'
102-
- '#Access to undefined constant Symfony\\Component\\HttpKernel\\HttpKernelInterface::MASTER_REQUEST\.#'
103104
- '#Attribute class PHPUnit\\Framework\\Attributes\\DataProvider does not exist.#'

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
</include>
2929
<exclude>
3030
<directory>src/Symfony/Maker/Resources/skeleton</directory>
31+
<directory>src/Laravel</directory>
3132
<directory>features</directory>
3233
<directory>tests</directory>
3334
<directory>vendor</directory>

src/Action/NotExposedAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace ApiPlatform\Action;
1515

16-
use ApiPlatform\Exception\NotExposedHttpException;
16+
use ApiPlatform\Metadata\Exception\NotExposedHttpException;
1717
use Symfony\Component\HttpFoundation\Request;
1818

1919
/**

src/Api/CompositeIdentifierParser.php

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)