Skip to content

Instantly share code, notes, and snippets.

{
"require": {
"symfony/event-dispatcher": "2.1.0-stable"
}
}
@SofHad
SofHad / UseSymfonyAndTwig
Last active December 20, 2015 17:28
Use Symfony components and Twig in your project.
<?php
/*
# ------------------------------------------------------------------------
# SymfonyAsLib
# ------------------------------------------------------------------------
# Developer : Sofiane Haddag, [email protected]
*/
use Symfony\Component\Validator\Validation;
@SofHad
SofHad / gist:6168420
Created August 6, 2013 20:40
[Symfony Tests Unitaires] - Les assertions les plus utiles
// Vérifie qu'il y a au moins une balise h2 dans la classe "subtitle"
$this->assertGreaterThan(0, $crawler->filter('h2.subtitle')->count());
// Vérifie qu'il y a exactement 4 balises h2 sur la page
$this->assertCount(4, $crawler->filter('h2'));
// Vérifie que l'entête "Content-Type" vaut "application/json"
$this->assertTrue($client->getResponse()->headers->contains('Content-Type', 'application/json'));
// Vérifie que le contenu retourné correspond à la regex
@SofHad
SofHad / initializeSymfony
Created August 6, 2013 20:36
initialize Symfony Controller
public function initializeAction() {
$this->doctrine = $this->getDoctrine();
$this->bundle = $this->container->getParameter("bundle");
$this->entityManager = $this->doctrine->getEntityManager();
$this->productRepository = $this->doctrine->getRepository($this->bundle . ':Product');
$this->categoryRepository = $this->doctrine->getRepository($this->bundle . ':Category');
$this->categoryModel = $categoryModel = $this->get("CategoryModel");
$this->productModel = $this->get("ProductModel");
Doctrine/Common/DataFixtures/Exception/CircularReferenceException.php
Doctrine/Common/Annotations/AnnotationException.php
Doctrine/Common/CommonException.php
Doctrine/Common/Persistence/Mapping/MappingException.php
Doctrine/ORM/TransactionRequiredException.php
Doctrine/ORM/Query/QueryException.php
Doctrine/ORM/Query/AST/ASTException.php
Doctrine/ORM/Mapping/MappingException.php
Doctrine/ORM/UnexpectedResultException.php
Doctrine/ORM/PessimisticLockException.php
@SofHad
SofHad / Symfony Exceptions
Last active July 18, 2016 07:06
Symfony Exceptions
Symfony/Component/OptionsResolver/Exception/MissingOptionsException.php
Symfony/Component/OptionsResolver/Exception/OptionDefinitionException.php
Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.php
Symfony/Component/Serializer/Exception/InvalidArgumentException.php
Symfony/Component/Serializer/Exception/UnsupportedException.php
Symfony/Component/Serializer/Exception/UnexpectedValueException.php
Symfony/Component/Serializer/Exception/LogicException.php
Symfony/Component/Serializer/Exception/Exception.php
Symfony/Component/Serializer/Exception/RuntimeException.php
Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php