PHPackages                             magdv/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. [API Development](/categories/api)
4. /
5. magdv/yii2-graphql

ActiveYii2-extension[API Development](/categories/api)

magdv/yii2-graphql
==================

graphql server side for yii2 php framework

0.0.2(2y ago)01.9k↓50%BSD-3-ClausePHPPHP ^8.0

Since Apr 16Pushed 2y agoCompare

[ Source](https://github.com/magdv/yii2-graphql)[ Packagist](https://packagist.org/packages/magdv/yii2-graphql)[ RSS](/packages/magdv-yii2-graphql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (9)Versions (5)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`

```
