Starting a new thread since I have a new question.
Plan is to have Rails as the web services server and PHP as client.
What I’m trying to figure out is at one point in the request does
“respond_to” know when it’s being called.
Example, I have a state controller, with a list action:
StateController:
def list @state = State.find_all
respond_to do |wants|
wants.html
wants.xml { render :xml => @state.to_xml}
end
Now the php makes a request to the server (using REST) via curl -
So this establishes the curl session. What I want to do is create a
conditional statement based on
the request coming in and Rails acting. I am trying not to send data
back
to php.
I know this is probably an insane question.
I do hope someone answers and knows something.
So this establishes the curl session. What I want to do is create a
conditional statement based on
the request coming in and Rails acting. I am trying not to send data back
to php.
I know this is probably an insane question.
I do hope someone answers and knows something.
I’m not sure what the question is, but GET /state/list.xml?results=8 so
respond_to knows to use the .xml block.
Another possibility which I read about on a thread at ruby- forum.com has some php pages living in side the Rails app’s public
directory. It was suggested as one possibility that you could use
sub-domains for the php.
In my case though I wonder if I could use sub-domains for Rails ?
For example , the link in the PHP menu might be www.mydomain.com/users . This would re-direct(?) to the Rails app .
Stuart
Hey Stuart-
I had to deal with this problem about a year and a half ago when i
built the yakimaherald.com website. There were still some php scripts
that were in use that weren’t worth rewriting at the time. The way I
did it was to have lighty setup like a normal rails/fcgi
configuration. And then tell lighty to also run any php scripts that
it find in /public. This works fine for simple integration stuff.
You could do the same thing now with apache2.2 and mod-proxy-
balancer. Just use the normal mongrel setup for the apache vhost and
add the php handler in as well. Then any call to a url that ends
in .php will serve the php page directly as long as its in public.
Migration via ‘Portal’
The PHP front end can also proxy through to the Rails applications running
behind the scenes. This makes the app feel a little like a portal, but
basically it is just a proxy. The front end can build the template (header,
footer, sidebars) and then call back to the Rails backend to get the main
content.
Either I"m missing something in what I’ve been told so far and read or
maybe I’m misinterpreting this article.
Another possibility which I read about on a thread at ruby-forum.com
has
some php pages living in side the Rails app’s public directory. It was
suggested as one possibility that you could use sub-domains for the php.
In my case though I wonder if I could use sub-domains for Rails ? For
example , the link in the PHP menu might be www.mydomain.com/users . This would re-direct(?) to the Rails app .
Stuart
What I’m trying to figure out is at one point in the request does
In my case though I wonder if I could use sub-domains for Rails ?
did it was to have lighty setup like a normal rails/fcgi
configuration. And then tell lighty to also run any php scripts that
it find in /public. This works fine for simple integration stuff.
You could do the same thing now with apache2.2 and mod-proxy-
balancer. Just use the normal mongrel setup for the apache vhost and
add the php handler in as well. Then any call to a url that ends
in .php will serve the php page directly as long as its in public.
It's all a bit fugly but it can be done.
public Rails public ? What if there are subdirectories. This has
numerous
directories for php
The question is really a way on how I can NOT have php pulling the data
and
delivering it but have PHP call into Rails and letting Rails takeover
delivering either a form to create a query and then rendering the
results ,
or rendering the results from a table.
Everything I’ve read and heard so far is that either using Rails as a
proxy
or using Web services, Rails sends the data requested back to PHP and
then
it’s up to PHP to format and return the data for presentation.
Migration via ‘Portal’
The PHP front end can also proxy through to the Rails applications
running
behind the scenes. This makes the app feel a little like a portal, but
basically it is just a proxy. The front end can build the template
(header,
footer, sidebars) and then call back to the Rails backend to get the
main
content.
Either I"m missing something in what I’ve been told so far and read or
maybe
I’m misinterpreting this article.
public Rails public ? What if there are subdirectories. This has
numerous directories for php
Stuart
Subdirectories are fine. You just need to have the front end
webserver always look for static files first before it send the
request to mongrel. If there is a static file with .php ext apache
will interpret the php and send it out. So yes it has to be in public
but it can be nested directories inside public. Its pretty nasty
though when you get a big mix of php code in your public dir.
The other side effect of this is that to make the php files work
with this method, the url always has to have the full url to the php
file including the .php ext.
– Ezra Z.
– Lead Rails Evangelist
– [email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)