# Bridge Ruby and PHP (in a CMS)?

**URL:** <https://rubytalk.org/t/bridge-ruby-and-php-in-a-cms/6391>\
**Category:** ruby-talk\
**Created:** [15 June 2003 23:10 UTC](https://rubytalk.org/t/bridge-ruby-and-php-in-a-cms/6391 "2003-06-15T23:10:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Its\_Me](https://avatars.discourse-cdn.com/v4/letter/i/958977/32.png) [@Its\_Me](https://rubytalk.org/u/Its_Me)\
**Post date:** [15 June 2003 23:10 UTC](https://rubytalk.org/t/bridge-ruby-and-php-in-a-cms/6391/1 "2003-06-15T23:10:24Z")

</div>

I have not found any CMS-like framework in Ruby, and may have to fall  
back on to something written in PHP.

Is it possible to have Ruby and PHP talk easily to each other on the  
server side, if I have mod-ruby and mod-php both installed?

Any pointers, or alternative suggestions, appreciated.

---

<div class="post-metadata">

**Author:** ![gabriele\_renzi4](https://avatars.discourse-cdn.com/v4/letter/g/e36b37/32.png) [@gabriele\_renzi4](https://rubytalk.org/u/gabriele_renzi4)\
**Post date:** [15 June 2003 23:30 UTC](https://rubytalk.org/t/bridge-ruby-and-php-in-a-cms/6391/2 "2003-06-15T23:30:37Z")

</div>

possibly, this could help?  
[http://raa.ruby-lang.org/list.rhtml?name=pruby](http://raa.ruby-lang.org/list.rhtml?name=pruby)  
pRuby is a glue code between PHP and Ruby

> **···**
>
> il 15 Jun 2003 15:54:09 -0700, [itsme213@hotmail.com](mailto:itsme213@hotmail.com) (you CAN teach an old dog …) ha scritto::
> 
> > I have not found any CMS-like framework in Ruby, and may have to fall  
> > back on to something written in PHP.
> > 
> > Is it possible to have Ruby and PHP talk easily to each other on the  
> > server side, if I have mod-ruby and mod-php both installed?
> > 
> > Any pointers, or alternative suggestions, appreciated.

---

<div class="post-metadata">

**Author:** ![Thomas\_Hurst](https://avatars.discourse-cdn.com/v4/letter/t/53a042/32.png) [@Thomas\_Hurst](https://rubytalk.org/u/Thomas_Hurst)\
**Post date:** [16 June 2003 12:25 UTC](https://rubytalk.org/t/bridge-ruby-and-php-in-a-cms/6391/3 "2003-06-16T12:25:11Z")

</div>

[http://www.aagh.net/projects/ruby-php-serialize](http://www.aagh.net/projects/ruby-php-serialize) may be helpful.

You can do things like:

class Meh  
attr\_accessor :wah,:feh  
def to\_assoc  
[[:wah,@wah],[:feh,@feh]]  
end  
end

bah = Meh.new  
bah.wah = “Sigh”  
bah.feh = 5.4321  
Foo = Struct.new(:foo,:bar,:wibble)  
File.open(‘cache’, ‘w’) do |f|  
PHP.serialize(Foo.new(  
[‘meh’, ‘moo’, 1234, false, true],  
{‘foo’ =\> ‘bar’, 1 =\> [‘a’, ‘b’, ‘c’]},  
bah))  
end

And on the PHP side:

class Foo {}  
class Meh {}

if ($fp = fopen(“cache”, “r+”))  
{  
$foo = unserialize(fread($fp, 65535));  
rewind($fp);

```
    print_r($foo);
    $foo->wibble->wah = "PHP suxx! Ruby rulez!!!1!1!1111111";
    fwrite($fp, serialize($foo));
    fclose($fp);

```

}

And back on Ruby:

File.open(“cache”) do |f|  
p PHP.unserialize(f.read)  
end

I suppose it might come in handy 🙂

> **···**
>
> - you CAN teach an old dog … ([itsme213@hotmail.com](mailto:itsme213@hotmail.com)) wrote:
> 
> > I have not found any CMS-like framework in Ruby, and may have to fall  
> > back on to something written in PHP.
> > 
> > Is it possible to have Ruby and PHP talk easily to each other on the  
> > server side, if I have mod-ruby and mod-php both installed?
> > 
> > Any pointers, or alternative suggestions, appreciated.
> 
> –  
> Thomas ‘Freaky’ Hurst - [freaky@aagh.net](mailto:freaky@aagh.net) - [http://www.aagh.net/](http://www.aagh.net/)
