Skip to content

Code Generation

dannykopping edited this page Jul 24, 2011 · 2 revisions

This is the final step before we can start writing our first application!

The Aerial Admin application we downloaded earlier has functionality to generate several useful files for us based on our configuration and YAML schema.

Open Aerial Admin, open your project and go to the Code Generation page. If you open this page without having the relevant files already generated, you will get the following notification:

Model definitions could not be read from the server. Please check your configuration values. This error could also be caused by not having generated models present. You can close this dialog and generate your PHP models using the options provided.

Aerial Admin Code Generation

Click the Generate button and you should see the following:

Aerial Admin Code Generation

We just generated our PHP models that Doctrine requires to operate.

Models, Services & Bootstrap files

Aerial Framework uses two types of classes: models and services.

A model (sometimes called a VO - Value Object) is a class that represents a database table. It will contain all the fields that the database table contains as well as some other useful meta-data. We use models in both Flex (client) and PHP (server).

A service is a class that exposes methods for saving, updating, deleting and retrieving records from a database table. We use services in both Flex (client) and PHP (server).

The bootstrap file is a file we generate that contains some essential configuration options that are required by the Flex application.

Doctrine ORM - the framework that helps us interact with the database - requires special PHP models to function. These are generated by selecting the PHP models option under the Generation Options section in the Code Generation page. To view the files that have been generated, navigate to src_php/org/aerial/vo/base.

Generating Models and Services

Now that we have generated the "base" models that Doctrine ORM uses to interact with the database, we can generate some other classes that we will use when writing our application.

We are now going to generate:

  • ActionScript 3.0 (AS3) models and services
  • PHP services
  • Bootstrap file

Select all the models from the list on the left, ensure that all the relevant options are selected from the Generation Options and click Generate:

Aerial Admin Code Generation

Hey presto!

Aerial Admin Code Generation

  • The generated ActionScript files can be found under src_flex/org/aerial/services and src_flex/org/aerial/vo.
  • The generated PHP files are can be found under src_php/org/aerial/services and src_php/org/aerial/vo.
  • The generated Bootstrap file can be found under src_flex/org/aerial/bootstrap/Aerial.as

Next Step: Your First Application