PageRenderTime 27ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/documentation/reference/buildtime-configuration.markdown

http://github.com/propelorm/Propel2
Markdown | 313 lines | 241 code | 72 blank | 0 comment | 0 complexity | 74df67c2726aacf0642d253cd40a90eb MD5 | raw file
  1. ---
  2. layout: documentation
  3. title: Build Properties Reference
  4. ---
  5. # Build Properties Reference #
  6. 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).
  7. First, some conventions:
  8. * 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.)
  9. * Items where you have an alternative choice have a `|` character between them (i.e. true|false)
  10. * Alternative choices may be delimited by `{` and `}` to indicate that this is the default option, if not overridden elsewhere.
  11. ## Where to Specify Properties ##
  12. ### In the Project `build.properties` File ###
  13. 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.
  14. ### In a global `build.properties` file ###
  15. 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.
  16. ### On the Command Line ###
  17. You can also specify properties on the command line when you invoke Propel. The command line accepts a camelCase version of the property name. So for instance, to set the value of the `propel.some.other.property` property using the command line, type:
  18. > propel-gen /path/to/project -Dpropel.someOtherProperty#value
  19. >**Tip**<br />There is no space between the -D and the property name.
  20. ## Property List ##
  21. ### General Build Settings ###
  22. {% highlight ini %}
  23. # The name of your project.
  24. # This affects names of generated files, etc.
  25. propel.project = /Your-Project-Name/
  26. # The package to use for the generated classes.
  27. # This affects the value of the @package phpdoc tag, and it also affects
  28. # the directory that the classes are placed in. By default this will be
  29. # the same as the project. Note that the target package (and thus the target
  30. # directory for generated classes) can be overridden in each `<database>` and
  31. # `<table>` element in the XML schema.
  32. propel.targetPackage = {propel.project}|string
  33. # Whether to join schemas using the same database name into a single schema.
  34. # This allows splitting schemas in packages, and referencing tables in another
  35. # schema (but in the same database) in a foreign key. Beware that database
  36. # behaviors will also be joined when this parameter is set to true.
  37. propel.packageObjectModel = true|{false}
  38. # If you use namespaces in your schemas, this setting tells Propel to use the
  39. # namespace attribute for the package. Consequently, the namespace attribute
  40. # will also stipulate the subdirectory in which model classes get generated.
  41. propel.namespace.autoPackage = true|{false}
  42. # If your XML schema specifies SQL schemas for each table, you can copy the
  43. # value of the `schema` attribute to other attributes.
  44. # To copy the schema attribute to the package attribute, set this to true
  45. propel.schema.autoPackage = true|{false}
  46. # To copy the schema attribute to the namespace attribute, set this to true
  47. propel.schema.autoNamespace = true|{false}
  48. # To use the schema attribute as a prefix to all model phpNames, set this to true
  49. propel.schema.autoPrefix = true|{false}
  50. # Whether to validate the XML schema using the XSD file.
  51. # The default XSD file is located under `generator/resources/xsd/database.xsd`
  52. # and you can use a custom XSD file by changing the `propel.schema.xsd.file`
  53. # property.
  54. propel.schema.validate = {true}|false
  55. # Whether to transform the XML schema using the XSL file.
  56. # This was used in previous Propel versions to clean up the schema, but tended
  57. # to hide problems in the schema. It is disabled by default since Propel 1.5.
  58. # The default XSL file is located under `generator/resources/xsd/database.xsl`
  59. # and you can use a custom XSL file by changing the `propel.schema.xsl.file`
  60. # property.
  61. propel.schema.transform = true|{false}
  62. {% endhighlight %}
  63. ### Database Settings ###
  64. {% highlight ini %}
  65. # The Propel platform that will be used to determine how to build
  66. # the SQL DDL, the PHP classes, etc.
  67. propel.database = pgsql|mysql|sqlite|mssql|oracle
  68. # The database PDO connection settings at builtime.
  69. # This setting is required for the sql, reverse, and datasql tasks.
  70. # Note that some drivers (e.g. mysql, oracle) require that you specify the
  71. # username and password separately from the DSN, which is why they are
  72. # available as options.
  73. # Example PDO connection strings:
  74. # mysql:host=localhost;port=3307;dbname=testdb
  75. # sqlite:/opt/databases/mydb.sq3
  76. # sqlite::memory:
  77. # pgsql:host=localhost;port=5432;dbname=testdb;user=bruce;password=mypass
  78. # oci:dbname=//localhost:1521/mydb
  79. propel.database.url = {empty}|string
  80. propel.database.user = {empty}|string
  81. propel.database.password = {empty}|string
  82. # The database PDO connection settings at builtime for reverse engineer
  83. # or data dump. The default is to use the database connection defined by the
  84. # `propel.database.url` property.
  85. propel.database.buildUrl = {propel.database.url}/string
  86. # The database PDO connection settings at builtime for creating a database.
  87. # The default is to use the database connection defined by the
  88. # `propel.database.url` property.
  89. # Propel is unable to create databases for some vendors because they do not
  90. # provide a SQL method for creation; therefore, it is usually recommended that
  91. # you actually create your database by hand.
  92. propel.database.createUrl = {propel.database.url}/string
  93. # Optional schema name, for RDBMS supporting them.
  94. # Propel will use this schema is provided.
  95. propel.database.schema = {empty}|string
  96. # The encoding to use for the database.
  97. # This can affect things such as transforming charsets when exporting to XML, etc.
  98. propel.database.encoding = {empty}|string
  99. # Add a prefix to all the table names in the database.
  100. # This does not affect the tables phpName.
  101. # This setting can be overridden on a per-database basis in the schema.
  102. propel.tablePrefix = {empty}|string
  103. {% endhighlight %}
  104. >**Tip**<br />If you need more than one database connection at buildtime, the INI format is not enough. Therefore, you can add a `buildtime-conf.xml` file in the same directory as the `build.properties` file, and Propel will use the connections defined in this file instead of the ones defined by `propel.database.XXX` settings. The buildtime configuration file uses the same format as the `runtime-conf.xml` (see the runtime documentation reference for more details about this format).
  105. ### Reverse-Engineering Settings ###
  106. {% highlight ini %}
  107. # Whether to specify PHP names that are the same as the column names.
  108. propel.samePhpName = true|{false}
  109. # Whether to add the vendor info. This is currently only used for MySQL, but
  110. # does provide additional information (such as full-text indexes) which can
  111. # affect the generation of the DDL from the schema.
  112. propel.addVendorInfo = true|{false}
  113. {% endhighlight %}
  114. ### Customizing Generated Object Model ###
  115. {% highlight ini %}
  116. # Whether to add generic getter/setter methods.
  117. # Generic accessors are `getByName()`, `getByPosition(), ` and `toArray()`.
  118. propel.addGenericAccessors = {true}|false
  119. # Generic mutators are `setByName()`, `setByPosition()`, and `fromArray()`.
  120. propel.addGenericMutators = {true}|false
  121. # Whether to add a timestamp to the phpdoc header of generated OM classes.
  122. # If you use a versioning system, don't set this to true, or the classes
  123. # will be committed too often with just a date change.
  124. propel.addTimeStamp = true|{false}
  125. # Whether to add `require` statements on the generated stub classes.
  126. # Propel uses autoloading for OM classes, and doesn't insert require statements
  127. # by default. If you don't want to use autoloading, set this to true.
  128. propel.addIncludes = true|{false}
  129. # Whether to support pre- and post- hooks on `save()` and `delete()` methods.
  130. # Set to false if you never use these hooks for a small speed boost.
  131. propel.addHooks = {true}|false
  132. # The prefix to use for the base (super) classes that are generated.
  133. propel.basePrefix = {Base}|string
  134. # Some sort of "namespacing": All Propel classes with get the Prefix
  135. # "My_ORM_Prefix_" just like "My_ORM_Prefix_BookPeer".
  136. propel.classPrefix = {empty}|string
  137. # Identifier quoting may result in undesired behavior (especially in Postgres),
  138. # it can be disabled in DDL by setting this property to true in your build.properties file.
  139. propel.disableIdentifierQuoting = true|{false}
  140. # Whether the generated `doSelectJoin*()` methods use LEFT JOIN or INNER JOIN
  141. # (see ticket:491 and ticket:588 to understand more about why this might be
  142. # important).
  143. propel.useLeftJoinsInDoJoinMethods = {true}|false
  144. {% endhighlight %}
  145. ### MySQL-specific Settings ###
  146. {% highlight ini %}
  147. # Default table type.
  148. # You can override this setting if you wish to default to another engine for
  149. # all tables (for instance InnoDB, or HEAP). This setting can also be
  150. # overridden on a per-table basis using the `<vendor>` element in the schema
  151. # (see Schema AddingVendorInfo).
  152. propel.mysql.tableType = {MyISAM}|string
  153. # Keyword used to specify the table engine in the CREATE SQL statement.
  154. # Defaults to 'ENGINE', users of MYSQL < 5 should use 'TYPE' instead.
  155. propel.mysql.tableEngineKeyword = {ENGINE}|TYPE
  156. {% endhighlight %}
  157. ### Date/Time Settings ###
  158. {% highlight ini %}
  159. # Enable full use of the DateTime class.
  160. # Setting this to true means that getter methods for date/time/timestamp
  161. # columns will return a DateTime object when the default format is empty.
  162. propel.useDateTimeClass = {true}|false
  163. # Specify a custom DateTime subclass that you wish to have Propel use
  164. # for temporal values.
  165. propel.dateTimeClass = {DateTime}|string
  166. # These are the default formats that will be used when fetching values from
  167. # temporal columns in Propel. You can always specify these when calling the
  168. # methods directly, but for methods like getByName() it is nice to change
  169. # the defaults.
  170. # To have these methods return DateTime objects instead, you should set these
  171. # to empty values
  172. propel.defaultTimeStampFormat = {Y-m-d H:i:s}|string
  173. propel.defaultTimeFormat = { %X }|string
  174. propel.defaultDateFormat = { %x }|string
  175. {% endhighlight %}
  176. ### Directories and Filenames ###
  177. {% highlight ini %}
  178. # Directory where the project files (`build.properties`, `schema.xml`,
  179. # `runtime-conf.xml`, etc.) are located.
  180. # If you use the `propel-gen` script, this value will get overridden by
  181. # the path from which the script is called.
  182. propel.project.dir = {current_path}|string
  183. # The directory where Propel expects to find the XML configuration files.
  184. propel.conf.dir # ${propel.project.dir}
  185. # The XML configuration file names
  186. propel.runtime.conf.file = runtime-conf.xml
  187. propel.buildtime.conf.file = buildtime-conf.xml
  188. # The directory where Propel expects to find your `schema.xml` file.
  189. propel.schema.dir = ${propel.project.dir}
  190. # The schema base name
  191. propel.default.schema.basename = schema
  192. # The directory where Propel should output classes, sql, config, etc.
  193. propel.output.dir = ${propel.project.dir}/build
  194. # The directory where Propel should output generated object model classes.
  195. propel.php.dir = ${propel.output.dir}/classes
  196. # The directory where Propel should output the compiled runtime configuration.
  197. propel.phpconf.dir = ${propel.output.dir}/conf
  198. # The name of the compiled configuration and classmap files
  199. propel.runtime.phpconf.file = ${propel.project}-conf.php
  200. propel.runtime.phpconf-classmap.file = ${propel.project}-classmap.php
  201. # The directory where Propel should output the generated DDL (or data insert statements, etc.)
  202. propel.sql.dir = ${propel.output.dir}/sql
  203. {% endhighlight %}
  204. ### Overriding Builder Classes ###
  205. {% highlight ini %}
  206. # Object Model builders
  207. propel.builder.peer.class = builder.om.PeerBuilder
  208. propel.builder.object.class = builder.om.ObjectBuilder
  209. propel.builder.objectstub.class = builder.om.ExtensionObjectBuilder
  210. propel.builder.peerstub.class = builder.om.ExtensionPeerBuilder
  211. propel.builder.objectmultiextend.class = builder.om.MultiExtendObjectBuilder
  212. propel.builder.tablemap.class = builder.om.TableMapBuilder
  213. propel.builder.query.class = builder.om.QueryBuilder
  214. propel.builder.querystub.class = builder.om.ExtensionQueryBuilder
  215. propel.builder.queryinheritance.class = builder.om.QueryInheritanceBuilder
  216. propel.builder.queryinheritancestub.class = builder.om.ExtensionQueryInheritanceBuilder
  217. propel.builder.interface.class = builder.om.InterfaceBuilder
  218. # SQL builders
  219. propel.builder.datasql.class = builder.sql.${propel.database}.${propel.database}DataSQLBuilder
  220. # Platform classes
  221. propel.platform.class = platform.${propel.database}Platform
  222. # Pluralizer class (used to generate plural forms)
  223. propel.builder.pluralizer.class = builder.util.DefaultEnglishPluralizer
  224. # Use StandardEnglishPluralizer instead of DefaultEnglishPluralizer for better pluralization
  225. # (Handles uncountable and irregular nouns)
  226. {% endhighlight %}
  227. As you can see, you can specify your own builder and platform classes if you want to extend & override behavior in the default classes
  228. ### Overriding / Adding Behaviors ###
  229. {% highlight ini %}
  230. # Define the path to the class to be used for the `timestampable` behavior.
  231. # This behavior is bundled with Propel, but if you want to override it, you can
  232. # specify a different path.
  233. propel.behavior.timestampable.class = propel.engine.behavior.TimestampableBehavior
  234. # Other behaviors use similar settings
  235. # If you want to add more behaviors, write their path following the same model:
  236. propel.behavior.my_behavior.class = my.custom.path.to.MyBehaviorClass
  237. # Behaviors are enabled on a per-table basis in the `schema.xml`. However, you
  238. # can add behaviors for all your schemas, provided that you define them in the
  239. # `propel.behavior.default` setting:
  240. propel.behavior.default = archivable,my_behavior
  241. {% endhighlight %}