Url object Handling Url as an object
#1
Posted 30 April 2012 - 07:29 AM
Hello ppl,
Do you think it would be nice to introduce a Url object in the yii 2.0. This would be used internally in CUrlManager and CHttpRequest but it would hold the logic and functionality around urls like:
- Creating a PATH or GET url ( currently in CUrlManager )
- Be able to getRequestUri from a url ( part of the CHttpRequest ), so people would be able to handle url with common Yii functions.
Please let me know what you think about it. It's just a draft thought.
Friendly and geeky.
#3
Posted 30 April 2012 - 07:43 AM
#4
Posted 30 April 2012 - 07:53 AM
I'm currently experimenting with phpnode's work on a CHttpResponse class and had about the same idea. I left the URLs as strings eventualy. It looked a lot like bloat to me. And ... yeah, well, what phpnode said: There's always parse_url().
#5
Posted 30 April 2012 - 07:57 AM
I want to consume an api that has PATH format instead of GET. So I have 'http://some.api.com/' and an array like array('user'=>1) where 1 the id of the user. How can I create it ? Of course there is a php way but wouldn't be nice to be able to have a yii premade infastructure for this stuff?
#6
Posted 30 April 2012 - 08:02 AM
#7
Posted 30 April 2012 - 08:05 AM
#8
Posted 30 April 2012 - 08:10 AM
#9
Posted 30 April 2012 - 08:16 AM
#10
Posted 30 April 2012 - 08:18 AM
Anyway, I might have actually found a purpose for this class: It could be useful if you want to add/remove GET-params dynamicaly from a URL.
#12
Posted 30 April 2012 - 08:27 AM
#13
Posted 30 April 2012 - 05:25 PM
Eye-catching from the API: Support for port, userinfo (both missing in horde_url) and a whole lot seems to be about encoding.
For a recent project, I searched a way to transform a relative URL into an absolute one. Think this would be another candidate for such a class. In the end, I used this: http://sourceforge.n...ts/absoluteurl/
#14
Posted 01 May 2012 - 03:38 AM
tydeas_dr, on 30 April 2012 - 07:57 AM, said:
I want to consume an api that has PATH format instead of GET. So I have 'http://some.api.com/' and an array like array('user'=>1) where 1 the id of the user. How can I create it ? Of course there is a php way but wouldn't be nice to be able to have a yii premade infastructure for this stuff?
whats wrong with create url function?
$this->createUrl();

Quote
#15
Posted 21 May 2012 - 03:16 PM
Jaggi, on 01 May 2012 - 03:38 AM, said:
$this->createUrl();
As I said before
$this->createUrl()( God knows what $this refers to ) has to do with your Yii Application urls and not third party urls like REST service that you want to consume.

Help

This topic is locked












