Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How to set status code in controller_template?
  • This question is so basic, so I feel myself stupido idioto...

    If I want set status, I have to forge Response object with that status code, but I must return it and my template will not be used with my content... I think it's stupid to set Response object to $this->template->content property and expect status code will be set, isn't it?

    How I have to set it?
  • HarroHarro
    Accepted Answer
    You mean the HTTP status code?

    A controller has a property called "response_status", so you can simply do

    $this->response_status = 403;

    This will be used when the Controllers' after() method constucts the Response object. Unless your controller method already returns a Response, in that case the status code of that object is used.
  • Thank you, Harro! it's useful.

Howdy, Stranger!

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

In this Discussion