[PropelBundle] Added more details in the README

This commit is contained in:
Francois Zaninotto 2010-06-07 00:10:59 +02:00 committed by Fabien Potencier
parent ca00e20748
commit 3a35c327c5
1 changed files with 50 additions and 1 deletions

View File

@ -6,7 +6,8 @@ This is a (work in progress) implementation of Propel in Symfony 2.
Currently supports:
* Generation of model classes based on an XML schema (not YAML) placed under `BundleName/Resources/*schema.xml`.
* Propel runtime initialization through `$container->getPropelService()`.
* Runtime autoloading of Propel and generated classes
* Propel runtime initialization through the XML configuration.
Installation
------------
@ -42,6 +43,54 @@ Sample Configuration
# dsn: mysql:host=localhost;dbname=test
# options: {}
### Sample Schema
Place the following schema in src/Application/HelloBundle/Resources/config/schema.xml:
<?xml version="1.0" encoding="UTF-8"?>
<database name="default" package="Application.HelloBundle.Model" defaultIdMethod="native">
<table name="book" namespace="Application\HelloBundle\Model">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="title" type="varchar" primaryString="1" size="100" />
<column name="ISBN" type="varchar" size="20" />
<column name="author_id" type="integer" />
<foreign-key foreignTable="author">
<reference local="author_id" foreign="id" />
</foreign-key>
</table>
<table name="author" namespace="Application\HelloBundle\Model">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="first_name" type="varchar" size="100" />
<column name="last_name" type="varchar" size="100" />
</table>
</database>
### Build Process
Call the application console with the `propel:build` task:
> ./hello/console propel:build --classes
### Use The Model Classes
Use the Model classes as any other class in Symfony. Just use the correct namespace, and Symfony will autoload them:
class HelloController extends Controller
{
public function indexAction($name)
{
$author = new \Application\HelloBundle\Model\Author();
$author->setFirstName($name);
$author->save();
return $this->render('HelloBundle:Hello:index', array('name' => $name, 'author' => $author));
}
}
Known Problems
--------------