PhpCompat

Php functions all wrapped up in a ruby interface! Basically, when I get last minute 'we must migrate this huge PHP codebase to Ruby' projects, I'll use this compatibility layer, and do a huge SED replace on all available methods.
The methods that might be of most use to us Ruby nubes are probably...

  • posix methods (posix_getpwnam, posix_getuid, posix_setguid, etc..)
  • date method (it takes the secondary timestamp argument, AND, converts the php date format characters into ruby Time format characters. Check out the tests for examples
  • File methods are coming next, although, local-file versions of file_get_contents, and file_put_contents are already in place.

Get it here


./script/plugin install svn://ahgsoftware.com/php_compat/trunk

Examples

1
2
3
4
5
6
7
8
9
10
# Dates
PhpCompat.date("F j, Y, g:i")   # Translated to Time.strftime chars
PhpCompat.time  # Integer unix timestamp

# Posix methods
PhpCompat.get_pwnam('localusername') # Struct with passwd info

# File methods (not network enabled... yet!)
PhpCompat.file_put_contents('/tmp/file.txt',"yo yo yo")
PhpCompat.file_get_contents('/tmp/file.txt')

Leave a Reply

 

Michael Cerna Chicago-based Rails Developer and Avid Musician. More ...

Search

Categories

  • Home (15)
  • Rails Plugins (5)
  • Pages (9)
  • Archives

    Tags

    BlogRoll