Perl Success Story - Managing PHP apps with Perl
WebPub helps install and manage popular web apps. We currently are doing WordPress, Drupal, MODX and phpBB. While the web UI is in PHP (decided before I came onboard) the backend is all Perl.
Some of the major components being used are: Mojolicious, Moose, DBIx::Class and Gearman.
Mojolicious provides the REST interface for the PHP front end and will be used in the near future by at least one other company we are working with. That company will write their client in Ruby.
Moose is used heavily for meta method creation, mapping various before / after 'method' to validation and DB update_or_create and the installer system loads the appropriate role (each app has its own role for things that are app specific - an install of Drupal needs more fixup than WP) at runtime.
DBIx::Class - no explaination needed
Gearman - actual interaction with remote systems happens from workers.
There are really two main applications. The one that does database CRUD, and the part that handles actual installation, upgrade, rollback, import and uninstall of the app. That piece is Moose based behind Gearman workers; has its own API and can function as an independent app. If you knew the API you could skip the REST/CRUD interface and write your own to use the installer system. Or even just use the .pm(s) in your own app ( if they were public ).
Outside of the primary web app, there is a check for updates system which watches the application repositories for new versions and pulls those in automatically. There is a mass upgrade daemon that handles distributing jobs for say a mass upgrade from WP 3.4.1 to 3.4.2 and works with the job server to throttle jobs by IP address (so as not to trip connection limits). Autoupgrades can be kicked off from a command line tool or web interface and both clients use the same daemon, feeding it installation IDs to upgrade.
These two pieces make heavy use of Mojo::UserAgent, Mojo::DOM, Mojo::IOLoop server/client. Mojo::IOLoop is being used where POE::Component::TCP::* would have been used in the past.
In the modules list below you may notice some duplication of fuctionality. Where in the REST/CRUD server we are running 5.12.4 under perlbrew, we were concerned with having this requirement where we may need to spin up gearman workers. We made the decision early on that we wanted to be able to deploy the workers in a 5.8.8 environment - you all know why. So whereas the REST/CRUD server uses Mojolicious modules, the workers use WWW::Mechanize. You may find other similar duplication between other modules depending on which sub system they are in.
The list of CPAN modules used in the project.
Modules used in Testing:
A bunch of DBIx::Class components.
Leave a comment