I am inheriting a legacy PHP website and I want to add a few Rails pages. Is there anyone who can recommend some info on how to add RoR to a PHP-driven website? Ralph Shnelvar -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 6, 2012, at 3:53 PM, Ralph Shnelvar wrote:> I am inheriting a legacy PHP website and I want to add a few Rails pages. > > Is there anyone who can recommend some info on how to add RoR to a PHP-driven website?I''ve never tried this, but if you''re using Passenger, it seems likely that you could add the handler directive to your Apache configuration (or maybe it would inherit the php handler stuff if the server can already host php by default) and then put the entire PHP site in the public folder. Just make sure that you don''t clobber any of your routes, and it should work fine. If you''re not hitting the same database with PHP and Rails, you could possibly get away with as little as that. Walter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yea, I would even consider keeping the existing PHP app at "www.xyz.com" and making your Rails app "services.xyz.com" or something like that But Walter''s hack might work. Alternatively there''s some fancy mod_rewrite I''m sure apache will do to direct request to the right app. But consider that PHP and Rails are mostly different technologies and you should have no expectation that they will work "together" -- what you''re trying to do is a hack and probably should only be done if absolutely necessary and/or as a band-aid fix. On Apr 6, 2012, at 4:14 PM, Walter Lee Davis wrote:> > On Apr 6, 2012, at 3:53 PM, Ralph Shnelvar wrote: > >> I am inheriting a legacy PHP website and I want to add a few Rails pages. >> >> Is there anyone who can recommend some info on how to add RoR to a PHP-driven website? > > I''ve never tried this, but if you''re using Passenger, it seems likely that you could add the handler directive to your Apache configuration (or maybe it would inherit the php handler stuff if the server can already host php by default) and then put the entire PHP site in the public folder. Just make sure that you don''t clobber any of your routes, and it should work fine. If you''re not hitting the same database with PHP and Rails, you could possibly get away with as little as that. > > Walter > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Apr 6, 2012 at 4:53 PM, Ralph Shnelvar <ralphs-bVGy8FV858MAvxtiuMwx3w@public.gmane.org> wrote:> I am inheriting a legacy PHP website and I want to add a few Rails pages. > > Is there anyone who can recommend some info on how to add RoR to a PHP-driven website? >At the risk of going Off Topic, I would ask why on earth would you do that? *I think* that''s a terrible idea. Debugging and maintenance WILL hurt you. Not to mention that every somebody does that kind of things a baby Panda dies. -- Leonardo Mateo. There''s no place like ~ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jason, Friday, April 6, 2012, 2:18:53 PM, you wrote: JFB> Yea, I would even consider keeping the existing PHP app at "www.xyz.com" and making your Rails app "services.xyz.com" or something like that JFB> But Walter''s hack might work. Alternatively there''s some fancy mod_rewrite I''m sure apache will do to direct request to the right app. JFB> But consider that PHP and Rails are mostly different technologies and you should have no expectation that they will work "together" -- what you''re trying to do is a hack and probably should only be done if absolutely necessary and/or as a band-aid fix. JFB> On Apr 6, 2012, at 4:14 PM, Walter Lee Davis wrote:>> >> On Apr 6, 2012, at 3:53 PM, Ralph Shnelvar wrote: >> >>> I am inheriting a legacy PHP website and I want to add a few Rails pages. >>> >>> Is there anyone who can recommend some info on how to add RoR to a PHP-driven website? >> >> I''ve never tried this, but if you''re using Passenger, it seems likely that you could add the handler directive to your Apache configuration (or maybe it would inherit the php handler stuff if the server can already host php by default) and then put the entire PHP site in the public folder. Just make sure that you don''t clobber any of your routes, and it should work fine. If you''re not hitting the same database with PHP and Rails, you could possibly get away with as little as that. >> >> Walter >> >> -- >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >> >>What a simple and wonderful idea! Thanks!!! Ralph Shnelvar -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
PHP + Ruby = Phuby =) https://github.com/tenderlove/phuby http://www.youtube.com/watch?v=4_zq9oW71sg 2012/4/6 Ralph Shnelvar <ralphs-bVGy8FV858MAvxtiuMwx3w@public.gmane.org>> Jason, > > Friday, April 6, 2012, 2:18:53 PM, you wrote: > > > JFB> Yea, I would even consider keeping the existing PHP app at " > www.xyz.com" and making your Rails app "services.xyz.com" or something > like that > > JFB> But Walter''s hack might work. Alternatively there''s some fancy > mod_rewrite I''m sure apache will do to direct request to the right app. > > JFB> But consider that PHP and Rails are mostly different technologies and > you should have no expectation that they will work "together" -- what > you''re trying to do is a hack and probably should only be done if > absolutely necessary and/or as a band-aid fix. > > > > > JFB> On Apr 6, 2012, at 4:14 PM, Walter Lee Davis wrote: > > >> > >> On Apr 6, 2012, at 3:53 PM, Ralph Shnelvar wrote: > >> > >>> I am inheriting a legacy PHP website and I want to add a few Rails > pages. > >>> > >>> Is there anyone who can recommend some info on how to add RoR to a > PHP-driven website? > >> > >> I''ve never tried this, but if you''re using Passenger, it seems likely > that you could add the handler directive to your Apache configuration (or > maybe it would inherit the php handler stuff if the server can already host > php by default) and then put the entire PHP site in the public folder. Just > make sure that you don''t clobber any of your routes, and it should work > fine. If you''re not hitting the same database with PHP and Rails, you could > possibly get away with as little as that. > >> > >> Walter > >> > >> -- > >> You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >> > >> > > > What a simple and wonderful idea! Thanks!!! > > Ralph Shnelvar > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Fernando Almeida www.fernandoalmeida.net -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Friday, 6 April 2012 15:53:13 UTC-4, RalphShnelvar wrote:> > I am inheriting a legacy PHP website and I want to add a few Rails pages. > > Is there anyone who can recommend some info on how to add RoR to a > PHP-driven website? > > Ralph Shnelvar >Depends on what you mean by "PHP-driven" - if it''s doing its own URL rewriting (Wordpress''s clean URLs, for instance) you''re probably best served putting the Rails stuff on a subdomain or in a subdirectory. On the other hand, if it''s a plain PHP site where URLs just end in .php everywhere, you can do some mod_rewrite magic (tune the paths as appropriate): RewriteCond /home/web/public_html/%{REQUEST_URI} -f RewriteRule ^(.*) /home/web/public_html/$1 [QSA,L] RewriteCond /home/web/public_html/%{REQUEST_URI}/index.php -f RewriteRule ^(.*) /home/web/public_html/$1/index.php [QSA,L] Then point your DocumentRoot to the public dir in your Rails app, as Passenger''s instructions indicate, and add this: <Directory /home/web/public_html> PassengerEngine off </Directory> to the Apache config as well, to avoid confusing Passenger with stuff in PHP-land. The result will be that any incoming URL which matches either an actual PHP file, or a directory with an index.php file will be handled by PHP, while everything else goes to the Rails app. One other thing - for additional integration, you may want to access the PHP session from the Rails app. (Going the other way is NOT recommended, as you''d need to be able to un-Marshal Ruby objects in PHP) To do this, you''ll need a gem like php-serialize (https://github.com/jqr/php-serialize) and you''ll need to find where your particular PHP installation stores session data - sometimes this is in /tmp, sometimes elsewhere. The files are typically named after the session token (found in "cookies[''PHPSESSID'']" in your controllers). PHP does some locking to avoid multiple writers messing the whole thing up, but I''ve only ever needed to *read* from the PHP session, so I''m not sure exactly how that works. Hope this helps! --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/FAV9sfY553sJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><title>Re: [Rails] Re: Rails & PHP</title> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- body { margin: 5px 5px 5px 5px; background-color: #ffffff; } /* ========== Text Styles ========== */ hr { color: #000000} body, table /* Normal text */ { font-size: 9pt; font-family: ''Courier New''; font-style: normal; font-weight: normal; color: #000000; text-decoration: none; } span.rvts1 /* Heading */ { font-size: 10pt; font-family: ''Arial''; font-weight: bold; color: #0000ff; } span.rvts2 /* Subheading */ { font-size: 10pt; font-family: ''Arial''; font-weight: bold; color: #000080; } span.rvts3 /* Keywords */ { font-size: 10pt; font-family: ''Arial''; font-style: italic; color: #800000; } a.rvts4, span.rvts4 /* Jump 1 */ { font-size: 10pt; font-family: ''Arial''; color: #008000; text-decoration: underline; } a.rvts5, span.rvts5 /* Jump 2 */ { font-size: 10pt; font-family: ''Arial''; color: #008000; text-decoration: underline; } span.rvts6 { font-size: 8pt; font-family: ''segoe ui''; } a.rvts7, span.rvts7 { font-size: 8pt; font-family: ''segoe ui''; color: #0000ff; background-color: #ffffff; text-decoration: underline; } span.rvts8 { font-size: 8pt; font-family: ''arial''; font-style: italic; color: #c0c0c0; } a.rvts9, span.rvts9 { font-size: 8pt; font-family: ''arial''; color: #0000ff; text-decoration: underline; } /* ========== Para Styles ========== */ p,ul,ol /* Paragraph Style */ { text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; } .rvps1 /* Centered */ { text-align: center; } --></style> </head> <body> <p>Matt,</p> <p><br></p> <p>Saturday, April 7, 2012, 1:43:46 PM, you wrote:</p> <p><br></p> <div><table border=0 cellpadding=1 cellspacing=2 style="background-color: #ffffff;"> <tr valign=top> <td width=2 style="background-color: #0000ff;"><br> </td> <td width=1467> <p><br></p> <p><br></p> <p><span class=rvts6>On Friday, 6 April 2012 15:53:13 UTC-4, RalphShnelvar wrote:</span></p> <p><span class=rvts6>I am inheriting a legacy PHP website and I want to add a few Rails pages.</span></p> <p><span class=rvts6>Is there anyone who can recommend some info on how to add RoR to a PHP-driven website?</span></p> <p><span class=rvts6>Ralph Shnelvar</span></p> <p><br></p> <p><span class=rvts6>Depends on what you mean by "PHP-driven" - if it''s doing its own URL rewriting (Wordpress''s clean URLs, for instance) you''re probably best served putting the Rails stuff on a subdomain or in a subdirectory.</span></p> <p><br></p> <p><span class=rvts6>On the other hand, if it''s a plain PHP site where URLs just end in .php everywhere, you can do some mod_rewrite magic (tune the paths as appropriate):</span></p> <p><br></p> <p><span class=rvts6> RewriteCond /home/web/public_html/%{REQUEST_URI} -f</span></p> <p><span class=rvts6> RewriteRule ^(.*) /home/web/public_html/$1 [QSA,L]</span></p> <p><span class=rvts6> RewriteCond /home/web/public_html/%{REQUEST_URI}/index.php -f</span></p> <p><span class=rvts6> RewriteRule ^(.*) /home/web/public_html/$1/index.php [QSA,L]</span></p> <p><br></p> <p><span class=rvts6>Then point your DocumentRoot to the public dir in your Rails app, as Passenger''s instructions indicate, and add this:</span></p> <p><br></p> <p><span class=rvts6> <Directory /home/web/public_html></span></p> <p><span class=rvts6> PassengerEngine off</span></p> <p><span class=rvts6> </Directory></span></p> <p><br></p> <p><span class=rvts6>to the Apache config as well, to avoid confusing Passenger with stuff in PHP-land. The result will be that any incoming URL which matches either an actual PHP file, or a directory with an index.php file will be handled by PHP, while everything else goes to the Rails app.</span></p> <p><br></p> <p><span class=rvts6>One other thing - for additional integration, you may want to access the PHP session from the Rails app. (Going the other way is NOT recommended, as you''d need to be able to un-Marshal Ruby objects in PHP) To do this, you''ll need a gem like php-serialize (https://github.com/jqr/php-serialize) and you''ll need to find where your particular PHP installation stores session data - sometimes this is in /tmp, sometimes elsewhere. The files are typically named after the session token (found in "cookies[''PHPSESSID'']" in your controllers). PHP does some locking to avoid multiple writers messing the whole thing up, but I''ve only ever needed to *read* from the PHP session, so I''m not sure exactly how that works.</span></p> <p><br></p> <p><span class=rvts6>Hope this helps!</span></p> <p><br></p> <p><span class=rvts6>--Matt Jones</span></p> <p><span class=rvts6>-- </span></p> <p><span class=rvts6>You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.</span></p> <p><span class=rvts6>To view this discussion on the web visit </span><a class=rvts7 href="https://groups.google.com/d/msg/rubyonrails-talk/-/FAV9sfY553sJ">https://groups.google.com/d/msg/rubyonrails-talk/-/FAV9sfY553sJ</a><span class=rvts6>.</span></p> <p><span class=rvts6>To post to this group, send email to rubyonrails-talk@googlegroups.com.</span></p> <p><span class=rvts6>To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org</span></p> <p><span class=rvts6>For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.</span></p> </td> </tr> </table> </div> <p><br></p> <p>This is way over my head although I have some glimpses of understanding.</p> <p><br></p> <p>I thank you for taking the time to write all this tuff. I''ll save it and cogitate when I know a lot more.</p> <p><br></p> <p><br></p> <p><span class=rvts8>-- </span></p> <p><span class=rvts8>Best regards,</span></p> <p><span class=rvts8> Ralph </span><a class=rvts9 href="mailto:ralphs-bVGy8FV858MAvxtiuMwx3w@public.gmane.org">mailto:ralphs-bVGy8FV858MAvxtiuMwx3w@public.gmane.org</a></p> </body></html> <p></p> -- <br /> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.<br /> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org<br /> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.<br /> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.<br />