Jump to content

URL routes. Dynamic or harcoded


coder_

Recommended Posts

Hor the last couple of weeks, my colleague and are in a discussion about framework's url routing. What do you think, which is better way to do the job. Dynamicaly checking route for for existing module/controller/action with no predefined routes or "hardcoded" route setting like it's done in zend framework.

 

I know that both ways have their pros and cons, but i want to know other side. Other opinion.

 

I noticed that every known framework uses the second, defined url route way. Where you directlly specify all application's routes.

 

<?php

$route = new Route('route_name', '/url/route/:some_variable', array('controller' => 'url', 'action' => 'route'));

Link to comment
Share on other sites

No, ZF does not use named routes only (unfortunately). There's the implied, unnamed route. Named routes (I wouldn't call them "hardcoded") have the advantage of some decoupling. You can change the routing and keep the handle, not having to change any controllers or views.

Link to comment
Share on other sites

No, ZF does not use named routes only (unfortunately). There's the implied, unnamed route. Named routes (I wouldn't call them "hardcoded") have the advantage of some decoupling. You can change the routing and keep the handle, not having to change any controllers or views.

 

Ok, i know that zf has the ability of using unnamed routes, and thanks for the correction.

 

But, what i would likt to hear from you is what way do like to implement. Named (predefined) or unnamed routing?

Link to comment
Share on other sites

shouldn't this have been posted in application design?

 

i'm in the process of writing my own framework...i know it's not good to reinvent the wheel but i'm just not happy with the way most frameworks in PHP are implemented.

 

but yeah, i would say i prefer named routes.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.