Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Controller Bug
  • Hi,
    I wanted to report wrong behavior of controller classes (template,rest and hybrid) not the abstract Controller class.
    When you create a controller which is not derived from base controller class and try to reach url like http://localhost/mycontroller/notexistaction than it doesnt respond 404 action just tries render template.php and show content.
    Also when you use template controller if you change default template view name, it doesnt work.
  • HarroHarro
    Accepted Answer
    A controller always HAS to extend one of the available base controllers. A standard class does not work as a controller.

    If your controller correctly extends one of the available base controller, the Request class will ALWAYS trigger an HttpNotFoundException when the requested method could not be found. The only exception is a controller that contains a router() method, if that exists it will always be called. If no method name is passed in the URI, it will default to 'index', but if action_index() does not exist, that too will result in a HttpNotFoundException.

    The Controller_Template converts the defined template property (if a string) to a View object in the before() method of the controller. This is required, otherwise you can't assign anything to it. If you want to change it somewhere in the controller (which might be a sign of bad design) you need to manually assign the View, and not the string.

    Neither of these are bugs, but by design. If you think otherwise, please provide code samples.
  • When i have bellow controller and template.php exist, if i try to reach http://localhost/sample/any than it doest give me 404 exception, just render the template.php and send output to browser with status 200. Controller_Template works as expected.

    <?php
    class Controller_Sample extends Controller_Hybrid
    {
        public function action_test()
        {
            die('Hello');
        }
    }

  • Ah, this is new information, in your first message you mentioned incorrect behaviour for all controller base classes.

    So it happens with Controller_Hybrid only?
  • HarroHarro
    Accepted Answer
    F*CK!

    Good of you to notice and report this, it looks like it's been broken for over 8 months!

    fixed here: https://github.com/fuel/core/commit/c3291ebf6e14ad1af6dafa5047e3e8b4058dbcb7
  • in my first post i metioned TemplateController's template property. i didnt work it when i change value different than "template". this was second :)

    nice to see that fixed..

Howdy, Stranger!

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

In this Discussion