Welcome Guest, Not a member yet? Register   Sign In
REST Controller Issue

Im having some trouble trying to configure the RestServer library for CodeIgniter (https://github.com/chriskacerguis/codeig...roller.php).

//EDIT I'm using Code Igniter Version 2.1.3

Whenever I try to access a model from a Controller, it returns an error saying:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Dan::$dM
My controller looks like this

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// This can be removed if you use __autoload() in config.php OR use Modular Extensions
require APPPATH.'/libraries/REST_Controller.php';

class Dan extends REST_Controller {

function __construct(){


public function ptest_get()
$test = $this->dM->testSum();
//$test = 1;

$this->response($test, 200); // 200 being the HTTP response code



I have configured everything that the documentation states, I have loaded the database module in the autoload.php, I have tried loading the model in the construct and in the function but it always returns the error. The only solution I have found (which is not efficiente) is in the autoload.php file configure to load all the models since the beginning (thing that we don't want because of performance).

| -------------------------------------------------------------------
| Auto-load Models
| -------------------------------------------------------------------
| Prototype:
| $autoload['model'] = array('model1', 'model2');

$autoload['model'] = array('finder_model');
Could anyone point me if I'm missing some configuration or what I'm doing wrong?

How about using $this->dan_model->testSum(), I think the complaint was that CI didnt understand the 'alias' name of model

Hmm - I tried essentially the same thing you describe, but not using a REST controller, and had no problem.
What line # is the error reported at, and what does that correspond to in your controller?
James Parry
Project Lead

Theme © iAndrew 2016 - Forum software by © MyBB