Pagoda Box – scalable platform for your PHP application

I got my hands on a private beta of Pagoda Box.  It is a platform that you can deploy your PHP applications to.   I gave it a brief look around and I have to say it’s pretty sweet.

Right after you register and get access to your dashboard, you can add applications.  Applications are cloned from GitHub repositories.  Both public and private repositories are supported.  Once you add an application, you can access it at http://your-app-name.pagodabox.com. If you’d rather have your own domain – you can assign it to your application from the dashboard and all that will remain to be done is adding an A-record in your DNS zone.  Super easy!

There is more to it, even at this beta stage.  Pagoda Box supports a number of PHP frameworks, including all major ones – CakePHP, CodeIgniter, Lithium, Symfony, Zend, and more.  You can also optionally have a MySQL database for your application.  They even help you out with outgoing email.

On top of that, you have control as to how many instances of the application you want (the more you have, the more requests you can serve at the same time, and the more you’ll have to pay).  There are statistics of your application performance, requests, and a few other parameters (I’m sure those will grow together with the project).

I’ll admit, I am too used to hosting my projects on my own servers to take immediate advantage of Pagoda Box.  But I am now seriously considering which projects I can move out of my server and into this platform.  It just makes things so much easier.  Deploying and re-deploying works wonders for any GitHub commit of your project.  Initial resources that one usually needs to try an idea out are free of charge.  If the idea picks up, the prices are more than reasonable (and comparable to other hosting solutions).

Out of those things that I consider necessary, I haven’t see any mentioning of files (uploaded via application, for example), support for build systems (such as Phing), and some sort of common library of frequently used code (PEAR modules, for example).  But I’m sure that either I simply didn’t look for these hard enough, or they will be added in the future.

If you are a PHP developer or involved with PHP source on GitHub in any other way, I suggest you try it out.  You can request a private beta invite directly from Pagoda Box website.  Or, if you prefer, I can send you one (I have about 10 of them left for now).  Also watch the demonstration screencasts,  and read through other platform features.

CakePHP GraphViz Models

I have completely and totally rewritten my old script that generates a graph of CakePHP models and their relationships.  Instead of pasting the code in here, I pushed all of its development to GitHub where it now enjoys a new repository.  Please have a look, try it out, and let me know if it does or doesn’t work for you.

The major changes in this version are:

  • Rewritten as CakePHP Shell instead of being a standalone madness script.
  • Got rid of all dot markup. Utilized Image_GraphViz PEAR package instead.
  • Added support for old and new CakePHP versions (1.2, 1.3, and 2.0).
  • Added option for using only real models (via className property of the relationship) or sticking with the old behavior.
  • Added a bunch of options for tweaking GraphViz output.  And now it’s obvious where to edit them, in case you need more.
  • Improved the styling of the graph a bit – fonts and colors.
  • Improved documentation.

As a side effect improvement, now that it is a native CakePHP Shell, it’s trivial to add to your project build process.

Disable and enable CakePHP plugins on the fly

I am currently working on a rather large project which is based on CakePHP framework.  In order to simplify the task, I’ve broken down the whole application into a number of CakePHP plugins.  Now, however, I want to enable/disable plugins on the fly.  After a brief search around I couldn’t find how to do that.  Asking a question at #cakephp IRC channel did it.  RabidFire instantly replied with the link that gave me an idea.   30 seconds later I had a working solution.

CakePHP plugins extend AppController.  So all that one needs to do is add the following lines to app/app_controller.php (Using CakePHP 2.0, but it’s trivial to adopt for earlier versions):

public function beforeFilter() {
    $allowedPlugins = array('crm', 'articles');
    if (!empty($this->request->params['plugin']) && !in_array($this->request->params['plugin'], $allowedPlugins)) {
        throw new ForbiddenException();
    }
}

ORM Designer

Here is a tool that might help you with your MVC framework, like CakePHP, Symfony, and others – ORM Designer.  In essence, it is a graphical user interface for drawing a visual representation of your project (such as an Entity Relationship Diagram (ERD)) and than converting it into the code.  You can specify which framework and which  ORM you want to use and it will generate the appropriate bits and pieces.  What’s even more interesting is that it has import functionality, which means that you can start using it with an existing project.  Here is the video that shows and explains more.

[youtube=http://www.youtube.com/watch?v=FNlmU6zX5Ug]

Of course, I got excited about it, downloaded and installed.   Two things that disappointed me were:

  1. It’s a native Windows application, which runs on Linux through the wine emulator.  While it works fine, I’d much prefer a native application that I could integrate with the rest of my development environment.
  2. CakePHP import is not supported at this time.

Other than that though, it looks very promising.  I’ve seen quite a few applications that help with database design, and ORM Designer stands well in that row.  You can create entities, define fields, specify indexes, and associate entities with each other using relationships.  Many-to-many relationships are supported, as are entity inheritance.  While inheritance does make it for a bit more complicated structure of the project (with app/models/base/ folder for CakePHP), it’s very nice to have such support for bigger, more complex projects.

The project is commercial, with a 14 days evaluation version available for download. If you like it enough to buy, the price is very reasonable – 99 EUR per license.

Try and see if you like it, and provide some feedback to the guys who are developing it.  ORM Designer has all the chances of becoming an extremely useful tool and since it is still in its early development, your feedback would be of the most value.

Unit tests with CakePHP

I’ve spent a large part of yesterday setting up the testing environment for a CakePHP project.  As always, every time I do something that I have done before, I wanted to do it better, using all the experienced that was acquired previously.  And this often leads to the discovery of new things – both good and bad.  Here is a record of what I’ve learned yesterday.

Continue reading Unit tests with CakePHP