Skip to content

Commit

Permalink
[PropelBundle] Added more details in the README
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois Zaninotto authored and fabpot committed Jun 11, 2010
1 parent ca00e20 commit 3a35c32
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion src/Symfony/Framework/PropelBundle/README
Expand Up @@ -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
------------
Expand Down Expand Up @@ -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
--------------

Expand Down

0 comments on commit 3a35c32

Please sign in to comment.