Request helper

The previous post covers it but I’ll complement it with this post. I wrote a request helper which some may find useful. It’s fairly simple, you can retrieve all kinds of information on the current request.

request::accepts_xhtml();// test to see if the browser accepts xhtml or not (IE)
request::accepts_xml();
request::accepts_rss();
request::accepts_atom();
request::is_post(); //is request a post request
request::is_ajax(); //test if it's an ajax request, most js-frameworks support this
request::is_delete(); //delete request
request::is_get();
request::is_put();
request::accepts(); //returns array of all accepted content types


4 Responses to “Request helper”

  1. schnoodles Says:

    Very nice, and i find the code rather clean :)

  2. Vincent Voyer Says:

    Hello, it would be nice to have a “messages” helper, i had one in codeigniter :

    $this->messages->add(’Error in your password’,'error’);

    then on the page the error is displayed.

    using flashvariables.

  3. dlib Says:

    A message helper isn’t that hard to do. You could even do a messages:add_redirect(’error in password’,'user/login’); method. So you combine the redirect into the helper.

  4. sam.clark.name » Delivering intuitive content Says:

    [...] and XML side by side with no special API controller. Using a new module for Kohana PHP written by Maarten Van Vliet called request_Core(), the controller will inspect the incoming request and automatically determine [...]

Leave a Comment