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.
Mojo::Base
MojoX::Log::Log4perl
File::Basename
File::Spec
Method::Signatures
Moose
DateTime
Try::Tiny
Log::Log4perl
Exception::Base
Moose::Role
Validate::Tiny
Email::Valid
Data::Validate::URI
Moose::Util::TypeConstraints
MooseX::Aliases
Net::xFTP
Net::Ping::External
File::Temp
Path::Class
Data::Random
JSON
List::MoreUtils
Gearman::XS
Gearman::XS::Client
Gearman::XS::Worker
Hash::Merge
MooseX::Types::Path::Class
MooseX::Types::URI
cPanel::PublicAPI
Template::Simple
App::Genpass
IO::String
URI
HTTP::Tiny
WWW::Mechanize
Path::Class
Archive::Tar::Wrapper
Crypt::CBC
Cwd
Config::ZOMG
Modules used in Testing:
FindBin
Test::More
Test::DBIx::Class
Data::Printer;
Test::Mojo
Test::TCP
Test::FTP::Server
File::Temp
File::Copy::Recursive
Privileges::Drop
MooseX::AutoImmute
MooseX::Types::Path::Class
Test::Httpd::Apache2
A bunch of DBIx::Class components.
Leave a comment