Skip to content

Instantly share code, notes, and snippets.

View ornicar's full-sized avatar
💭
⏚⏚⏚⏚

Thibault Duplessis ornicar

💭
⏚⏚⏚⏚
View GitHub Profile
Symfony2 project with frontend+backend
Architecture example
- Only one kernel.
- Bundles can have different routing files, controllers and views for frontend and backend
- bundle different routing files are imported from app/config/routing.yml using prefixes
app/
AppKernel
config/
<select id="article_publishedAt_month" name="article[publishedAt][month]">
<option value="1">Jan</option>
<option value="2">Feb</option>
<option value="3">Mar</option>
<option value="4">Apr</option>
<option value="5">May</option>
<option value="6">Jun</option>
<option value="7">Jul</option>
<option value="8">Aug</option>
<option value="9" selected="selected">Sep</option>
# Mapping
unmap ?
map ? enterFindMode
map = showHelp
unmap gf
# Hints
qsdfghjklm
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
alias sf='php symfony'
alias git-archive='git archive'
alias swap='sudo swapoff -a && sudo swapon -a'
alias apt-hop='sudo apt-get update && sudo apt-get upgrade'
alias s='git status'
alias d='git diff'
alias subupdate='git submodule sync && git submodule update --init --recursive'
<?php
namespace Application\ExerciseBundle\Twig\Extension;
class ExerciseTwigExtension extends \Twig_Extension
{
public function getFilters()
{
return array(
'numberFormat' => new \Twig_Filter_Method($this, 'numberFormatFilter'),
class TagCollection implements Collection
{
/**
* Magic PHP method that intercepts method calls and redirects them to the internal collection object
*
* @param string $method The method on the object to be called
* @param array $args An array of arguments to be passed to the method
*
* @return mixed The result of the method
*/
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
$document = $eventArgs->getDocument();
$isTagsChanged = $eventArgs->hasChangedField('tags')
<?php
class Article extends Content
{
protected $comments; // a Collection implementation, ArrayCollection or PersistentCollection
// get the ArrayCollection or PersistentCollection
public function getComments()
{
return $this->comments;
" disable arrow keys
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
http://github.com/fabpot/symfony/commit/8fbf19694f253e8bacdd677362ee58967506bbb3
Here is a vim command to update mongodb document mapping annotation (requires the DirDo plugin http://www.vim.org/scripts/script.php?script_id=367)
:DDF src/Bundle,src/Application *.php %s/\v\\*(\\s+)\@(Document|Id|Field|String|Int|Float|Bool|Date|Distance|Reference|Embed|Mapped|HasLife|Index|UniqueIndex|Hash)/*\\1@mongodb:\\2/gIce\ |\ update