diff --git a/composer.json b/composer.json index 8c08611..80c9f04 100644 --- a/composer.json +++ b/composer.json @@ -1,29 +1,30 @@ { - "name" : "thecodingmachine/graphqlite-laravel", - "description" : "A Laravel service provider package to help you get started with GraphQLite in Laravel.", - "keywords" : [ + "name": "thecodingmachine/graphqlite-laravel", + "description": "A Laravel service provider package to help you get started with GraphQLite in Laravel.", + "keywords": [ "GraphQL", "GraphQLite", "Laravel" ], - "homepage" : "https://github.com/thecodingmachine/graphqlite", - "type" : "library", - "license" : "MIT", - "authors" : [{ - "name" : "David Négrier", - "email" : "d.negrier@thecodingmachine.com", - "homepage" : "http://mouf-php.com" + "homepage": "https://github.com/thecodingmachine/graphqlite", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "David N\u00e9grier", + "email": "d.negrier@thecodingmachine.com", + "homepage": "http://mouf-php.com" } ], - "require" : { - "php" : ">=7.2", - "thecodingmachine/graphqlite" : "^4", + "require": { + "php": ">=7.2", + "thecodingmachine/graphqlite": "^4", "illuminate/console": "^5.7|^6.0", "illuminate/container": "^5.7|^6.0", "illuminate/support": "^5.7|^6.0", "illuminate/cache": "^5.7|^6.0", - "symfony/psr-http-message-bridge": "^1", - "zendframework/zend-diactoros": "^1.8.6", + "symfony/psr-http-message-bridge": "^1.3.0 || ^2", + "laminas/laminas-diactoros": "^2.2.2", "symfony/cache": "^4.3 || ^5" }, "require-dev": { @@ -31,14 +32,14 @@ "phpunit/phpunit": "^7.5.4 || ^8.3", "ext-sqlite3": "*" }, - "autoload" : { - "psr-4" : { - "TheCodingMachine\\GraphQLite\\Laravel\\" : "src/" + "autoload": { + "psr-4": { + "TheCodingMachine\\GraphQLite\\Laravel\\": "src/" } }, - "autoload-dev" : { - "psr-4" : { - "App\\" : "tests/Fixtures/App" + "autoload-dev": { + "psr-4": { + "App\\": "tests/Fixtures/App" } }, "extra": { diff --git a/src/Providers/GraphQLiteServiceProvider.php b/src/Providers/GraphQLiteServiceProvider.php index c0f5718..ed15028 100644 --- a/src/Providers/GraphQLiteServiceProvider.php +++ b/src/Providers/GraphQLiteServiceProvider.php @@ -5,6 +5,15 @@ use Illuminate\Contracts\Auth\Access\Gate; use Illuminate\Contracts\Auth\Factory as AuthFactory; use Illuminate\Contracts\Events\Dispatcher; +use Laminas\Diactoros\ResponseFactory; +use Laminas\Diactoros\ServerRequestFactory; +use Laminas\Diactoros\StreamFactory; +use Laminas\Diactoros\UploadedFileFactory; +use Psr\Http\Message\ResponseFactoryInterface; +use Psr\Http\Message\ServerRequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; +use Psr\Http\Message\UploadedFileFactoryInterface; +use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; use Symfony\Component\Cache\Adapter\ApcuAdapter; use Symfony\Component\Cache\Adapter\PhpFilesAdapter; use Symfony\Component\Cache\Psr16Cache; @@ -62,7 +71,20 @@ public function register() { $this->app->bind(WebonyxSchema::class, Schema::class); - $this->app->bind(HttpMessageFactoryInterface::class, DiactorosFactory::class); + if (!$this->app->has(ServerRequestFactoryInterface::class)) { + $this->app->bind(ServerRequestFactoryInterface::class, ServerRequestFactory::class); + } + if (!$this->app->has(StreamFactoryInterface::class)) { + $this->app->bind(StreamFactoryInterface::class, StreamFactory::class); + } + if (!$this->app->has(UploadedFileFactoryInterface::class)) { + $this->app->bind(UploadedFileFactoryInterface::class, UploadedFileFactory::class); + } + if (!$this->app->has(ResponseFactoryInterface::class)) { + $this->app->bind(ResponseFactoryInterface::class, ResponseFactory::class); + } + + $this->app->bind(HttpMessageFactoryInterface::class, PsrHttpFactory::class); $this->app->singleton(GraphQLiteController::class, function (Application $app) { $debug = config('graphqlite.debug', Debug::RETHROW_UNSAFE_EXCEPTIONS);