Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Rest Api Routing
  • Hi,
    I would like to build a rest api and organise my code in subfolders like that controller/api/1/

    I tried with a simple test controller like this: test.php

    <?php
    class Controller_Test extends Controller_Rest
    {
        public function get_list()
        {
            return $this->response(array('foo'=>'bar'));
        }
    }

    It works perfectly if I put the file is in controller folder but not in controller/api/1/. Should I configure some routes? Is it a bad practice to work like that?
    I also tried to rename controller Controller_Api_1_Test.

    Thanks


  • HarroHarro
    Accepted Answer
    Theoretically that should work fine. "Controller_Api_1_Test" should map to ./app/classes/controller/api/1/test.php.

    The only thing I'm not sure about is if it likes the numeric part, we use "v1", "v2", etc in our applications, and I wonder if that is for a specific reason.
  • Thanks, it works event without the v indeed.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion