Yii Framework Forum: Create REST Web Service - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Create REST Web Service Rate Topic: -----

#1 User is offline   jadent 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 09-October 10

Posted 09 October 2010 - 06:13 PM

How do you create a REST based web service using YII? I've seen the question asked but no answers nor can i find any tutorials anywhere?

ty
0

#2 User is offline   aphelio 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 04-October 10

Posted 13 October 2010 - 11:21 PM

Applications written with the Yii Framework will likely have RESTful qualities. The thought behind REST is that a concise and uniform vocabulary is provided to a client. Yii applications typically return HTML messages, in which case the client is a browser. You may be interested in returning other internet media types like JSON or XML for consumption by other applications. Check out the URI management capabilities that Yii offers:

Yii URI Management

A great step toward designing your RESTful application is planning the structure of your requests. The format of your responses will certainly depend on what is consuming the service.

Cheers!
0

#3 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 3,710
  • Joined: 10-October 10
  • Location:Denmark

Posted 13 October 2010 - 11:29 PM

If you're able to use SOAP, here's what the Definitive Yii Guide has to say:
http://www.yiiframew...pics.webservice
Would be cool to have other options, but it's better than nothing. ;)
"Less noise - more signal"
1

#4 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 3,710
  • Joined: 10-October 10
  • Location:Denmark

Posted 14 October 2010 - 02:43 AM

There is a patch at Google code:
http://code.google.c...s/detail?id=802
"Less noise - more signal"
1

#5 User is offline   aphelio 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 04-October 10

Posted 22 October 2010 - 11:03 AM

Thanks for posting that patch, jacmoe. I haven't tried it yet, but it looks promising. That's one of those things that would be nice to see in the core.
0

#6 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 18 December 2010 - 11:53 PM

I've just created an extension to route url's based on requested method
Its here if interests you
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#7 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 20 January 2011 - 04:20 AM

Gustavo, jacmoe - it seems you interested in Yii+REST. I searched throw forum posts and found that most threads only mention url management (including Gustavo's extension and recently fixed issue 802).

But as I understand when we receive PUT or DELETE request we have no access to the request parameters using standard methods. PHP does not populates these requests into superglobals as $_GET and $_POST and Yii's CHttpRequest also deals with GET and POST only.

Am I wrong? Maybe I missing something, but it seems like for most people first part (url management) is enough. How the second part (get request parameters) is usually solved?
I now have CHttpRequest subclass and use file_get_contents('php://input') to get PUT/DELETE parameters and this is discussed only here.

So maybe there is a simpler method to do this?
0

#8 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 20 January 2011 - 09:04 AM

You are right
I actually extended the CHttpRequest to fit my needs, pretty much doing what the guy says in the link you posted
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#9 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 20 January 2011 - 12:46 PM

Yes, I am extending CHttpRequest too and use input parsing.
There is one more thing in the link I posted above - Qiang promised to add support for REST to the Yii and now support is added to the url manager, but not to the CHttpRequest.
So I think we should add one more ticket and ask for this. What do you think?
0

#10 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 20 January 2011 - 02:03 PM

Yeah, it is a good idea
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#11 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 21 January 2011 - 09:36 AM

Added - issue 2024
0

#12 User is offline   el chief 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 24-November 10

Posted 21 January 2011 - 03:30 PM

View Postjacmoe, on 13 October 2010 - 11:29 PM, said:

If you're able to use SOAP, here's what the Definitive Yii Guide has to say:
http://www.yiiframew...pics.webservice
Would be cool to have other options, but it's better than nothing. ;)


Do not use SOAP if you can avoid it. It is awful. Do not use XML if you can avoid it. It is awful.
http://learnyii.blogspot.com/

Quick snippets to get you up to speed with the Yii PHP framework
1

#13 User is offline   zardon 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 14-February 11

Posted 14 February 2011 - 02:16 PM

I am interested in finding tutorials, source code or video on how to create your own RESTful API (Server or Client) using YII.

I want to build a REST API (Server) that delivers JSON for a mobile iPhone application, but I really do not know where to start; or if YII will help me or how.

Has anyone built an API using YII? Where do I start?

Thanks.
0

#14 User is offline   intel352 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 196
  • Joined: 05-February 10
  • Location:Southport, NC

Posted 25 May 2011 - 03:04 PM

View Postzardon, on 14 February 2011 - 02:16 PM, said:

I am interested in finding tutorials, source code or video on how to create your own RESTful API (Server or Client) using YII.

I want to build a REST API (Server) that delivers JSON for a mobile iPhone application, but I really do not know where to start; or if YII will help me or how.

Has anyone built an API using YII? Where do I start?

Thanks.


http://www.yiiframew...ate-a-rest-api/
Need live Yii support? - Join the #yii IRC channel on Freenode!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users