Petit four, the online CakePHP baking tool

Faced with the sometimes tiresome tasks of CakePHP development, especially the SQL and models generation of our applications, we decided to create a quick and easy tool allowing us to design and generate a relational database and then the base files following the MVC model needed for any CakePHP application. 

This is how petit four was born, a tool allowing the design of a Web project, then all necessary files following the CakePHP convention: models, controllers and views. This online application also allows to generate one or many SQL tables and their associated MVC files in order to integrate them to an existing CakePHP application. We follow strictly the CakePHP conventions and naming in order to ease your task and to enforce the "convention over configuration" doctrine.

How to use it?

We tried to conceive a simple user interface, that was similar to interfaces we often use, like phpMyAdmin.

In order to begin to bake your petit four, start by filling out the default values of your application:

  • The value of the default attributes of each model that will be created: set the primary key of each table, and choose wether or not to include the CREATED and MODIFIED attributes and their format
  • The default type of each new column that you will add to existing models

These values can be modified while editing your database structure, in order to speed up the creation of new models or new columns habing different default properties.

You can of course create as many models as you desire, by filling out their singular name (we automatically create the plural table name in the database). You can also add new models while you are editing your website structure. To create a model, write its name and press Enter.

Inside models, you can:

  • Add a new column in the table by filling out its name
  • Change the characteristics of an existing column
  • Add validations rules for this column inside the model
  • Create a new relation with anoter model : choose the relation type and the name of the model (the input has an updated autocomplete function with the name of all existing models). The new column for the foreign key of the relation is automatically added to the relevant model, and the new table in the case of a HABTM relation is automatically created when generating the project. You can also add aliases to relations if you have several relations between two models, or a self relation.

Bake my CakePHP project online

Output of the application

The application outputs an archive which contains :

  • A SQL file containing the database
  • The basic architecture of the App directory: Model, View, Controller
  • The files of each model containing the defined relations and validation rules
  • The Controller file for each Model following the CakePHP basic template
  • A  view file for each controller's action following the CakePHP basic template

Once this archive is generated, you can extract it in any 2.X CakePHP working installation.

Improvements to come

The current version of the application is still very basic and concentrates on the taks of generating the database file and all the models, the necessary base of any CakePHP application. However we plan to quickly add new functionalities and improve the automated code generation.

Here is a list of the functionalities we plan to implement in the future:

  • Adding virtual fields to models
  • Filling out parameters for specific validation rules
  • Attaching behaviors to models
  • Choosing a template for view files generation: Classic Cake, Bootsrap ready, JQueryUI ready...
  • Graphical User Interface for the model designing process
  • Import an existing SQL file into Petit Four and compute relations from existing foreign ids (like in the console)
  • Tell us !
This page belongs to the following categories: news , CakePHP.
Petits fours baked