12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- Propel Bundle
- =============
- 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`.
- * Runtime autoloading of Propel and generated classes
- * Propel runtime initialization through the XML configuration.
- Installation
- ------------
- * Checkout Propel and Phing in the src/vendor/ directory
- > cd sandbox/src/vendor
- > svn checkout http://svn.propelorm.org/branches/1.5 propel
- > svn checkout http://phing.mirror.svn.symfony-project.com/tags/2.3.3/classes/phing phing
-
- Sample Configuration
- --------------------
- ### Project configuration
- # in sandbox/hello/config/config.yml
- propel.config:
- path: %kernel.root_dir%/../src/vendor/propel
- phing_path: %kernel.root_dir%/../src/vendor/phing
- propel.dbal:
- driver: mysql
- user: root
- password: null
- dsn: mysql:host=localhost;dbname=test
- options: {}
- # default_connection: default
- # connections:
- # default:
- # driver: mysql
- # user: root
- # password: null
- # 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" namespace="Application\HelloBundle\Model" defaultIdMethod="native">
- <table name="book">
- <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">
- <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
- --------------
- Your application must not be in a path including dots in directory names (i.e. '/Users/me/symfony/2.0/sandbox/' fails).
|