CakePHP and PaaS
A common problem the engineering team is experiencing at Pollenizer is finding the resources to dedicate to system administration duties. With the vision of reducing those duties, Pollenizer has been exploring PaaS providers. I have reviewed services offered by Orchestra, PHP Fog and Pagoda Box. The stand out is clearly the latter.
PaaS providers typically offer deployment via Git hooks, most likely post-receive. This means you commit to the provider’s repository, and the code is immediately deployed. Having previously depended on managing deployments with Capistrano in traditional environments, I expect a similar interface from PaaS. Pagoda Box excels in scriptability of deployments compared to the other providers.
A YAML file named “Boxfile” in the root of the repository will be parsed during the deployment of a Pagoda Box application. The file is created and managed by the application author and prepares the Pagoda Box infrastructure for the newly pushed code.
I have developed a CakePHP Pagoda Boxfile which can be used as a base for new CakePHP applications. It uses all current Pagoda Boxfile Deploy Hooks for a pristine environment. Note that the Boxfile makes a number of assumptions:
- Pagoda specific database configuration file: app/Config/database.php.pagoda
- The Migrations plugin from CakeDC is used
web1: name: pagoda-webserver-name document_root: /app/webroot shared_writable_dirs: - app/tmp - app/tmp/cache - app/tmp/cache/models - app/tmp/cache/persistent - app/tmp/cache/views - app/tmp/logs - app/tmp/sessions - app/tmp/tests php_extensions: - mcrypt - mbstring - pdo_mysql - apc after_build: - "mv app/Config/database.php.pagoda app/Config/database.php" before_deploy: # https://github.com/CakeDC/migrations - "app/Console/cake Migrations.migration all" after_deploy: - "rm -rf app/tmp/cache/models/*" - "rm -rf app/tmp/cache/persistent/*" - "rm -rf app/tmp/cache/views/*" db1: name: pagoda-db-name type: mysql
The need for automating deployment tasks is critical for reducing the number of human errors, especially since Pagobox only offers a database connection via a non-standard tunnel. The Migrations plugin removes the need for performing schema changes by hand.
PaaS allows engineers to focus on development whilst removing the need to dedicate resources to system administrative duties, whilst a good provider will provide interfaces into the deployment routine.