-1
defined('BASEPATH') OR exit('No direct script access allowed');

require('application/libraries/REST_Controller.php');

use Restserver\Libraries\REST_Controller;

class demo extends REST_Controller {

  function __construct(){

    parent::__construct();
  }

  public function demo1_get()
  {
    echo 'demo 1';
  }

} 

Error Image enter image description here

This is My REST_Controller enter image description here

Hi, I m getting Error for making Codeigniter RESTful API. Please Help me to solve this problem.

2 Answers 2

0

It should be like this :

Make sure you have REST_Controller.php in your libraries folder

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

require_once APPPATH . '/libraries/REST_Controller.php';


class Demo  extends REST_Controller
{
    function __construct(){

      parent::__construct();
    }

   public function demo1_get()
   {
     echo 'demo 1';
   }
}
Sign up to request clarification or add additional context in comments.

Comments

0

You need to follow the link https://itsolutionstuff.com/post/codeigniter-3-restful-api-tutorialexample.html

and then after you run the code you will get a small error Unable to load the requested language file: language/english/rest_controller_lang.php

The problem is that codeigniter can't find the rest_controller translations. You just need to create this file /application/languages/english/rest_controller_lang.php

Then copy & paste this code inside:

<?php
/*
 * English language
 */
$lang['text_rest_invalid_api_key'] = 'Invalid API key %s'; // %s is the REST API key
$lang['text_rest_invalid_credentials'] = 'Invalid credentials';
$lang['text_rest_ip_denied'] = 'IP denied';
$lang['text_rest_ip_unauthorized'] = 'IP unauthorized';
$lang['text_rest_unauthorized'] = 'Unauthorized';
$lang['text_rest_ajax_only'] = 'Only AJAX requests are allowed';
$lang['text_rest_api_key_unauthorized'] = 'This API key does not have access to the requested controller';
$lang['text_rest_api_key_permissions'] = 'This API key does not have enough permissions';
$lang['text_rest_api_key_time_limit'] = 'This API key has reached the time limit for this method';
$lang['text_rest_ip_address_time_limit'] = 'This IP Address has reached the time limit for this method';
$lang['text_rest_unknown_method'] = 'Unknown method';
$lang['text_rest_unsupported'] = 'Unsupported protocol';

Hope this helps

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.