Hari K T
|Regarding your opinion on routing at PHP level, I disagree.|
Apache may be fast to perform the routing based on mod_rewrite, but hard for people to write the htaccess rules. PHP is much easier and if you still strongly feel the neeed for faster performance route why not a C implementation like Pux can be introduced ?
Benchmark with PHP routes.
|2014-02-12 04:28:52 - In reply to message 1 from Hari K T|
|No, there is no need to use mod_rewrite to do routing with Apache. Look at PHP Clases URLs, there are no .php URLs. mod_rewrite is never used.|
It is a old trick of Apache that it is explained here.
It can't be simpler than this. Requests are directed to the scripts that run your controllers. There is no need for front controllers to look at the URLs and match them against any of the controller URL patterns you need to match.
I may end up writing an article about this because you framework fans always assume the framework you are in love with is the best for everything. Consider the fact that you may not know all the best techniques.
Hari K T
|2014-02-12 06:22:59 - In reply to message 2 from Manuel Lemos|
|> Consider the fact that you may not know all the best techniques.|
Manuel Lemo, I agree with you. I don't really know all the best techniques and I am learning each day. But I still didn't get what you were telling in the thread.
It will be good if we can show some example.
If you are trying to explain like
1) Create the router object
2) add a route with the controller, action values.
3 ) Match the route based on thr request and dispatch it, then it is same as what Aura.Router is doing.
It is not full framework, but just components.
github.com/auraphp/Aura.Router/#dis ... and what I have pointed to Pux or many similar components are doing.
I will wait for your example to see how the best way / technique you are mentioning.
|2014-02-12 06:27:06 - In reply to message 3 from Hari K T|
|What I mean is that if you put in your Apache configuration something like this, you will be telling that all requests to URLs that start with /blog/ will be handled by a PHP script named blog. In that PHP script named blog you just call your blog controller classes. No front controllers or mod_rewrite are needed.|
Hari K T
|2014-02-12 06:45:00 - In reply to message 4 from Manuel Lemos|
|Thank you for the information.|
I was not aware of this. But this has its own drawback if you at some point of time want to move to ngix or some other.
I don't know the real speed you are getting with this sort of technique though.
|2014-02-12 06:51:30 - In reply to message 5 from Hari K T|
|That is the thing Rasmus was trying to make people pay more attention.|
If you are using a certain setup, Apache for instance, it does not make sense to optimize for a different setup that is not what you are running.
If you are using MySQL, why are you checking on every request the type of database you are using? It won't change, so optimize for it.
Anyway, if you change to nginx one day, I don't know if there is anything like SetHandler for nginx, but in the worst case you can use their equivalent for mod_rewrite and make your request to /blog/* be handled as if they were going to /blog.php/* .