REST_Controller.php is not working in codeigniter
I am going to use REST_Controller.php to make rest api's. (using codeigniter v3 on ubnatu 15)
from link https://github.com/chriskacerguis/codeigniter-restserver
on calling
localhost/rest_api_ci/api/example/user/1
Showing me error
Fatal error: Class 'REST_Controller' not found in /var/www/html/rest_api_ci/application/controllers/api/Example.php on line 21
A look of Example.php file
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
require(APPPATH.'libraries/REST_Controller.php');
/**
* This is an example of a few basic user interaction methods you could use
* all done with a hardcoded array
*
* @package CodeIgniter
* @subpackage Rest Server
* @category Controller
* @author Phil Sturgeon, Chris Kacerguis
* @license MIT
* @link https://github.com/chriskacerguis/codeigniter-restserver
*/
class Example extends REST_Controller {
function __construct()
{
codeigniter
|
show 3 more comments
I am going to use REST_Controller.php to make rest api's. (using codeigniter v3 on ubnatu 15)
from link https://github.com/chriskacerguis/codeigniter-restserver
on calling
localhost/rest_api_ci/api/example/user/1
Showing me error
Fatal error: Class 'REST_Controller' not found in /var/www/html/rest_api_ci/application/controllers/api/Example.php on line 21
A look of Example.php file
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
require(APPPATH.'libraries/REST_Controller.php');
/**
* This is an example of a few basic user interaction methods you could use
* all done with a hardcoded array
*
* @package CodeIgniter
* @subpackage Rest Server
* @category Controller
* @author Phil Sturgeon, Chris Kacerguis
* @license MIT
* @link https://github.com/chriskacerguis/codeigniter-restserver
*/
class Example extends REST_Controller {
function __construct()
{
codeigniter
where do you place rest_controller.php in your project?
– dhruv jadia
Dec 28 '16 at 7:45
in libraries/REST_Controller.php everything is in right place . I am using .htaccess file to remove index.php
– Vipul sharma
Dec 28 '16 at 7:46
so your url must be localhost/rest_api_ci/index.php/api/Example/users
– dhruv jadia
Dec 28 '16 at 7:48
if u r working on localhost
– dhruv jadia
Dec 28 '16 at 7:48
@vipul sharma are you using MX_controller also?
– Hek mat
Dec 28 '16 at 8:06
|
show 3 more comments
I am going to use REST_Controller.php to make rest api's. (using codeigniter v3 on ubnatu 15)
from link https://github.com/chriskacerguis/codeigniter-restserver
on calling
localhost/rest_api_ci/api/example/user/1
Showing me error
Fatal error: Class 'REST_Controller' not found in /var/www/html/rest_api_ci/application/controllers/api/Example.php on line 21
A look of Example.php file
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
require(APPPATH.'libraries/REST_Controller.php');
/**
* This is an example of a few basic user interaction methods you could use
* all done with a hardcoded array
*
* @package CodeIgniter
* @subpackage Rest Server
* @category Controller
* @author Phil Sturgeon, Chris Kacerguis
* @license MIT
* @link https://github.com/chriskacerguis/codeigniter-restserver
*/
class Example extends REST_Controller {
function __construct()
{
codeigniter
I am going to use REST_Controller.php to make rest api's. (using codeigniter v3 on ubnatu 15)
from link https://github.com/chriskacerguis/codeigniter-restserver
on calling
localhost/rest_api_ci/api/example/user/1
Showing me error
Fatal error: Class 'REST_Controller' not found in /var/www/html/rest_api_ci/application/controllers/api/Example.php on line 21
A look of Example.php file
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
require(APPPATH.'libraries/REST_Controller.php');
/**
* This is an example of a few basic user interaction methods you could use
* all done with a hardcoded array
*
* @package CodeIgniter
* @subpackage Rest Server
* @category Controller
* @author Phil Sturgeon, Chris Kacerguis
* @license MIT
* @link https://github.com/chriskacerguis/codeigniter-restserver
*/
class Example extends REST_Controller {
function __construct()
{
codeigniter
codeigniter
asked Dec 28 '16 at 7:39
Vipul sharmaVipul sharma
4921618
4921618
where do you place rest_controller.php in your project?
– dhruv jadia
Dec 28 '16 at 7:45
in libraries/REST_Controller.php everything is in right place . I am using .htaccess file to remove index.php
– Vipul sharma
Dec 28 '16 at 7:46
so your url must be localhost/rest_api_ci/index.php/api/Example/users
– dhruv jadia
Dec 28 '16 at 7:48
if u r working on localhost
– dhruv jadia
Dec 28 '16 at 7:48
@vipul sharma are you using MX_controller also?
– Hek mat
Dec 28 '16 at 8:06
|
show 3 more comments
where do you place rest_controller.php in your project?
– dhruv jadia
Dec 28 '16 at 7:45
in libraries/REST_Controller.php everything is in right place . I am using .htaccess file to remove index.php
– Vipul sharma
Dec 28 '16 at 7:46
so your url must be localhost/rest_api_ci/index.php/api/Example/users
– dhruv jadia
Dec 28 '16 at 7:48
if u r working on localhost
– dhruv jadia
Dec 28 '16 at 7:48
@vipul sharma are you using MX_controller also?
– Hek mat
Dec 28 '16 at 8:06
where do you place rest_controller.php in your project?
– dhruv jadia
Dec 28 '16 at 7:45
where do you place rest_controller.php in your project?
– dhruv jadia
Dec 28 '16 at 7:45
in libraries/REST_Controller.php everything is in right place . I am using .htaccess file to remove index.php
– Vipul sharma
Dec 28 '16 at 7:46
in libraries/REST_Controller.php everything is in right place . I am using .htaccess file to remove index.php
– Vipul sharma
Dec 28 '16 at 7:46
so your url must be localhost/rest_api_ci/index.php/api/Example/users
– dhruv jadia
Dec 28 '16 at 7:48
so your url must be localhost/rest_api_ci/index.php/api/Example/users
– dhruv jadia
Dec 28 '16 at 7:48
if u r working on localhost
– dhruv jadia
Dec 28 '16 at 7:48
if u r working on localhost
– dhruv jadia
Dec 28 '16 at 7:48
@vipul sharma are you using MX_controller also?
– Hek mat
Dec 28 '16 at 8:06
@vipul sharma are you using MX_controller also?
– Hek mat
Dec 28 '16 at 8:06
|
show 3 more comments
4 Answers
4
active
oldest
votes
change your url from
localhost/rest_api_ci/api/example/user/1
to
http://localhost/rest_api_ci/index.php/api/Example/users
still same with localhost/rest_api_ci/index.php/api/Example/user/1 and localhost/rest_api_ci/api/Example/user/2
– Vipul sharma
Dec 28 '16 at 7:52
@vipul sharma : answer provided
– dhruv jadia
Dec 28 '16 at 7:52
place example.php outside api folder and change url localhost/rest_api_ci/index.php/Example/users
– dhruv jadia
Dec 28 '16 at 7:54
Not working because "class Example extends REST_Controller" is not working
– Vipul sharma
Dec 28 '16 at 7:56
download latest code from filetolink.com/a720227fd5
– dhruv jadia
Dec 28 '16 at 7:59
|
show 2 more comments
Removing Unnecessary Namespaces in REST_Server.php
and Format.php
helped me.
add a comment |
After
require(APPPATH.'libraries/REST_Controller.php');
you need to add the namespace:
// use namespace
use RestserverLibrariesREST_Controller;
... I ran into this issue few minutes ago and it worked with me
add a comment |
I think its the path issue, same answer is given here
Hope it will help you or someone else.
Thanks
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f41357516%2frest-controller-php-is-not-working-in-codeigniter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
change your url from
localhost/rest_api_ci/api/example/user/1
to
http://localhost/rest_api_ci/index.php/api/Example/users
still same with localhost/rest_api_ci/index.php/api/Example/user/1 and localhost/rest_api_ci/api/Example/user/2
– Vipul sharma
Dec 28 '16 at 7:52
@vipul sharma : answer provided
– dhruv jadia
Dec 28 '16 at 7:52
place example.php outside api folder and change url localhost/rest_api_ci/index.php/Example/users
– dhruv jadia
Dec 28 '16 at 7:54
Not working because "class Example extends REST_Controller" is not working
– Vipul sharma
Dec 28 '16 at 7:56
download latest code from filetolink.com/a720227fd5
– dhruv jadia
Dec 28 '16 at 7:59
|
show 2 more comments
change your url from
localhost/rest_api_ci/api/example/user/1
to
http://localhost/rest_api_ci/index.php/api/Example/users
still same with localhost/rest_api_ci/index.php/api/Example/user/1 and localhost/rest_api_ci/api/Example/user/2
– Vipul sharma
Dec 28 '16 at 7:52
@vipul sharma : answer provided
– dhruv jadia
Dec 28 '16 at 7:52
place example.php outside api folder and change url localhost/rest_api_ci/index.php/Example/users
– dhruv jadia
Dec 28 '16 at 7:54
Not working because "class Example extends REST_Controller" is not working
– Vipul sharma
Dec 28 '16 at 7:56
download latest code from filetolink.com/a720227fd5
– dhruv jadia
Dec 28 '16 at 7:59
|
show 2 more comments
change your url from
localhost/rest_api_ci/api/example/user/1
to
http://localhost/rest_api_ci/index.php/api/Example/users
change your url from
localhost/rest_api_ci/api/example/user/1
to
http://localhost/rest_api_ci/index.php/api/Example/users
answered Dec 28 '16 at 7:51
dhruv jadiadhruv jadia
1,59021127
1,59021127
still same with localhost/rest_api_ci/index.php/api/Example/user/1 and localhost/rest_api_ci/api/Example/user/2
– Vipul sharma
Dec 28 '16 at 7:52
@vipul sharma : answer provided
– dhruv jadia
Dec 28 '16 at 7:52
place example.php outside api folder and change url localhost/rest_api_ci/index.php/Example/users
– dhruv jadia
Dec 28 '16 at 7:54
Not working because "class Example extends REST_Controller" is not working
– Vipul sharma
Dec 28 '16 at 7:56
download latest code from filetolink.com/a720227fd5
– dhruv jadia
Dec 28 '16 at 7:59
|
show 2 more comments
still same with localhost/rest_api_ci/index.php/api/Example/user/1 and localhost/rest_api_ci/api/Example/user/2
– Vipul sharma
Dec 28 '16 at 7:52
@vipul sharma : answer provided
– dhruv jadia
Dec 28 '16 at 7:52
place example.php outside api folder and change url localhost/rest_api_ci/index.php/Example/users
– dhruv jadia
Dec 28 '16 at 7:54
Not working because "class Example extends REST_Controller" is not working
– Vipul sharma
Dec 28 '16 at 7:56
download latest code from filetolink.com/a720227fd5
– dhruv jadia
Dec 28 '16 at 7:59
still same with localhost/rest_api_ci/index.php/api/Example/user/1 and localhost/rest_api_ci/api/Example/user/2
– Vipul sharma
Dec 28 '16 at 7:52
still same with localhost/rest_api_ci/index.php/api/Example/user/1 and localhost/rest_api_ci/api/Example/user/2
– Vipul sharma
Dec 28 '16 at 7:52
@vipul sharma : answer provided
– dhruv jadia
Dec 28 '16 at 7:52
@vipul sharma : answer provided
– dhruv jadia
Dec 28 '16 at 7:52
place example.php outside api folder and change url localhost/rest_api_ci/index.php/Example/users
– dhruv jadia
Dec 28 '16 at 7:54
place example.php outside api folder and change url localhost/rest_api_ci/index.php/Example/users
– dhruv jadia
Dec 28 '16 at 7:54
Not working because "class Example extends REST_Controller" is not working
– Vipul sharma
Dec 28 '16 at 7:56
Not working because "class Example extends REST_Controller" is not working
– Vipul sharma
Dec 28 '16 at 7:56
download latest code from filetolink.com/a720227fd5
– dhruv jadia
Dec 28 '16 at 7:59
download latest code from filetolink.com/a720227fd5
– dhruv jadia
Dec 28 '16 at 7:59
|
show 2 more comments
Removing Unnecessary Namespaces in REST_Server.php
and Format.php
helped me.
add a comment |
Removing Unnecessary Namespaces in REST_Server.php
and Format.php
helped me.
add a comment |
Removing Unnecessary Namespaces in REST_Server.php
and Format.php
helped me.
Removing Unnecessary Namespaces in REST_Server.php
and Format.php
helped me.
answered Dec 29 '16 at 9:24
Nithi2023Nithi2023
251310
251310
add a comment |
add a comment |
After
require(APPPATH.'libraries/REST_Controller.php');
you need to add the namespace:
// use namespace
use RestserverLibrariesREST_Controller;
... I ran into this issue few minutes ago and it worked with me
add a comment |
After
require(APPPATH.'libraries/REST_Controller.php');
you need to add the namespace:
// use namespace
use RestserverLibrariesREST_Controller;
... I ran into this issue few minutes ago and it worked with me
add a comment |
After
require(APPPATH.'libraries/REST_Controller.php');
you need to add the namespace:
// use namespace
use RestserverLibrariesREST_Controller;
... I ran into this issue few minutes ago and it worked with me
After
require(APPPATH.'libraries/REST_Controller.php');
you need to add the namespace:
// use namespace
use RestserverLibrariesREST_Controller;
... I ran into this issue few minutes ago and it worked with me
edited Apr 18 '17 at 17:46
Alex Filatov
1,76232228
1,76232228
answered Apr 18 '17 at 16:05
Eissa AbdullahEissa Abdullah
13
13
add a comment |
add a comment |
I think its the path issue, same answer is given here
Hope it will help you or someone else.
Thanks
add a comment |
I think its the path issue, same answer is given here
Hope it will help you or someone else.
Thanks
add a comment |
I think its the path issue, same answer is given here
Hope it will help you or someone else.
Thanks
I think its the path issue, same answer is given here
Hope it will help you or someone else.
Thanks
answered Nov 19 '18 at 6:38
ImFarhadImFarhad
1528
1528
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f41357516%2frest-controller-php-is-not-working-in-codeigniter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
where do you place rest_controller.php in your project?
– dhruv jadia
Dec 28 '16 at 7:45
in libraries/REST_Controller.php everything is in right place . I am using .htaccess file to remove index.php
– Vipul sharma
Dec 28 '16 at 7:46
so your url must be localhost/rest_api_ci/index.php/api/Example/users
– dhruv jadia
Dec 28 '16 at 7:48
if u r working on localhost
– dhruv jadia
Dec 28 '16 at 7:48
@vipul sharma are you using MX_controller also?
– Hek mat
Dec 28 '16 at 8:06