What you could do, is just use rewriting to route all of them to the
same module / controller / action.
Then, in the action itself, just show the appropriate view. You could
name your scripts like:
users/books.phtml
users/books.api.phtml
users/books.mobile.phtml
and use a plugin to determine the appropriate postfix to use for the
templates based on the request.
On Dec 18, 2007, at 7:03 PM, sgrobins wrote:
Hello,
I am using Zend Framework to create my website. I have a typical
directory
setup (without modules). Here is an example of a url (user books is
just
something i came up with for this example):
http://mysite.com/user/books?userId=1
This goes to the UserController::booksAction function. The page
that gets
returned is the user's information along with all the books they have
entered.
Now I plan to have a REST webservice with somewhat the same
information. My
url I would like is: http://api.mysite.com/user/books?userId=1
I would like something similar for mobile:
http://mobile.mysite.com/user/books?userId=1
How would you recommend I setup the directory structure and
controller/actions to accomplish this? Obviously, with the current
setup I
have, all above urls will go to UserController::booksAction, but I
probably
want 3 different ones, since each will be returning different data
(at the
very least different formats, but probably slightly different data
too). I
obviously want all three sites to use the same models I have written
for a
User and for a Book.
Here are some options I came up with, but I am wondering if there is
something better:
1) I was thinking I could have three different bootstrap files, one
for each
site. And then place all my models (which currently live in
.../application/default/models) to some general location that for
all three
sites to use.
2) I could change my urls to now use modules instead, so they would
look
like:
http://mysite.com/default/user/books?userId=1
http://mysite.com/api/user/books?userId=1
http://mysite.com/mobile/user/books?userId=1
Then create the directory structure as:
.../application/default/controllers
.../application/api/controllers
.../application/mobile/controllers
and place my models somewhere for all to see: .../models/User.php
3) Inside the UserController::booksAction function determine which
site I am
on (website, api, or mobile) and then send to the appropriate page
to view.
4) other? how are other people doing this?
Thanks,
Shawn
--
View this message in context:
http://www.nabble.com/creating-webservices-mobile-framework-with-current-site-tp14408497s16154p14408497.html
Sent from the Zend Framework mailing list archive at Nabble.com.