Search code examples
phpframeworksurl-routingconceptual

Is URL rewrite / routing (mod_rewrite) really necessary for a framework?


I've been writing PHP code for years. And now I have plenty of reusable modules -- for me at least. A typical classic-old-style developer :D. But now almost everybody using baked instant framework, and my modules not reusable anymore --to some extent. Most of current famous framework such CI, Zend, Cake, etc. and also should-be-simpler micro-framework such as Fat-free, Silex, MicroMVC, etc. utilize method called URL routing / URL rewrite or such.

But... do you think this fancy URL routing is REALLY necessary?

Let's consider this:

  • How much work needed to process this fancy method of complexities? Regular expression parsing uses relatively heavy computing isn't it? Is it worthed?
  • How often we write URL address / type it manually? Instead of click bookmarks and/or hyperlink?
  • Is it really search-engine friendly? I mean doesn't it OK for search engines indexing URL params?
  • Why BIG sites such as Google, Facebook, etc still using "path?var1=val1&var2=val2&..."?
  • How about different settings on different web servers? Apache/IIS/Nginx/Ligthy? Such as porting .htaccess to web.config and to another?? Doesn't it make more problem than more solution? (for debugging, etc)

What do you think? Should we keep on with that fancy URL routing? Or we better go back to [web] nature with [simpler] request params? Any respond appreciated.


Solution

    • computation costs of running URL through regular expressions arr mitigated by use of APC
    • it is not about manual URL entry
    • yes, it has impact in context of SEO
    • because they have to save each flop, your site does not have billions of requests per day
    • this is actually why front controllers are used instead of .htaccess for parsing URLs

    That should take care of your "points".

    And yes, we should keep on using "pretty URL" because a lot of people glance at the full URL, before they click on the link. People fee l safer, when they see the full and understandable URL.

    Also, quite a lot of professional PHP developers try to avoid the popular frameworks. Mostly because quality of said frameworks are really, really bad (even Symfony2, which is considered to be one of best available, has issues) in terms of code quality.

    Just because you use a framework, it does not make your application better. Instead you should be focusing on proper OOP, following the SOLID principles and adhering to Law of Demeter. MVC is just another design pattern, which actually solves separation of presentation of domain business logic.

    If you want to learn about MVC, read GUI Architectures by Martin Fowler.