++ Introduction The purpose of schema files is to allow you to manage your model definitions directly from a yaml file rather then editing php code. The yaml schema file is parsed and used to generate all your model definitions/classes. This makes Doctrine model definitions much more portable. Schema files support all the normal things you would write with manual php code. Component to connection binding, relationships, attributes, templates/behaviors, indexes, etc. ++ Relationships ++ Connection Binding ++ Attributes ++ Templates ++ ActAs ++ Options ++ Indexes Please see chapter [doc basic-schema-mapping :index :name] for more information about indexes and their options. schema.yml --- UserProfile: columns: user_id: type: integer length: 4 primary: true autoincrement: true first_name: type: string length: 20 last_name: type: string length: 20 indexes: name_index: fields: first_name: sorting: ASC length: 10 primary: true last_name: ~ type: unique This is the PHP line of code that is auto-generated inside setTableDefinition() inside your base model class. $this->index('name_index', array('fields' => array('first_name' => array( 'sorting' => 'ASC', 'length' => '10', 'primary' => true ), 'last_name' => array( ) ), 'type' => 'unique')); ++ Generating Models Once you have defined your schema files you need some code to // The options are completely optional. Only use this if you need something beyond the default configuration for model generation $options = array('packagesPrefix' => 'Package', // What to prefix the middle package models with 'packagesPath' => '', // this defaults to the "#models_path#/packages" 'generateBaseClasses' => true, // Whether or not to generate abstract base models containing the definition and a top level class which is empty extends the base 'generateTableClasses' => true, // Whether or not to generate a table class for each model 'baseClassesDirectory' => 'generated', // Name of the folder to generate the base class definitions in 'baseClassName' => 'Doctrine_Record', // Name of the base Doctrine_Record class 'suffix' => '.php'); // Extension for your generated models // This code will generate the models for schema.yml at /path/to/generate/models Doctrine::generateModelsFromYaml('schema.yml', '/path/to/generate/models', $options);