Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 209 lines (152 sloc) 10.696 kB
8e6722e @willdurand Updated README
willdurand authored
1 sfPropelORMPlugin
2 =================
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
3
8e6722e @willdurand Updated README
willdurand authored
4 Replaces symfony's core Propel plugin by the latest version of Propel, in branch 1.6.
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
5
8e6722e @willdurand Updated README
willdurand authored
6 ## Installation
7
8 ### The Git way
9
10 Clone the plugin from Github:
11
12 git clone git://github.com/propelorm/sfPropelORMPlugin.git plugins/sfPropelORMPlugin
13 cd plugins/sfPropelORMPlugin
d2372a0 @willdurand Fixed git typo
willdurand authored
14 git submodule update --init
8e6722e @willdurand Updated README
willdurand authored
15
16 If you use Git as a VCS for your project, it should be better to add the plugin as a submodule:
17
18 git submodule add git://github.com/propelorm/sfPropelORMPlugin.git plugins/sfPropelORMPlugin
19 git submodule init --update --recursive
20
21 As both Phing and Propel libraries are bundled with the plugin, you have to initialize submodules for the plugin.
22
23 ### The SVN way
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
24
25 Install the plugin via the subversion repository:
26
8e6722e @willdurand Updated README
willdurand authored
27 svn checkout http://svn.github.com/propelorm/sfPropelORMPlugin.git plugins/sfPropelORMPlugin
28
29 Install `Phing` and `Propel`:
30
31 cd plugins/sfPropelORMPlugin/lib/vendor
32 svn checkout http://phing.mirror.svn.symfony-project.com/tags/2.3.3/classes/phing phing
33 svn checkout http://svn.github.com/propelorm/Propel.git propel
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
34
8e6722e @willdurand Updated README
willdurand authored
35 ### Final step
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
36
8e6722e @willdurand Updated README
willdurand authored
37 Disable the core Propel plugin and enable the `sfPropelORMPlugin` instead:
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
38
8e6722e @willdurand Updated README
willdurand authored
39 ``` php
40 // config/ProjectConfiguration.class.php
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
41
8e6722e @willdurand Updated README
willdurand authored
42 class ProjectConfiguration extends sfProjectConfiguration
43 {
4878b50 @willdurand Fixed README
willdurand authored
44 public function setup()
45 {
8e6722e @willdurand Updated README
willdurand authored
46 $this->enablePlugins('sfPropelORMPlugin');
4878b50 @willdurand Fixed README
willdurand authored
47 }
8e6722e @willdurand Updated README
willdurand authored
48 }
49 ```
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
50
4878b50 @willdurand Fixed README
willdurand authored
51 Right after the installation of the plugin, you should update plugin assets:
52
53 php symfony plugin:publish-assets
54
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
55 Change the path of the symfony behaviors in the `config/propel.ini` file of your project:
56
8e6722e @willdurand Updated README
willdurand authored
57 ``` ini
58 // config/propel.ini
59
60 propel.behavior.symfony.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorSymfony
61 propel.behavior.symfony_i18n.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorI18n
62 propel.behavior.symfony_i18n_translation.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorI18nTranslation
63 propel.behavior.symfony_behaviors.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorSymfonyBehaviors
64 propel.behavior.symfony_timestampable.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorTimestampable
65 ```
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
66
67 (Re)Build the model:
68
8e6722e @willdurand Updated README
willdurand authored
69 php symfony propel:build --all-classes
70
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
71
8e6722e @willdurand Updated README
willdurand authored
72 ## What's New In Propel 1.6
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
73
8e6722e @willdurand Updated README
willdurand authored
74 Propel 1.6 is a **backwards compatible** evolution of Propel 1.4 (the version bundled with symfony 1.3 and 1.4), which adds some very interesting features. Among these features, you will find the **new Propel Query API**, which is essentially a Criteria on steroids:
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
75
8e6722e @willdurand Updated README
willdurand authored
76 ``` php
77 // find the 10 latest books published by authror 'Leo'
78 $books = BookQuery::create()
79 ->useAuthorQuery()
80 ->filterByFirstName('Leo')
81 ->endUse()
82 ->orderByPublishedAt('desc')
83 ->limit(10)
84 ->find($con);
85 ```
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
86
8e6722e @willdurand Updated README
willdurand authored
87 Propel 1.6 also supports **many-to-many relationships**, **collections**, **on-demand hydration**, **new core behaviors** (see below), better Oracle support, and is now licensed under the MIT license.
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
88
89
8e6722e @willdurand Updated README
willdurand authored
90 ## Core Propel Behaviors
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
91
8e6722e @willdurand Updated README
willdurand authored
92 Propel 1.6 bundles most common behaviors in a new, robust buildtime implementation. These core behaviors provide faster runtime execution and the ability to modify the data model:
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
93
8e6722e @willdurand Updated README
willdurand authored
94 - [timestampable](http://www.propelorm.org/wiki/Documentation/1.6/Behaviors/timestampable)
95 - [sluggable](http://www.propelorm.org/wiki/Documentation/1.6/Behaviors/sluggable)
96 - [soft_delete]([http://www.propelorm.org/wiki/Documentation/1.6/Behaviors/soft_delete)
97 - [nested_set](http://www.propelorm.org/wiki/Documentation/1.6/Behaviors/nested_set)
98 - [sortable](http://www.propelorm.org/wiki/Documentation/1.6/Behaviors/sortable)
99 - [concrete_inheritance](http://www.propelorm.org/wiki/Documentation/1.6/Inheritance#ConcreteTableInheritance)
100 - [query_cache](http://www.propelorm.org/wiki/Documentation/1.6/Behaviors/query_cache)
9d248d4 @GromNaN typo
GromNaN authored
101 - [alternative_coding_standards](http://www.propelorm.org/wiki/Documentation/1.6/Behaviors/alternative_coding_standards)
8e6722e @willdurand Updated README
willdurand authored
102 - [auto_add_pk](http://www.propelorm.org/wiki/Documentation/1.6/Behaviors/auto_add_pk)
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
103
8e6722e @willdurand Updated README
willdurand authored
104 `sfPropelORMPlugin` allows you to register core propel behaviors right from your `schema.yml`. For instance, to create a tree structure from a `Section` model:
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
105
8e6722e @willdurand Updated README
willdurand authored
106 ``` yaml
107 propel:
108 section:
109 _attributes: { phpName: Section }
110 _propel_behaviors:
111 - nested_set
112 id: ~
113 title: { type: varchar(100), required: true primaryString: true }
114 ```
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
115
8e6722e @willdurand Updated README
willdurand authored
116 **Tip**: Check the [`doc/schema.md`](https://raw.github.com/propelorm/sfPropelORMPlugin/master/doc/schema.md) file in this plugin source code for a complete reference of the YAML schema format.
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
117
8e6722e @willdurand Updated README
willdurand authored
118 You can also register a behavior for all your models right in the `propel.ini` configuration file. `sfPropelORMPlugin` already enables the `symfony` and `symfony_i18n` behaviors to support symfony's behavior system and model localization features, but you can easily add your owns:
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
119
8e6722e @willdurand Updated README
willdurand authored
120 ``` ini
121 propel.behavior.default = symfony,symfony_i18n,alternative_coding_standards,auto_add_pk
122 ```
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
123
8e6722e @willdurand Updated README
willdurand authored
124 ## Admin Generator Extensions
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
125
8e6722e @willdurand Updated README
willdurand authored
126 The plugin comes bundled with a new admin generator theme named 'admin15'. This theme is backwards compatible with sfPropelPlugin's admin generator theme, and provides additional features based on the new Propel 1.6 query objects:
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
127
128 ### List view enhancements
129
130 - **Easy related objects hydration**: You don't need to write custom `doSelectJoinXXX()` methods to hydrate related objects. The `with` setting is much more poxwerful that the previous `peer_method` and `peer_count_method` settings, and much easier to use.
131 - **Custom query methods**: You can refine the query executed to display the list view by by setting the `query_methods` parameter. This allows to hydrate an additional column wit hno additional query, or to pre-filter the list to hide rows that the user shouldn't see.
132 - **All columns are sortable**: Virtual columns and foreign key columns are now sortable in the list view. You'll need to set the sort method to use for that, but it's a one-liner. No more lists with column headers that can't be clicked for sorting!
133 - **Easy links to filtered lists**: A link to a fitlered list view is very easy to write with the new theme. Just add GET parameter, the same way you used to do with the admin generator in symfony 1.2, and it works
134 - **Links to another admin module**: To make a foreign key column link to the edit view of the related object in another module, you no longer need to create a partial. Just define the `link_module` setting in the foreign key field configuration, and you're good to go:
135 - **Easy custom filters**: Adding custom filters becomes very easy once you can take advantage of the generated Propel query classes. This allows your, for instance, to setup a full-text search input in two minutes, replacing many text filters by a single one for better usability.
136
137 ### Filter and Edit forms enhancement
138
139 - **YAML widget customization**: The `generator.yml` format was extended to allow widget and validator customization directly in YAML, without the need to edit a form object. You can also safely omit a field from a `display` list in a form definition, without any risk to loose data.
140 - **Plain text field**: If you want to display some data in a form without allowing the user to edit it, use the `type: plain` attribute, just like in the old days of symfony 1.2. This is very useful for columns managed by the model, like `created_at` and `updated_at` columns.
141
8e6722e @willdurand Updated README
willdurand authored
142 The new options for the `admin15` generator theme are fully documented, and illustrated by real life examples, in the [`doc/admin_generator.md`](https://raw.github.com/propelorm/sfPropelORMPlugin/master/doc/admin_generator.md) file in this plugin source code.
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
143
8e6722e @willdurand Updated README
willdurand authored
144 ## Form Subframework Modifications
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
145
0ba5f54 Removed trailing spaces
rozwell authored
146 - **Updated `sfWidgetFormPropelChoice` widget**: The widget now uses the new Query API. You can customize the list of choices more easily by executing custom query methods, using the new `query_methods` option.
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
147 - **Updated Propel validators**: Both the `sfValidatorPropelChoice` and the `sfValidatorPropelUnique` were updated to use the new PropelQuery objects, and to accept a `query_methods` option similar to the one of `sfWidgetFormPropelChoice`.
148 - **Plain text widget and validator**: This new widget allows a field to be displayed in a form, without letting the use change it.
149 - **Easy Relation Embed**: Editing related objects together with the main objects (e.g., editing `Comments` in a `Post` form) is a piece of cake. The new `sfFormPropel::embedRelation()` method does all the work to fetch related objects, build the forms for each of them, and embed the related object forms into the main form. Embdeded relation forms allow to **edit**, **add**, and **delete** a related objects with no additional code.
150
8e6722e @willdurand Updated README
willdurand authored
151 ``` php
152 class ArticleForm extends BaseArticleForm
153 {
76a8cf1 @willdurand Fixed indentation in README
willdurand authored
154 public function configure()
155 {
8e6722e @willdurand Updated README
willdurand authored
156 $this->embedRelation('Book');
76a8cf1 @willdurand Fixed indentation in README
willdurand authored
157 }
8e6722e @willdurand Updated README
willdurand authored
158 }
159 ```
160
161 The Propel widgets, validators, and form classes are fully documented in the [`doc/form.md`](https://raw.github.com/propelorm/sfPropelORMPlugin/master/doc/form.md) file in this plugin source code.
162
163 ## Routing Modifications
164
165 The plugin offer two new routing classes, `sfPropelORMRoute` and `sfPropelORMRouteCollection`. These classes are used by default in the models build with the propel admin generator. They behave just like the previous `sfPropelRoute` class - except they don't use the `methods` option anymore. Instead, use the `query_methods` option to execute a list of arbitrary query methods when calling `getObject()` and `getObjects()`.
166
167 ``` yaml
168 author:
169 class: sfPropelORMRouteCollection
170 options:
171 model: author
172 module: author
173 prefix_path: /author
174 column: id
175 query_methods:
176 object: [filterByIsPublished]
177 list: [filterByIsPublished, orderByLastName]
178 with_wildcard_routes: true
179 ```
a0ecb20 @fzaninotto [1.6] Markdown is more natural and easier to read than RST, reverting…
fzaninotto authored
180
09f08af query methods:
rozwell authored
181 Array of additional parameters are also possible for `query_methods`:
182
8e6722e @willdurand Updated README
willdurand authored
183 ``` yaml
184 author:
185 class: sfPropelORMRouteCollection
186 options:
187 model: author
188 module: author
189 prefix_path: /author
190 column: id
191 query_methods:
192 object:
193 filterByIsPublished: [false]
194 list:
195 filterByIsPublished: []
196 orderBy: [LastName]
197 with_wildcard_routes: true
198 ```
199
200 `sfPropelORMRoute` also makes your code a little easier to read in the action. Instead of calling `getObject()`, you can actually call a getter using the class name of the object's route:
201
202 ``` php
203 public function executeShow(sfWebRequest $request)
204 {
205 // using sfPropelORMRoute with 'Author' as model
206 $this->author = $this->getRoute()->getAuthor();
207 }
208 ```
Something went wrong with that request. Please try again.