= Build Properties Reference =

[[PageOutline]]

Here is a list of properties that can be set to affect how Propel builds database files.  For a complete list, see the {{{default.properties}}} file that is bundled with your version of Propel generator (this will be in PEAR's data directory if you are using a PEAR-installed version of Propel).

First, some conventions:

  *  Text surrounded by a '''/''' is text that you would provide and is not defined in the language. (i.e. a table name is a good example of this.)
  *  Items where you have an alternative choice have a '''|''' character between them (i.e. true|false)
  *  Alternative choices may be delimited by '''{''' and '''}''' to indicate that this is the default option, if not overridden elsewhere.

== Where to Specify Properties ==

=== In the Project build.properties File ===

The most natural place to specify properties for a file are in the project's {{{build.properties}}} file.  This file is expected to be found in the project directory.

=== In a global build.properties file ===

You can also create a {{{global build.properties}}} file in the same directory as Propel's {{{default.properties}}} file.  For users who have installed Propel using PEAR, this will be in PEAR data directory structure.

=== On the Command Line ===

You can also specify properties on the commandline when you invoke Propel:

{{{
$ propel-gen /path/to/project -Dpropel.someOtherProperty=value
}}}

''Note that there is '''no space''' between the -D and the property name.''

== The Properties ==

=== General Build Settings ===

{{{
propel.project = Your-Project-Name
}}}

The name of your project. This affects names of generated files, etc.

{{{
propel.targetPackage = {propel.project}
}}}

The package to use for the generated classes.  This affects the value of the @package phpdoc tag, and it also affects the directory that the classes are placed in.  By default this will be the same as the project. Note that the target package (and thus the target directory for generated classes) can be overridden in each `<database>` and `<table>` element in the XML schema.

{{{
propel.packageObjectModel = true|{false}
}}}

Whether to join schemas using the same database name into a single schema. This allows splitting schemas in packages, and referencing tables in another schema (but in the same database) in a foreign key. Beware that database behaviors will also be joined when this parameter is set to true.

{{{
propel.schema.validate = {true}|false
}}}

Whether to validate the schema using the XSD file. The default XSD file is located under `generator/resources/xsd/database.xsd`, and you can use a custom XSD file by changing the `propel.schema.xsd.file` property.

{{{
propel.schema.transform = true|{false}
}}}

Whether to transform the schema using the XSL file. This was used in previous Propel versions to clean up the schema, but tended to hide problems in the schema. It is disabled by default since Propel 1.5. The default XSL file is located under `generator/resources/xsd/database.xsl`, and you can use a custom XSL file by changing the `propel.schema.xsl.file` property.

=== Database Settings ===

{{{
propel.database = pgsql|mysql|sqlite|mssql|oracle
}}}

The Propel platform that will be used to determine how to build the SQL DDL, etc.


{{{
propel.database.url = /PDO database connection string/
propel.database.user =
propel.database.password =
}}}

Propel will use this information as the default to connect to your database.  Note that for PDO some drivers (e.g. mysql, oracle) require that you specify the username and password separately from the DSN, which is why they are available as options.


{{{
propel.database.buildUrl = /PDO database connection string, defaults to use ${propel.database.url}/
}}}

This property is used by Propel to connect to a database to reverse engineer or data dump.  The default is to use the database connection defined by the ''propel.database.url'' property.


{{{
propel.database.createUrl = /PDO database connection string, defaults to use ${propel.database.url}/
}}}

This property is used by Propel for creating a database.  Of course, Propel is unable to create many databases because they do not provide a SQL method for creation; therefore, it is usually recommended that you actually create your database by hand.

{{{
propel.database.schema = /schema-name/
}}}

Where supported by the RDBMS, you can specify a schema name for Propel to use.

{{{
propel.database.encoding =
}}}
The encoding to use for the database.  This can affect things such as transforming charsets when exporting to XML, etc.

{{{
propel.tablePrefix = {empty}|string
}}}

Add a prefix to all the table names in the database. This does not affect the tables phpName. This setting can be overridden on a per-database basis in the schema.

=== Reverse-Engineering Settings ===

{{{
propel.samePhpName = true|{false}
}}}
Whether to specify PHP names that are the same as the column names.

{{{
propel.addVendorInfo = true|{false}
}}}
Whether to add the vendor info.  This is currently only used for MySQL, but does provide additional information (such as full-text indexes) which can affect the generation of the DDL from the schema.

{{{
propel.addValidators = {none}|maxvalue|type|required|unique|all
}}}
Which Propel validators to add to the generated schema (based on the db constraints).

=== Customizing Generated Object Model ===

{{{
propel.addGenericAccessors = true|{false}
propel.addGenericMutators = true|{false}
}}}
Whether to add generic getter/setter methods -- e.g. '''getByName()''', '''setByName()'''.

{{{
propel.addTimeStamp = true|{false}
}}}
Whether to add a timestamp to the phpdoc header of generated OM classes.

{{{
propel.addValidateMethod = {true}|false
}}}
Whether to add `validate()` method to your classes. Set to false if you don't use Propel validation. 

{{{
propel.addIncludes = {true}|false
}}}
Whether to add `require` statements on the generated stub classes. Set to false if you autoload every classe at runtime.

{{{
propel.addHooks = {true}|false
}}}
Whether to support pre- and post- hooks on `save()` and `delete()` methods. Set to false if you never use these hooks for a small speed boost.

{{{
propel.basePrefix = {Base}|/YourPrefix/
}}}
The prefix to use for the base (super) classes that are generated. 

{{{
propel.classPrefix = {empty}|string;
}}}
Some sort of "namespacing": All Propel classes with get the Prefix "My_ORM_Prefix_" just like "My_ORM_Prefix_BookPeer".

{{{
propel.disableIdentifierQuoting = true|{false}
}}}
Identifier quoting is only implemented at the DDL layer at this point. Since this may result in undesired behavior (especially in Postgres), it can be disabled by setting this property to true.

{{{
propel.useLeftJoinsInDoJoinMethods = {true}|false
}}}
Set whether the '''doSelectJoin*()''' methods use LEFT JOIN or INNER JOIN (see ticket:491 and ticket:588 to understand more about why this might be important).

=== MySQL-specific Settings ===

{{{
propel.mysqlTableType = /DefaultTableEngine/
}}}
Default table engine - defaults to MyISAM. You can override this setting if you wish to default to another engine for all tables (for instance InnoDB, or HEAP). This setting can also be overridden on a per-table basis using the `<vendor>` element in the schema (see [wiki:Documentation/1.5/Schema#AddingVendorInfo]).

{{{
propel.mysqlTableEngineKeyword = /EngineKeyword/
}}}
Keyword used to specify the table engine in the CREATE SQL statement. Defaults to 'ENGINE', users of MYSQL < 5 should use 'TYPE' instead.

=== Date/Time Settings ===

{{{
propel.useDateTimeClass = true|{false}
}}}
This is how you enable full use of the new DateTime class in Propel.  Setting this to true means that getter methods for date/time/timestamp columns will return a DateTime object ''when the default format is empty''.  Note that the current default of ''false'' is only for backwards compatibility; in the future ''true'' will be the only option here.

{{{
propel.dateTimeClass = {DateTime}|string
}}}
Specify a custom DateTime subclass that you wish to have Propel use for temporal values.

{{{
propel.defaultTimeStampFormat = {Y-m-d H:i:s}|string
propel.defaultTimeFormat = {%X}|string
propel.defaultDateFormat = {%x}|string
}}}
These are the default formats that will be used when fetching values from temporal columns in Propel.  You can always specify these when calling the methods directly, but for methods like getByName() it is nice to change the defaults.

To have these methods return DateTime objects instead, you should set these to empty values, for example:
{{{
propel.defaultTimeStampFormat =
}}}

=== Directories ===

{{{
propel.project.dir = default-depends-on-installation-type
}}}

''This is not necessarily a property you can change.'' The project directory is the directory where you project files (build.properties, schema.xml, runtime-conf.xml, etc.) are located.  For example, if you use the {{{propel-gen}}} script, this value will get overridden to the path you pass to {{{propel-gen}}}.

{{{
propel.output.dir = ${propel.project.dir}/build
}}}
The default top-level directory for output of classes, sql, config, etc.

{{{
propel.schema.dir = ${propel.project.dir}
}}}
The directory where Propel expects to find your schema.xml file.

{{{
propel.conf.dir = ${propel.project.dir}
}}}
The directory where Propel expects to find your {{{runtime-conf.xml}}} file.

{{{
propel.php.dir = ${propel.output.dir}/classes
}}}
The directory where Propel will create generated object model classes.

{{{
propel.phpconf.dir = ${propel.output.dir}/conf
}}}
The directory where Propel will place the php-ified version of your {{{runtime-conf.xml}}}.

{{{
propel.sql.dir = ${propel.output.dir}/sql
}}}
The directory where Propel will place generated DDL (or data insert statements, etc.)


=== Overriding Builder Classes ===

{{{
# Object Model builders
propel.builder.peer.class = propel.engine.builder.om.php5.PHP5ComplexPeerBuilder
propel.builder.object.class = propel.engine.builder.om.php5.PHP5ComplexObjectBuilder
propel.builder.objectstub.class = propel.engine.builder.om.php5.PHP5ExtensionObjectBuilder
propel.builder.peerstub.class = propel.engine.builder.om.php5.PHP5ExtensionPeerBuilder

propel.builder.objectmultiextend.class = propel.engine.builder.om.php5.PHP5MultiExtendObjectBuilder

propel.builder.tablemap.class = propel.engine.builder.om.php5.PHP5TableMapBuilder

propel.builder.interface.class = propel.engine.builder.om.php5.PHP5InterfaceBuilder

propel.builder.node.class = propel.engine.builder.om.php5.PHP5NodeBuilder
propel.builder.nodepeer.class = propel.engine.builder.om.php5.PHP5NodePeerBuilder
propel.builder.nodestub.class = propel.engine.builder.om.php5.PHP5ExtensionNodeBuilder
propel.builder.nodepeerstub.class = propel.engine.builder.om.php5.PHP5ExtensionNodePeerBuilder

propel.builder.nestedset.class = propel.engine.builder.om.php5.PHP5NestedSetBuilder
propel.builder.nestedsetpeer.class = propel.engine.builder.om.php5.PHP5NestedSetPeerBuilder

# SQL builders

propel.builder.ddl.class = propel.engine.builder.sql.${propel.database}.${propel.database}DDLBuilder
propel.builder.datasql.class = propel.engine.builder.sql.${propel.database}.${propel.database}DataSQLBuilder

# Platform classes

propel.platform.class = propel.engine.platform.${propel.database}Platform

# Pluralizer class (used to generate plural forms)

propel.builder.pluralizer.class = propel.engine.builder.util.DefaultEnglishPluralizer
}}}

As you can see, you can specify your own builder and platform classes if you want to extend & override behavior in the default classes

=== Adding Behaviors ===

{{{
propel.behavior.timestampable.class = propel.engine.behavior.TimestampableBehavior
}}}

Define the path to the class to be used for the `timestampable` behavior. This behavior is bundled wit hPropel, but if you want to override it, you can specify a different path.

If you want to add more behaviors, write their path following the same model:

{{{
propel.behavior.my_behavior.class = my.custom.path.to.MyBehaviorClass
}}}

Behaviors are enabled on a per-table basis in the `schema.xml`. However, you can add behaviors for all your schemas, provided that you define them in the `propel.behavior.default` setting:

{{{
propel.behavior.default = soft_delete,my_behavior
}}}