Hi, Thank you very much for your answer. It helped me a lot... :)

Now I have another doubt. The following is my routing entry.

api_test:
  url:    /rest/:param1/:param2/:param3/test.:sf_format
  class:  sfDoctrineRoute
  param:  { module: rest, action: testing, sf_format: json }
  options:  { model: Stbuser, generate_shortest_url: true, type: list,
method: getTest }

And in my action class U have the following method...

  public function executeTesting(sfWebRequest $request)
  {
      $params = $request->getGetParameters();
      //print_r($params);
      $this->stbusers = $this->getRoute()->getObjects();
  }

The parameters (:param1/:param2/:param3) I declared in the routing
file is not getting in this method (action class's method). Is there
any way to get these parameters in the action class's trap method?
Only parameters passed as query string is getting in this method.
Like

http://localhost/restwebservice/rest/p1/p2/p3/test.json?start=1&count=10

Only the start and count is getting here. p1,p2,p3 are not getting..
is there problem here? Or it could not be possible?

But in the getTest method of the model class (the method I mentioned
in the routing file) the parameters are getting?

regards
Shihab

On Sep 1, 1:46 pm, Gareth McCumskey <gmccums...@gmail.com> wrote:
> Ok let me just ad as well that the best way we found to do it was to create
> a module per resource. So for example if you need a rest api to manage cars,
> trucks and motorcycles you would create a module called "car", another
> called "truck" and another called "motorcycle".
>
> Then each module has an actions.class.php file within which you can "trap"
> the request method in order to know what to do with the resource; i.e. if
> the car module is called as a GET request with no parameters passed, you
> return a list. If the car module is called as a GET request with an id
> parameters passed you return one resource. If the car module is called as a
> POST request then you will be inserting a new resource. PUT will do updates
> and DELETE requests will obviously delete.
>
> The entire REST methodology is based on a combination of URI components and
> request types.
>
>
>
>
>
> On Wed, Sep 1, 2010 at 9:13 AM, Shihab KB <shiha...@gmail.com> wrote:
> > Can you check this routing is correct?
>
> > api_createuser:
> >  url:    /rest/userregistration.:sf_format
> >  class:  sfDoctrineRoute
> >  param:  { module: rest, action: user, sf_format: json }
> >  options:  { model: Stbuser, type: object }
> >  requirements:
> >    sf_method: post
>
> > And in the action class I create a function for this. It is not
> > working
>
> >  public function executeUser(sfWebRequest $request)
> >  {
> >      if ($request->isMethod('post')) {
> >          print_r($request);
> >      }
> >  }
> > used this url for accessing this api.
>
> >http://localhost/restwebservice/rest/userregistration
>
> > But for GET I create the routing entry as given below and it working
> > fine with the urlhttp://localhost/restwebservice/rest/women.
>
> > api_women:
> >  url:    /rest/women.:sf_format
> >  class:  sfDoctrineRoute
> >  param:  { module: rest, action: women, sf_format: json }
> >  options:  { model: Women, type: list, method: getWomens }
> >  requirements:
> >    sf_format: (?:xml|json)
>
> > On Aug 31, 5:55 pm, Gareth McCumskey <gmccums...@gmail.com> wrote:
> > > There is no need to worry about routing as you can handle REST request
> > all
> > > within the index action (or whatever other default action you may have
> > > already setup in your routing for modules) and do checks on whether an
> > > incoming is a post request. For example:
>
> > > public function executeIndex (sfWebRequest $request)
> > > {
> > >   if ($request->isMethod('post'))
> > >   {
> > >      $post_parameters = $request->getPostParameters();
> > >      $this->processPostRequest($post_parameters);
> > >   }
> > >   else if ($request->isMethod('get'))
> > >   {
> > >      $get_parameters = $request->getGetParameters();
> > >      $this->processGetRequest($get_parameters);
> > >   }
>
> > > }
>
> > > public function processPostRequest($parameters)
> > > {
>
> > >   //Whatever code here you need to do whatever you want with the post
> > > parameters
>
> > > }
>
> > > public function processGetRequest($parameters)
> > > {
>
> > >   //Whatever code here you need to do whatever you want with the get
> > > parameters
>
> > > }
> > > On Tue, Aug 31, 2010 at 2:00 PM, Shihab KB <shiha...@gmail.com> wrote:
> > > > Dear friends,
>
> > > > I would like to do one REST API for creating a users by POST method. I
> > > > am new to REST, php & symfony. I just now created a rest api to get
> > > > uses from the database.
>
> > > > Can somebody help me by providing a samples for creating a rest api
> > > > with POST method... I request you to give me the entry in the routing
> > > > file, function to be created in the action class and templates. And
> > > > some test code also. Can you please help me.
>
> > > > regards
> > > > Shihab
>
> > > > --
> > > > If you want to report a vulnerability issue on symfony, please send it
> > to
> > > > security at symfony-project.com
>
> > > > You received this message because you are subscribed to the Google
> > > > Groups "symfony users" group.
> > > > To post to this group, send email to symfony-users@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@goog­legroups.com>
> > <symfony-users%2bunsubscr...@goog­legroups.com>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/symfony-users?hl=en
>
> > > --
> > > Gareth McCumskeyhttp://garethmccumskey.blogspot.com
> > > twitter: @garethmcc- Hide quoted text -
>
> > > - Show quoted text -
>
> > --
> > If you want to report a vulnerability issue on symfony, please send it to
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to symfony-users@googlegroups.com
> > To unsubscribe from this group, send email to
> > symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@goog­legroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en
>
> --
> Gareth McCumskeyhttp://garethmccumskey.blogspot.com
> twitter: @garethmcc- Hide quoted text -
>
> - Show quoted text -

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to