New CakePHP Project


This tutorial shows how simple it is to start a new project using Skipper. We are going to create a CakePHP project with two plugins and four entities. Part of this tutorial is also export of the finished project to CakePHP .php definition files.

Hint: See the ORM Model basics for detailed description of the ORM elements (e.g. plugin, entity).

New project

First step is to create new project with CakePHP framework support. Simply select the New ORM Project from File menu and perform the following steps shown in the pictures.

Select New Cake PHP ORM Project in Skipper New project wizard
Select CakePHP ORM in Skipper New project wizard
Select CakePHP framework in Skipper New project wizard
Set project name and directory in Skipper New project wizard
New project summary screen in Skipper New project wizard
Skipper visual model of the new project with default model

Application model design

Now we’re going to design a simple application with two plugins and four entities. The first plugin will serve as the contact records, the second plugin as the ecommerce logic. Contact plugin keeps data about the customers and their addresses, ecommerce plugin keeps data about orders and their items. Ecommerce order also has a relation with contact to store the order owner. You can do it this way:

Select Skipper CakePHP entity tool
Configure new CakePHP entity in Skipper
New CakePHP entity created in Skipper
Select CakePHP association tool in Skipper
Configure new CakePHP association in Skipper
New CakePHP association created in Skipper
Select Skipper comment tool
Configure new Skipper comment
New Skipper comment created
Select CakePHP plugin tool in Skipper
Configure new CakePHP plugin in Skipper
New CakePHP plugin created in Skipper
Create CakePHP ecommerce entities in Skipper
Create association between order and contact in Skipper visual model

Export model

Now when you have created the application model, next step is to export it to CakePHP schema definition files. Before Skipper generates all the files for you, it is necessary to configure schema files destinations and export formats.

Skipper exports single schema file for each CakePHP entity, and it will create schema file for derived class if such file is not already present in the target directory. This means that our sample project will export four to eight schema definition files. Each plugin can have its own export path and format which is relative to project root directory and its own export format. For CakePHP ORM it is PHP definition files.

Edit CakePHP plugin settings in Skipper main menu
Configure CakePHP schema definitions export settings in Skipper
Click Export to ORM icon to generate the CakePHP schema definition files in Skipper
CakePHP schema definitions export settings window in Skipper
CakePHP project schema files export results in Skipper
Exported CakePHP definition files

And here is an example of BaseOrder and Order entity generated by Skipper. As you can see everything is well formatted and exported:

<?php
/**
* Base Order object
*
* This class has been auto-generated by Skipper (http://www.skipper18.com)
* /

class BaseOrder extends AppModel
{
  public $name = 'Order';
  public $primaryKey = 'id';
  public $_schema =
    array (
      'id' =>
        array (
          'type' => 'integer',
          'null' => false
        ),
      'number' =>
        array (
          'type' => 'integer',
          'null' => false
        ),
      'createdAt' =>
        array (
          'type' => 'date',
          'null' => false
        ),
      'totalPrice' =>
        array (
          'type' => 'float'
        ),
      'contact_id' =>
        array (
          'type' => 'integer',
          'null' => false
        )
    );
  public $hasMany =
    array (
      'OrderItem' =>
        array (
          'className' => 'OrderItem',
          'foreignKey' => 'order_id'
        )
    );
  public $belongsTo =
    array (
      'Contact' =>
        array (
          'className' => 'Contact',
          'foreignKey' => 'contact_id'
        )
    );
}

and Order class:

<?php
require_once 'base/base_order.php';
/**
* Order object
*
* This class has been auto-generated by Skipper
*/

class Order extends BaseOrder
{
}

Conclusion

This short tutorial shows that to create new project and export it to schema definition files takes no more than five minutes in Skipper (if it is your first try, it may take little longer). Compare it with manual writing of such small project, and the acceleration of work is breathtaking. And in addition, you can concentrate only on the creative part of your work.

Video Tutorials

Create new project

Export project