PHPackages                             giginc/cakephp3-driver-json - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. giginc/cakephp3-driver-json

ActiveCakephp-plugin[Parsing &amp; Serialization](/categories/parsing)

giginc/cakephp3-driver-json
===========================

An Json datasource for CakePHP 3.0

1.0.0(6y ago)13.5k↑80%MITPHPPHP ^5.4|^7.0

Since Aug 26Pushed 6y ago4 watchersCompare

[ Source](https://github.com/giginc/cakephp3-driver-json)[ Packagist](https://packagist.org/packages/giginc/cakephp3-driver-json)[ Docs](https://github.com/giginc/cakephp3-driver-json)[ RSS](/packages/giginc-cakephp3-driver-json/feed)WikiDiscussions master Synced 3w ago

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

Json Driver for Cakephp3
========================

[](#json-driver-for-cakephp3)

An Json datasource for CakePHP 3.5

Installing via composer
-----------------------

[](#installing-via-composer)

Install [composer](http://getcomposer.org) and run:

```
composer require giginc/cakephp3-driver-json
```

Defining a connection
---------------------

[](#defining-a-connection)

Now, you need to set the connection in your config/app.php file:

```
 'Datasources' => [
    'default' => [
        'className' => 'Giginc\Json\Database\Connection',
        'driver' => 'Giginc\Json\Database\Driver\Json',
        'baseDir' => './', // local path on the server relative to WWW_ROOT
    ],
],
```

Models
------

[](#models)

After that, you need to load Giginc\\Json\\ORM\\Table in your tables class:

```
//src/Model/Table/YourTable.php

use Giginc\Json\ORM\Table;

class CategoriesTable extends Table {

    /**
     * Initialize method
     *
     * @param array $config The configuration for the Table.
     * @return void
     */
    public function initialize(array $config)
    {
        parent::initialize($config);

        $this->setTable('categories'); // load file is WWW_ROOT/categories.json
    }

}
```

Controllers
-----------

[](#controllers)

```
namespace App\Controller;

use App\Controller\AppController;

/**
 * Pages Controller
 *
 * @property \App\Model\Table\PagesTable $Pages
 *
 * @method \App\Model\Entity\Review[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
 */
class PagesController extends AppController
{
    /**
     * Index method
     *
     * @return \Cake\Http\Response|void
     */
    public function index()
    {
        $this->loadModel('TestJsons');
        $data = $this->TestJsons->find()
            ->where('code', '=', "0001")
            ->get()
            ;
    }
}
```

You can start Query your data using the various query methods such as **find**, **where**, **orWhere**, **whereIn**, **whereStartsWith**, **whereEndsWith**, **whereContains** and so on. Also you can aggregate your data after query using **sum**, **count**, **groupBy**, **max**, **min** etc.

Let's see a quick example:

```
//data.json
{
	"name": "products",
	"description": "Features product list",
	"vendor":{
		"name": "Computer Source BD",
		"email": "info@example.com",
		"website":"www.example.com"
	},
	"users":[
		{"id":1, "name":"Johura Akter Sumi", "location": "Barisal"},
		{"id":2, "name":"Mehedi Hasan Nahid", "location": "Barisal"},
		{"id":3, "name":"Ariful Islam", "location": "Barisal"},
		{"id":4, "name":"Suhel Ahmed", "location": "Sylhet"},
		{"id":5, "name":"Firoz Serniabat", "location": "Gournodi"},
		{"id":6, "name":"Musa Jewel", "location": "Barisal", "visits": [
			{"name": "Sylhet", "year": 2011},
			{"name": "Cox's Bazar", "year": 2012},
			{"name": "Bandarbar", "year": 2014}
		]}
	],
	"products": [
		{"id":1, "user_id": 2, "city": "bsl", "name":"iPhone", "cat":1, "price": 80000},
		{"id":2, "user_id": 2, "city": null, "name":"macbook pro", "cat": 2, "price": 150000},
		{"id":3, "user_id": 2, "city": "dhk", "name":"Redmi 3S Prime", "cat": 1, "price": 12000},
		{"id":4, "user_id": 1, "city": null, "name":"Redmi 4X", "cat":1, "price": 15000},
		{"id":5, "user_id": 1, "city": "bsl", "name":"macbook air", "cat": 2, "price": 110000},
		{"id":6, "user_id": 2, "city": null, "name":"macbook air 1", "cat": 2, "price": 81000}
	]
}
```

```
$this->loadModel('TestJsons');
$data = $this->TestJsons->find('products')
    ->where('cat', '=', 2)
    ->get();
dd($res);

//This will print
/*
array:3 [▼
  1 => {#7 ▼
    +"id": 2
    +"user_id": 2
    +"city": null
    +"name": "macbook pro"
    +"cat": 2
    +"price": 150000
  }
  4 => {#8 ▼
    +"id": 5
    +"user_id": 1
    +"city": "bsl"
    +"name": "macbook air"
    +"cat": 2
    +"price": 110000
  }
  5 => {#9 ▼
    +"id": 6
    +"user_id": 2
    +"city": null
    +"name": "macbook air 1"
    +"cat": 2
    +"price": 81000
  }
]
*/
```

SPECIAL THANKS:
---------------

[](#special-thanks)

[php-jsonq](https://github.com/nahid/jsonq)

LICENSE
-------

[](#license)

[The MIT License (MIT) Copyright (c) 2013](http://opensource.org/licenses/MIT)

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2494d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a6e6faaa4785c7f5812464198b2503a25975f08e8c5a6239c33dc023dd272ab0?d=identicon)[issys16](/maintainers/issys16)

![](https://avatars.githubusercontent.com/u/3604122?v=4)[kgw](/maintainers/kgw)[@KGW](https://github.com/KGW)

![](https://www.gravatar.com/avatar/7949227b7010f17463abac769d717a9fb16d1b81e0b584b2ec5f399369a96cb3?d=identicon)[moimoi](/maintainers/moimoi)

---

Top Contributors

[![kgws](https://avatars.githubusercontent.com/u/83611?v=4)](https://github.com/kgws "kgws (14 commits)")

---

Tags

jsoncakephpjsonq

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/giginc-cakephp3-driver-json/health.svg)

```
[![Health](https://phpackages.com/badges/giginc-cakephp3-driver-json/health.svg)](https://phpackages.com/packages/giginc-cakephp3-driver-json)
```

###  Alternatives

[nahid/jsonq

JsonQ is a PHP based json data query library

873665.6k7](/packages/nahid-jsonq)[colinodell/json5

UTF-8 compatible JSON5 parser for PHP

30424.1M51](/packages/colinodell-json5)[cakephp/bake

Bake plugin for CakePHP

11211.7M190](/packages/cakephp-bake)[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

333972.2k49](/packages/dereuromark-cakephp-tools)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308914.0k25](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1882.3M40](/packages/dereuromark-cakephp-ide-helper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
