Professional Documents
Culture Documents
Symfony Cheat Sheet: by Via
Symfony Cheat Sheet: by Via
KnpBundles http://knpbundles.com/ php composer.phar update Creates a field with all entities from one
class
Folders Forms generation country/language/locale/timezone
Contains configuration, cache, logs, ... Adds a form filed, where $child is the birthday
Everything that is not the source code member, $type is the input type and Same as datetime, but with more recent
/src $options the type's options years
pattern nullable
Doctrine
The pattern to match Allows the column to contain null
@ORM\Entity((repositoryClass="Me\Bundle\Enti
defaults precision
ty\Repository")
The bundle and controller to use Number of total digits, for decimal type
Declares a class as an ORM entity, with
requirements Me\Bundle\Entity\Repository being its scale
List of required parameters and their format repository Number of digits after point, for decimal type
@ORM\Table(name="table_name")
Example:
Doctrine column types
HelloTheWorld: Changes a table name
pattern: /hello-world/{name}.{format} string
@ORM\Column(type="string")
defaults: { _controller: MyBundle:Blog:index,
Declares an attribute as being a table Every string up to 255 chars
format: html }
requirements: column integer
name: \w @ORM\OneToOne(targetEntity="Me\Bundle\Entit Numbers up to 2.147.483.647
format: html|xml y\Column", cascade={"persist"})
boolean
Declares a One-To-One relation. cascade
Request parameters Boolean values; true and false
cascades some operations (such as persist
$_GET['tag'] or remove) to the relation decimal
Note Declares that the Entity has callbacks Doctrine Query Builder
$request = $this->get('request');
$query->select('a')
Doctrine Column parameters
Set columns to get
Twig
type
$query->addSelect('a')
{{ id }} Column type
Adds columns to get
Show variable id content
name
$query->leftJoin('alias.column', 'column_alias')
{{ id|upper }} Column name
Joins an Entity to the request, just like a
Show variable id content in uppercase.
length LEFT JOIN
Works with a lot of other filters
Column length, only for string type
$query->where('a.column = ?')
{% if condition %} {% elseif condition %} {%
else %} {% endif %} Sets the WHERE conditions
if/elseif/else structure
Note : Loggable
$query = $this->createQueryBuilder('alias'); Helps tracking changes and history of
objects, also supports version managment
Doctrine Callbacks
Sortable
PrePersist Makes any document or entity sortable
Executed just before a persist(). Therefore,
Softdeletable
the $id isn't available, but all changes made
to the Entity will be persisted in database Allows to implicitly remove records
PostPersist Uploadable
PostUpdate
PreRemove
PostRemove
PostLoad