This post is basically a crib sheet of Symfony 2 reminders for myself, but you're welcomed to use it if it helps. It's a short list right now, but I'll be periodically adding to it.
List available app/console commands
$ php app/console list
Useful DQL examples
Install web assets
$ php app/console assets:install web
The optional parameter --symlink will use symbolic links instead.
Force schema update
$ php app/console doctrine:schema:update --force
Note: consider using Doctrine Migrations instead
Create tables
$ php app/console doctrine:schema:create
Note: don't run this in a production setting
Create database
$ php app/console doctrine:database:create
Generate setters and getters
$ php app/console doctrine:generate:entities Package
Generates setters and getters for all entities in Package.
ORM annotation Column() options
- type (optional, default 'string')
- name (optional, default to field name)
- length (optional, default 255)
- unique (optional, default FALSE)
- nullable (optional, default FALSE)
- precision (optional, default 0) The precision for a decimal column.
- scale (optional, default 0) The scale for a decimal column.
- http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/reference/basic-mapping.html
- http://symfony.com/doc/current/book/doctrine.html#book-doctrine-field-types
Install doctrine fixtures in Symfony 2.1
Step 1 (only if necessary): install Composer
$ curl -s http://getcomposer.org/installer | php
Step 2: Update composer.json
{
"require": {
"doctrine/doctrine-fixtures-bundle": "dev-master"
}
}
Step 3 (optional): allow only stable updates in composer.json
Look for the key "minimum-stability", and change its value from "dev" to "stable", e.g.
"minimum-stability": "stable",
Step 4: update vendors library
$ php composer.phar update
// ...
public function registerBundles()
{
$bundles = array(
// ...
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
// ...
);
// ...
}
- http://symfony.com/doc/current/book/installation.html
- http://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html
Generate a new bundle
$ php app/console generate:bundle --namespace=Package/YourBundle --format=yml
Generates a new bundle named PackageYourBundle in the namespace named Package/YourBundle.
No comments:
Post a Comment