07-23-2019, 07:52 PM
I was using tests in CI3, with the codeigniter-restserver library and I liked the following implementation:
class Books extends CI_Controller
{
use REST_Controller {
REST_Controller::__construct as private __resTraitConstruct;
}
public function index_get()
{
// Display all books
}
public function index_post()
{
// Create a new book
}
public function index_delete($id)
{
// Delete a book
}
}
What I like is that: the method names will be appended with the HTTP method used to access the request. If you're making an HTTP GET call to /books, for instance, it would call a Books#index_get() method.
Is it possible for CI4 to work this way?
link: https://github.com/chriskacerguis/codeig...restserver
class Books extends CI_Controller
{
use REST_Controller {
REST_Controller::__construct as private __resTraitConstruct;
}
public function index_get()
{
// Display all books
}
public function index_post()
{
// Create a new book
}
public function index_delete($id)
{
// Delete a book
}
}
What I like is that: the method names will be appended with the HTTP method used to access the request. If you're making an HTTP GET call to /books, for instance, it would call a Books#index_get() method.
Is it possible for CI4 to work this way?
link: https://github.com/chriskacerguis/codeig...restserver