REST_Controller.php is not working in codeigniter












1















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()
{









share|improve this question























  • 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
















1















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()
{









share|improve this question























  • 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














1












1








1








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()
{









share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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



















  • 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












4 Answers
4






active

oldest

votes


















0














change your url from



localhost/rest_api_ci/api/example/user/1


to



http://localhost/rest_api_ci/index.php/api/Example/users





share|improve this answer
























  • 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



















0














Removing Unnecessary Namespaces in REST_Server.php and Format.php helped me.






share|improve this answer































    0














    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






    share|improve this answer

































      0














      I think its the path issue, same answer is given here
      Hope it will help you or someone else.

      Thanks






      share|improve this answer























        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
        });


        }
        });














        draft saved

        draft discarded


















        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









        0














        change your url from



        localhost/rest_api_ci/api/example/user/1


        to



        http://localhost/rest_api_ci/index.php/api/Example/users





        share|improve this answer
























        • 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
















        0














        change your url from



        localhost/rest_api_ci/api/example/user/1


        to



        http://localhost/rest_api_ci/index.php/api/Example/users





        share|improve this answer
























        • 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














        0












        0








        0







        change your url from



        localhost/rest_api_ci/api/example/user/1


        to



        http://localhost/rest_api_ci/index.php/api/Example/users





        share|improve this answer













        change your url from



        localhost/rest_api_ci/api/example/user/1


        to



        http://localhost/rest_api_ci/index.php/api/Example/users






        share|improve this answer












        share|improve this answer



        share|improve this answer










        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



















        • 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













        0














        Removing Unnecessary Namespaces in REST_Server.php and Format.php helped me.






        share|improve this answer




























          0














          Removing Unnecessary Namespaces in REST_Server.php and Format.php helped me.






          share|improve this answer


























            0












            0








            0







            Removing Unnecessary Namespaces in REST_Server.php and Format.php helped me.






            share|improve this answer













            Removing Unnecessary Namespaces in REST_Server.php and Format.php helped me.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Dec 29 '16 at 9:24









            Nithi2023Nithi2023

            251310




            251310























                0














                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






                share|improve this answer






























                  0














                  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






                  share|improve this answer




























                    0












                    0








                    0







                    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






                    share|improve this answer















                    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







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    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























                        0














                        I think its the path issue, same answer is given here
                        Hope it will help you or someone else.

                        Thanks






                        share|improve this answer




























                          0














                          I think its the path issue, same answer is given here
                          Hope it will help you or someone else.

                          Thanks






                          share|improve this answer


























                            0












                            0








                            0







                            I think its the path issue, same answer is given here
                            Hope it will help you or someone else.

                            Thanks






                            share|improve this answer













                            I think its the path issue, same answer is given here
                            Hope it will help you or someone else.

                            Thanks







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 19 '18 at 6:38









                            ImFarhadImFarhad

                            1528




                            1528






























                                draft saved

                                draft discarded




















































                                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.




                                draft saved


                                draft discarded














                                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





















































                                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







                                Popular posts from this blog

                                Guess what letter conforming each word

                                Port of Spain

                                Run scheduled task as local user group (not BUILTIN)