* you CAN teach an old dog ... (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.

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 :)

-- 
Thomas 'Freaky' Hurst  -  freaky / aagh.net  -  http://www.aagh.net/