The sfDoctrineTablePlugin generates feature packed base tables to each model.
Base table contains PHPDocs of available pre-generated WHERE, COUNT
and JOIN considering table relations and its depth. List of new available
methods are accessed through the PHPDoc @method annotation and is suitable for IDE
users only.

Plugin generates feature packed base tables to each model. Base table contains PHPDocs of available pre-generated WHERE, COUNT and JOIN considering table relations and its depth. List of new available methods are accessed through the PHPDoc tag @method and are suitable for IDE users only.

Developers

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release 1.0.3 - 19/10/2011

sfDoctrineTablePlugin

The sfDoctrineTablePlugin generates feature packed base tables for models.
Base table contains PHPDocs of available pre-generated WHERE, COUNT
and JOIN methods, considering table relations and its depth. List of pre-generated PHPDoc
methods are accessed through the @method annotation and is suitable for IDE
users only (perfect implementation in NetBeans since v7.1)

Table of contents

Release notes

Plugin version v2.X.X has new API and is not compatible with v1.X.X.
To install new major version you must uninstall current version.
How to correctly uninstall plugin you can find in v1.X.X's README file.

Plugin helps you not to keep in mind table relation aliases and escape from the
constructing left and/or inner joins.
It gives you ability to use pre-generated methods with IDE code-completion
to speed-up your coding. Also, you can easy add your owns methods to the generator's
template by extending it (see 8. Extending the generator).

In case you have your own-custom Doctrine_Table class (e.g. My_Doctrine_Table), then you
need to make it inherited from class Doctrine_Table_Scoped, not from Doctrine_Table class.
It can be done inside config/ProjectConfiguration.class.php:

Here is a default plugin configuration. All the configuration options are used to
find all PHP files where you keep a business logic.

---
all:
sfDoctrineTablePlugin:
# Given below finder_* options used to find which methods
# are used in your project and further remove then in production environment
finder_search_in: [%SF_APPS_DIR%, %SF_LIB_DIR%] # List of directories where business logic are located
finder_prune_folders: [base, vendor] # List of folders to prune
finder_discard_folders: [] # List of folders to discard
finder_name: ["*.php"] # List of file-names to add
finder_not_name: [] # List of file-names to skip

By the default base tables will be generated for all models and to for only enabled
plugins that contains schema files. Occasionally, you won't use
all models to query its data. Only some of them will be used to save data. In
such cases is reasonable to disable such models from generating base tables. How to do that
please refer to 6.5. Turning off base table generation for
specific models.

According to my own experience, the most profit you will get in case you disable
automatic relation detection (detect_relations: false) and setup only important
to you relations by hand. Advantages to the solutions are clear and good-looking method
names.

SELECT
c.id AS c__id, c.country_id AS c__country_id, c.title AS c__title,
c2.id AS c2__id, c2.capital_city_id AS c2__capital_city_id, c2.title AS c2__title,
c3.id AS c3__id, c3.country_id AS c3__country_id, c3.title AS c3__title,
c4.id AS c4__id, c4.capital_city_id AS c4__capital_city_id, c4.title AS c4__title
FROM city c
INNERJOIN country c2 ON c.country_id = c2.id
LEFTJOIN city c3 ON c2.capital_city_id = c3.id
LEFTJOIN country c4 ON c3.id = c4.capital_city_id

By the default JOIN's deepness is set to 3 (superfluously enough), but you can adjust it
by passing flag --depth. The level of depth does not affects on speed
in production environment (see Optimize tables for production):

When you deploy your code to production server, you can minimize generated base
table file size by passing flag --no-phpdoc (e.i. base tables without
@method hints) and combining with --minified (e.i. do not generate methods,
that aren't used in project).

By the default doctrine:build-model task will generate base tables for each
existing-active model, unless you disable it. To disable model you need to set table value to be false:
table: false for specific model in schema.yml file:

---
Book:
options:
symfony: { table: false }

Then rebuild models by executing:

./symfony doctrine:build-model

And then, generate an updated version of base tables:

./symfony doctrine:build-table

There are some nuances to keep in mind. When you disable model(-s), which base table(-s) was generated before,
task doctrine:build-table will uninstall disabled base table automatically.

This information helps to build requested method on the fly by implementing magic
method __call. Parsing PHPDoc on the fly is fast (< 0.003 sec) even the
base table is not minified and contains @method hints (about 700kb).

Then, create a new generator class (e.g. MyDoctrineTableGenerator) by extending
it from sfDoctrineTableGenerator class. And use it when you run
doctrine:build-table task by passing --generator-class option: