PHPackages                             danielalmeida1481/codeigniter3-datatables - 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. danielalmeida1481/codeigniter3-datatables

ActiveLibrary[API Development](/categories/api)

danielalmeida1481/codeigniter3-datatables
=========================================

DataTables server-side for CodeIgniter

v1.0.2(3y ago)011MITPHPPHP &gt;=8.1.0

Since Nov 26Pushed 3y agoCompare

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

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

CodeIgniter DataTables
======================

[](#codeigniter-datatables)

DataTables server-side for CodeIgniter 3.

**Note:** This library only handle the server-side part, you still needs to configure the client side like jQuery, DataTables library and including the styles. Don't worry, we already give the examples below.

Requirements
------------

[](#requirements)

If you are using CodeIgniter, let's go! You don't needs any extra requirements.

Installation
------------

[](#installation)

You just need to use composer and everything is done.

```
composer require danielalmeida1481/codeigniter3-datatables
```

Usage
-----

[](#usage)

Here is the basic example to use this library, you are freely make any changes for the client side, like defining searchable column, orderable column, etc...

### CodeIgniter 3 Example

[](#codeigniter-3-example)

```
// CodeIgniter 3 Example

// Here we will select all fields from posts table
// and make a join with categories table
// Please note: we don't need to call ->get() here
$queryBuilder = $this->db->select('p.*, c.name category')
                    ->from('posts p')
                    ->join('categories c', 'c.id=p.category_id');

/**
 * The first parameter is the query builder instance
 */
$datatables = new Danielalmeida1481\CodeIgniterDataTables\DataTables($queryBuilder);
$datatables->generate(); // done
```

**The above example will give you for [ajax data source (arrays)](https://datatables.net/examples/ajax/simple.html), so you need to make sure the table header you makes for the client side is match with the ajax response. We will talk about the objects data source below.**

### Client Side Examples

[](#client-side-examples)

You must include the jQuery and DataTables library.

```

    ID
    Title
    Category
    Description

$('#table-post').DataTable({
  processing: true,
  serverSide: true,
  ajax: {
    url: 'http://localhost/project/index.php/post/ajax_datatables', // Change with your own
    method: 'GET', // You are freely to use POST or GET
  }
})

```

Objects Data Source
-------------------

[](#objects-data-source)

As was mentioned above, the default data source we get is an arrays. It is easy also to get the objects data source.

To get objects response, you just need to call `asObject()` method.

```
$datatables->asObject()
           ->generate();
```

And then you can configure the client side with columns option to fit your data.

```
$('#table-post').DataTable({
  processing: true,
  serverSide: true,
  ajax: {
    url: 'http://localhost/project/index.php/post/ajax_datatables',
    method: 'GET',
  },
  columns: [
    { data: 'id' },
    { data: 'title' },
    { data: 'category' },
    { data: 'description' }
  ]
})

```

Some Others Settings
--------------------

[](#some-others-settings)

Some basic functionalities already available, here is the full settings you can doing to this library.

### Available Options

[](#available-options)

```
$datatables = new Danielalmeida1481\CodeIgniterDataTables\DataTables($queryBuilder);

// Return the output as objects instead of arrays
$datatables->asObject();

// Only return title & category (accept string or array)
$datatables->only(['title', 'category']);

// Return all except the id
// You may use one of only or except
$datatables->except(['id']);

// Format the output
$datatables->format('title', function($value, $row) {
  return ''.$value.'';
});

// Add extra column
$datatables->addColumn('action', function($row) {
  return 'Delete';
});

// Add column alias
// It is very useful when we use SELECT JOIN to prevent column ambiguous
$datatables->addColumnAlias('p.id', 'id');

// Add column aliases
// Same as the addColumnAlias, but for multiple alias at once
$datatables->addColumnAliases([
  'p.id' => 'id',
  'c.name' => 'category'
]);

// Add squence number
// The default key is `sequenceNumber`
// You can change it with give the param
$datatables->addSequenceNumber();
$datatables->addSequenceNumber('rowNumber'); // It will be rowNumber

// Don't forget ot call generate to get the results
$datatables->generate();
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.3% 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

Every ~0 days

Total

3

Last Release

1262d ago

### Community

Maintainers

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

---

Top Contributors

[![ngekoding](https://avatars.githubusercontent.com/u/11625690?v=4)](https://github.com/ngekoding "ngekoding (13 commits)")[![danielalmeida1481](https://avatars.githubusercontent.com/u/34009600?v=4)](https://github.com/danielalmeida1481 "danielalmeida1481 (3 commits)")

### Embed Badge

![Health badge](/badges/danielalmeida1481-codeigniter3-datatables/health.svg)

```
[![Health](https://phpackages.com/badges/danielalmeida1481-codeigniter3-datatables/health.svg)](https://phpackages.com/packages/danielalmeida1481-codeigniter3-datatables)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[mjaschen/collmex

Collmex PHP SDK

2080.7k](/packages/mjaschen-collmex)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)[dragon-code/laravel-json-response

Automatically always return a response in JSON format

1118.6k1](/packages/dragon-code-laravel-json-response)

PHPackages © 2026

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