SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    I want my 4th arrow! garlinto's Avatar
    Join Date
    Jun 2002
    Location
    Riding the electron wave
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Confusion using Zend Framework's Rewrite Router

    I have been using the fantastic Zend Framework now for about 6 months and truly love it. A client recently approached me and requested that I design a web app for his company, and so I am in the process of doing so right now, but having a bit of difficulty.

    The hosting company my client is using does not have mod_rewrite enabled, nor will they enable it. It is my understanding that the Zend_Controller_Router_Rewrite class will work in just such a situation, but I am confused as to how to impliment it's functionality.

    For my own site, I use the:
    Code:
    http://example.com/controller/action/param_1/1/param_2/2/...
    url syntax and have really gotten used to it.

    However, I don't believe I will be able to use this syntax without mod_rewrite and the ability to bootstrap /index.php.

    I would really appreciate a little more of an explanation or at least a resource I can go to that will explain how to use Zend_Controller_Router_Rewrite in this situation. Of course, I have read over ZF's documentation on the subject, but I'm just not getting it.

    For example: Where do I setup the routes? Do I set them up in /index.php? Instead of using the above url syntax, do I need to use a conventional query string, i.e.
    Code:
    http://example.com/index.php?controller=foo&action=bar&param_1=1...
    and then manually feed the controller/action to the router? If so how?

    Thank you in advance for your help!
    Ducharme's Axiom: "If you view your problem closely
    enough, you will recognize yourself as part of the problem."


  2. #2
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    United Kingdom
    Posts
    208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can still use the 'pretty' url format, but you'd need to use the full url to the bootstrap, I think.
    Code:
    http://example.com/index.php/controller/action/param_1/1/param_2/2/...

  3. #3
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    The Controller component should soon work without mod_rewrite.
    Check the documentation.

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by garlinto View Post
    The hosting company my client is using does not have mod_rewrite enabled, nor will they enable it. It is my understanding that the Zend_Controller_Router_Rewrite class will work in just such a situation, but I am confused as to how to impliment it's functionality.
    As a side note to everything said from others, you can use ErrorDocument directive to redirect incoming requests to a front_controller (obviously it won't block direct access to existing scripts - but I guess even this is workaroundable).

    This kind of trick, though, it is not advisable, because it will pollute Apache's error log (you can still rotate the logs, at the cost of some performance loss).

    Tac

  5. #5
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tacone View Post
    This kind of trick, though, it is not advisable, because it will pollute Apache's error log (you can still rotate the logs, at the cost of some performance loss).
    I may remember it wrongly, but if you send the correct HTTP status code (200), I don't think it will end up in the logs?

  6. #6
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi garlinto, have you subscribed to any of the framework mailing lists? If not I'd suggest at least subscribing to the general one. Your question on there would not only likely get an answer but could well be feedback for the developers. You can find out more info at...

    http://framework.zend.com/wiki/displ...Zend+Framework

    You can also search the mailing list archives here...

    http://www.nabble.com/Zend-Framework...ty-f16154.html

    Hope that helps,

    Nick

  7. #7
    I want my 4th arrow! garlinto's Avatar
    Join Date
    Jun 2002
    Location
    Riding the electron wave
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you all for your help

    nicklo, thanks for the suggestion. I'm joining the mailing list as we speak. I do find some of the documentation to be directed to more advanced users, where assumptions are made regarding the level of understanding of the reader. Since I have only recently appreciated the benefits of developing under a framework, I still find myself learning the terminology and concepts as I go.

    Quote Originally Posted by jjshel
    Hi,
    The Controller component should soon work without mod_rewrite.
    Check the documentation.
    I read this earlier and am curious as to how would this work. Unless you are using mod_rewrite to bootstrap the front controller, if you made a request to
    Code:
    example.com/someController/someAction
    the server is going to look for
    Code:
    ./someController/someAction
    as part of the directory structure. How can you use purely PHP to act in place of mod_rewrite? Would the rewrite router have to be included in every controller?
    Ducharme's Axiom: "If you view your problem closely
    enough, you will recognize yourself as part of the problem."


  8. #8
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken View Post
    I may remember it wrongly, but if you send the correct HTTP status code (200), I don't think it will end up in the logs?
    It does anyway, on my localhost (ubuntu/apache2), no matter what header I send.

    Tac


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •