SitePoint Sponsor

User Tag List

Results 1 to 18 of 18

Thread: RoR + PHP ?

  1. #1
    SitePoint Zealot janislanka's Avatar
    Join Date
    Sep 2004
    Location
    Lithuania
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    RoR + PHP ?

    I know that some of you might wonder WHY? but the question still is: Can RoR work together with PHP. The case: Some things developed in PHP and we would like to start working with Ruby and build things on top of it. Can it be done? Any good resources for that?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Rails has support for Web services so yeah. You can also use the same database between your ROR apps and your PHP apps.

    Other than that, there's not much else to know. You can't put PHP code in Ruby files and vice versa.

  3. #3
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yea, as well as webservices (which do incur a bit of an overhead with all the overhead what parsing XML etc), you can also have Ruby and PHP installed on the same machine, and simply use php for certain requests, and RoR for others, and simply share the the DB. I would assume that with Lighttpd that you can place php files in the ./public/ folder and let FCGI process them.

  4. #4
    SitePoint Zealot janislanka's Avatar
    Join Date
    Sep 2004
    Location
    Lithuania
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    any good resources and information more on that?

  5. #5
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by janislanka
    any good resources and information more on that?
    You might do well to be more specific. What is your concern?

    Sharing a database seems pretty straightforward, as does putting php files into the public directory. Are you worried about how to use the same sessions between two languages? That strikes me as potentially the trickiest part.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by samsm
    Are you worried about how to use the same sessions between two languages? That strikes me as potentially the trickiest part.
    I'd say cookies if you want to push it client-side, or throwing the session info into a database shared by both languages.

  7. #7
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yea, sessions are a pain, I forgot about that. My way to approach that is to again use the DB. However, I must say, I would try and where possible maybe work on things in a away so that one one of the two languages is needing sessions if I could. I'm not too keen on the cookies idea. Cookies are resitricted by size and have some security issues

  8. #8
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by janislanka
    any good resources and information more on that?
    Well I haven't done it my self, I'm just assuming that is possible based on my knowledge of how FCGi/ Lighttpd / PHP / Rails works.

    I do know if you wanna use FCGI in PHP, you'll need to tell it in configure using --enable-fcgi I think. You'll know if your PHP binary is FCGI compatible when you do a php -v as it will say fcgi as well as cli.

    When using either FCGI or CGI, you do need to be careful, certainly in CGI mode, PHP doesn't have all the environment variables and other similar vars that you sometimes find under Apache's mod_PHP. I can't remember the exact differences are, but I am aware it might be a gottcha if you have assumed certain variables exist say in the environment etc.

    Basically, if you get FCGI/PHP working under Lighttpd, there's no reason why you can't put PHP scripts in the ./public folder of your rails project. As others have suggested, sessions are also a catch.

  9. #9
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The real question is, integration with legacy apps aside, why would you want to use PHP as well as RoR?

  10. #10
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Luke Redpath
    The real question is, integration with legacy apps aside, why would you want to use PHP as well as RoR?
    Including legacy apps, this situation reminded me of the story of the guy who wanted to try out Rails, so he attempted to rewrite the Java app he had been working on for 6 months with Rails. Four days later, most of it was done.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  11. #11
    SitePoint Zealot janislanka's Avatar
    Join Date
    Sep 2004
    Location
    Lithuania
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samsm
    Including legacy apps, this situation reminded me of the story of the guy who wanted to try out Rails, so he attempted to rewrite the Java app he had been working on for 6 months with Rails. Four days later, most of it was done.
    Interesting that you said that. We were debating about Java vs. Ruby and how Java is moving ahead in may ways. Do you remember where you read that story about that guy?

  12. #12
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    basically I see such php+RoR need in projects that
    - lack RoR programmers , so certain modules are built with php
    - RoR lacks certain features that are available in php, which natural because of maturity

    As for Java vs RoR story, might be true if he never judged the result quality and scalability. And.. if he did Java the hard way .. These days JSF itself saves tons of time, not to mention a lot of RAD tools already available.

  13. #13
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samsm
    Including legacy apps, this situation reminded me of the story of the guy who wanted to try out Rails, so he attempted to rewrite the Java app he had been working on for 6 months with Rails. Four days later, most of it was done.
    Along similar lines, with a very balanced look at things:

    http://www.relevancellc.com/blogs/?p=31

  14. #14
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gpikelis
    basically I see such php+RoR need in projects that
    - lack RoR programmers , so certain modules are built with php
    - RoR lacks certain features that are available in php, which natural because of maturity
    Building some of your app in RoR and some in PHP sounds like a complete maintenance and interoperability nightmare. If you need more RoR programmers hire them, or get the PHP guys to learn it. If they any good it shouldn't take them more than a week or two to get up and running with at least the basics of Rails and Ruby, and they'll learn more as the project goes along. Bottom line when it comes to mixing PHP/RoR in this way, my advice...don't do it. Pick a platform and stick to it, or you'll regret it.

    Regarding your second point, name those features otherwise its not really an argument. I can't think of anything I've been doing in Rails when I've thought, "damn I wish it had xxxx like PHP". Ruby libraries are fewer in number, but higher in quality, I've found.

  15. #15
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by janislanka
    Interesting that you said that. We were debating about Java vs. Ruby and how Java is moving ahead in may ways. Do you remember where you read that story about that guy?
    It was Justin Gehtland, and the link Luke provided is the story I was recalling.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  16. #16
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This reminds me very much when we first started looking at Rails in my old job. Certainly one of the options we thought about was migrating a PHP app slowly to Rails. In the end, while it was a bit of a nightmare for a few weeks, it was well woth just moving the whole thing to Rails in one go; in the long run it saved a lot of hassle.

  17. #17
    SitePoint Member Arto's Avatar
    Join Date
    Mar 2005
    Location
    Spain
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Though I've been riding the Rails for a while now, I think PHP still has some use in writing quick 'n dirty "throw-away" web scripts for which Rails would simply be overkill.

    However, the new Camping Microframework for Ruby may balance things out a bit. It's a sort of micro-Rails, and while I haven't had a chance to try it out yet, it looks darned impressive for situations where you need a script up and running in an hour, and don't want to play around with FastCGI deployments etc.

    Anyone tried it yet?

  18. #18
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think even DHH will even agree here that, PHP still has a role. As Arto suggested, PHP does seem to work well in situations where you want simple disposable code, and you know for certain that the site will not need to evolve into anything complex.

    The thing where PHP comes in handy is with sites with lots of static content, and maybe the odd contact form mailer. However, saying that, PHP as a language is a lot heavier than Ruby, and probably less functional imo


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •