2

im trying to run codeigniter-restserver. Here what i've done;

i installed latest codeigniter to my localhost. then in the root directory of clean installed codeigniter i runned

composer require chriskacerguis/codeigniter-restserver

the vendor directory is created and it is look like this;

-rw-r--r--   1 xx  staff  178 Mar 13 12:18 autoload.php
drwxr-xr-x   3 xx  staff   96 Mar 13 12:18 bin
drwxr-xr-x   3 xx  staff   96 Mar 13 12:18 chriskacerguis
drwxr-xr-x  11 xx  staff  352 Mar 13 12:18 composer
drwxr-xr-x   3 xx  staff   96 Mar 13 12:18 doctrine
drwxr-xr-x   3 xx  staff   96 Mar 13 12:18 mikey179
drwxr-xr-x   3 xx  staff   96 Mar 13 12:18 myclabs
drwxr-xr-x   5 xx  staff  160 Mar 13 12:18 phpdocumentor
drwxr-xr-x   3 xx  staff   96 Mar 13 12:18 phpspec
drwxr-xr-x   9 xx  staff  288 Mar 13 12:18 phpunit
drwxr-xr-x  12 xx  staff  384 Mar 13 12:18 sebastian
drwxr-xr-x   3 xx  staff   96 Mar 13 12:18 symfony
drwxr-xr-x   3 xx  staff   96 Mar 13 12:18 webmozart

i changed in the application/config/config.php line to;

$config['composer_autoload'] = TRUE;

and my new controller file looks like (application/controller/Rest.php);

<?php
use Restserver\Libraries\REST_Controller;

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

class Rest extends REST_Controller {

    public function index_get() {

        echo json_encode(['wtf', 'igo']);

    }

}

when i try to reach http://mylocaltestdomainish.test/rest/

The configuration file rest.php does not exist.

i dont know why but, codeigniter-restserver is seeking rest.php in my /application/config/ directory instead of /vendor/chriskacerguis/codeigniter-restserver/application/config. if i copy rest.php in my config directory, than it says "i cant found Format.php" or something like this.

What i missing here? thanks for your advices.

Ali Aydin
  • 33
  • 4
  • read this : https://code.tutsplus.com/tutorials/working-with-restful-services-in-codeigniter--net-8814 – Pradeep Mar 13 '18 at 10:15
  • Read this https://github.com/chriskacerguis/codeigniter-restserver/issues/827 https://github.com/chriskacerguis/codeigniter-restserver/pull/832 – mohamedvall Mar 13 '18 at 10:30
  • Either install composer packages in `APPPATH` (which would be recommended in here because of publicly exposed `FCPATH` directory) either set `$config['composer_autoload'] = FCPATH.'vendor/autoload.php';` Read again [here](https://github.com/bcit-ci/CodeIgniter/blob/develop/application/config/config.php#L121-L141). – Tpojka Mar 13 '18 at 11:23
  • 1
    Thanks guys for your answers. @Tpojka reading config.php comments guided me to install package under application folder (application/vendor). i kept config.php file same $config['composer_autoload'] = TRUE; and it worked. thanks a lot :) – Ali Aydin Mar 13 '18 at 12:48

0 Answers0