PHPackages                             plato-solutions/yii2-graphql - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. plato-solutions/yii2-graphql

ActiveYii2-extension[Framework](/categories/framework)

plato-solutions/yii2-graphql
============================

graphql server side for yii2 php framework

0.11.4(8y ago)52.8k1BSD-3-ClausePHPPHP &gt;=5.6.0

Since Jul 5Pushed 2y agoCompare

[ Source](https://github.com/Plato-solutions/yii2-graphql)[ Packagist](https://packagist.org/packages/plato-solutions/yii2-graphql)[ RSS](/packages/plato-solutions-yii2-graphql/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

yii2-graphql
============

[](#yii2-graphql)

Using [GraphQL](https://graphql.org/) PHP server implementation. A fork of [yii2-graphql](https://github.com/tsingsun/yii2-graphql) which extends [graphql-php](https://github.com/webonyx/graphql-php) to apply to [Yii2](https://yiiframework.com).

Guide (For Yii Basic Template)
------------------------------

[](#guide-for-yii-basic-template)

Same as for Yii Advanced Template, but

- instead of the `backend` namespace, it's `app`
    - eg the namespace should be `namespace app\modules\graphql\...`
- Instead of `main.php`, it's `web.php` eg `
    - eg the config is in `config/web.php`

Guide (For Yii Advanced Template)
---------------------------------

[](#guide-for-yii-advanced-template)

### Install

[](#install)

Using [composer](https://getcomposer.org/)

```
composer require Plato-solutions/yii2-graphql

```

### Enable [Yii JsonParser](https://www.yiiframework.com/doc/api/2.0/yii-web-jsonparser)

[](#enable-yii-jsonparser)

To enable parsing for JSON requests in `backend/config/main.php`

```
'components' => [
    'request' => [
        // ... other config
        'parsers' => [
            'application/json' => 'yii\web\JsonParser',
        ]
    ]
]
```

### Create a [GraphQLModule](https://www.yiiframework.com/doc/guide/2.0/en/structure-modules)

[](#create-a-graphqlmodule)

1. Create a folder `modules` in your base path (ie `backend`)
2. Create a `graphql` folder in the modules folder. Thus `backend/modules/graphql`
3. Create a `GraphqlModule.php` file in there with the following content: `backend/modules/graphql/GraphqlModule.php`

```
