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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"api-platform/http-cache": "self.version",
"api-platform/hydra": "self.version",
"api-platform/json-api": "self.version",
"api-platform/json-hal": "self.version",
"api-platform/hal": "self.version",
"api-platform/json-schema": "self.version",
"api-platform/jsonld": "self.version",
"api-platform/laravel": "self.version",
Expand Down Expand Up @@ -146,7 +146,7 @@
"illuminate/routing": "^11.0 || ^12.0",
"illuminate/support": "^11.0 || ^12.0",
"jangregor/phpstan-prophecy": "^2.1.11",
"justinrainbow/json-schema": "^5.2.11",
"justinrainbow/json-schema": "5.3.0",
"laravel/framework": "^11.0 || ^12.0",
"orchestra/testbench": "^9.1",
"phpspec/prophecy-phpunit": "^2.2",
Expand Down
29 changes: 29 additions & 0 deletions src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
use ApiPlatform\Symfony\Validator\Metadata\Property\Restriction\PropertySchemaRestrictionMetadataInterface;
use ApiPlatform\Symfony\Validator\ValidationGroupsGeneratorInterface;
use ApiPlatform\Validator\Exception\ValidationException;
use Composer\InstalledVersions;
use Doctrine\Persistence\ManagerRegistry;
use PHPStan\PhpDocParser\Parser\PhpDocParser;
use Ramsey\Uuid\Uuid;
Expand Down Expand Up @@ -635,6 +636,10 @@ private function registerJsonApiConfiguration(array $formats, PhpFileLoader $loa
return;
}

if (!InstalledVersions::isInstalled('api-platform/json-api')) {
throw new \LogicException('JSON-API support cannot be enabled as the JSON-API component is not installed. Try running "composer require api-platform/json-api".');
}

$loader->load('jsonapi.php');
$loader->load('state/jsonapi.php');
}
Expand Down Expand Up @@ -666,6 +671,10 @@ private function registerJsonHalConfiguration(array $formats, PhpFileLoader $loa
return;
}

if (!InstalledVersions::isInstalled('api-platform/hal')) {
throw new \LogicException('HAL support cannot be enabled as the HAL component is not installed. Try running "composer require api-platform/hal".');
}

$loader->load('hal.php');
}

Expand Down Expand Up @@ -738,6 +747,10 @@ private function registerDoctrineOrmConfiguration(ContainerBuilder $container, a
return;
}

if (!InstalledVersions::isInstalled('api-platform/doctrine-orm')) {
throw new \LogicException('Doctrine support cannot be enabled as the doctrine ORM component is not installed. Try running "composer require api-platform/doctrine-orm".');
}

// For older versions of doctrine bridge this allows autoconfiguration for filters
if (!$container->has(ManagerRegistry::class)) {
$container->setAlias(ManagerRegistry::class, 'doctrine');
Expand Down Expand Up @@ -770,6 +783,10 @@ private function registerDoctrineMongoDbOdmConfiguration(ContainerBuilder $conta
return;
}

if (!InstalledVersions::isInstalled('api-platform/doctrine-odm')) {
throw new \LogicException('Doctrine MongoDB ODM support cannot be enabled as the doctrine ODM component is not installed. Try running "composer require api-platform/doctrine-odm".');
}

$container->registerForAutoconfiguration(AggregationItemExtensionInterface::class)
->addTag('api_platform.doctrine_mongodb.odm.aggregation_extension.item');
$container->registerForAutoconfiguration(AggregationCollectionExtensionInterface::class)
Expand Down Expand Up @@ -879,6 +896,10 @@ private function registerMercureConfiguration(ContainerBuilder $container, array
return;
}

if (!InstalledVersions::isInstalled('symfony/mercure-bundle')) {
throw new \LogicException('Mercure support cannot be enabled as the Symfony Mercure Bundle is not installed. Try running "composer require symfony/mercure-bundle".');
}

$container->setParameter('api_platform.mercure.include_type', $config['mercure']['include_type']);
$loader->load('state/mercure.php');

Expand All @@ -900,6 +921,10 @@ private function registerMessengerConfiguration(ContainerBuilder $container, arr
return;
}

if (!InstalledVersions::isInstalled('symfony/messenger')) {
throw new \LogicException('Messenger support cannot be enabled as the Symfony Messenger component is not installed. Try running "composer require symfony/messenger".');
}

$loader->load('messenger.php');
}

Expand All @@ -913,6 +938,10 @@ private function registerElasticsearchConfiguration(ContainerBuilder $container,
return;
}

if (!InstalledVersions::isInstalled('api-platform/elasticsearch')) {
throw new \LogicException('Elasticsearch support cannot be enabled as the Elasticsearch component is not installed. Try running "composer require api-platform/elasticsearch".');
}

$clientClass = !class_exists(\Elasticsearch\Client::class)
// ES v7
? \Elastic\Elasticsearch\Client::class
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"api-platform/doctrine-orm": "^4.2.3",
"api-platform/elasticsearch": "^4.2.3",
"api-platform/graphql": "^4.2.3",
"api-platform/hal": "^4.2.3",
"phpspec/prophecy-phpunit": "^2.2",
"phpunit/phpunit": "11.5.x-dev",
"symfony/expression-language": "^6.4 || ^7.0 || ^8.0",
Expand All @@ -70,6 +71,7 @@
"api-platform/elasticsearch": "To support Elasticsearch.",
"api-platform/graphql": "To support GraphQL.",
"api-platform/hal": "to support the HAL format",
"api-platform/json-api": "to support the JSON-API format",
"api-platform/ramsey-uuid": "To support Ramsey's UUID identifiers.",
"phpstan/phpdoc-parser": "To support extracting metadata from PHPDoc.",
"psr/cache-implementation": "To use metadata caching.",
Expand Down
Loading