Skip to content

Instantly share code, notes, and snippets.

View lwillems's full-sized avatar

Laurent WILLEMS lwillems

View GitHub Profile
@fdubost
fdubost / gist:6761662
Last active June 13, 2018 14:53
SQLite for Atoum tests in Symfony2
<?php
namespace M6\Helpers\Bundle\ORMBundle\Test\Controller;
use atoum\AtoumBundle\Test\Controller\ControllerTest as BaseControllerTest;
use atoum\AtoumBundle\Test\Asserters;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Output\NullOutput;
@webmozart
webmozart / array-validation-error-mapping.php
Last active June 25, 2023 23:30
A little experiment: Validating (potentially multi-leveled) arrays with the Symfony2 Validator component and returning the errors in the same data structure as the validated array by using the Symfony2 PropertyAccess component.
<?php
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\Validator\Constraints\All;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Optional;
use Symfony\Component\Validator\Constraints\Required;
@mandiwise
mandiwise / Update remote repo
Last active July 11, 2024 17:32
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@Nav-Appaiya
Nav-Appaiya / filling row with 2x 6-col
Created April 7, 2015 20:09
2 column twig loop using twig's batch loop
{% for row in badges|batch(2) %}
<div clas="row">
{% for badge in row %}
<div class="col-md-6">
<img src="{{ badge.imageUrl }}" alt="badge" class="badges img-responsive pull-left"/>
<blockquote class="pull-left">
<h3>{{ badge.assertion.badge.name }}</h3>
<p>{{ badge.assertion.badge.description }}</p>
<small>Achieved on {{ badge.assertion.issued_on }}</small>
select
co.Code '_id',
co.Code 'code',
co.name 'name',
co.Continent 'continent',
co.region 'region',
co.SurfaceArea 'surface_area',
co.IndepYear 'year_of_independence',
co.Population 'population',
co.LifeExpectancy 'life_expectancy',
@assada
assada / FormErrorsNormalizer.php
Last active May 22, 2019 08:42
Symfony 3 Form errors Normalizer
<?php
namespace Tire\DealerApiBundle\Serialize;
use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationPath;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Validator\ConstraintViolationInterface;
/**
* Class FormErrorsSerializer
@soyuka
soyuka / IriConverter.php
Created September 6, 2018 10:19
Override IriConverter and allow an ApiResource to not have any item route associated with it.
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@vvasiloi
vvasiloi / ExampleFactoryDecoratorTrait.php
Last active November 17, 2020 12:26
Extract options when decorating an example factory. See example usage in ProductExampleFactory.php. #sylius #fixtures #example #factory
<?php
namespace App\Fixture\Factory;
use Symfony\Component\OptionsResolver\OptionsResolver;
trait ExampleFactoryDecoratorTrait
{
/**
* @param array $options
@igormukhingmailcom
igormukhingmailcom / STUPID_SYLIUS_ISSUES.md
Last active February 6, 2024 08:25
Symfony/Sylius stupid issues that hard to debug and which may waste too many hours

Symfony/Sylius stupid issues that hard to debug and which may waste too many hours

1. [Doctrine\Common\Persistence\Mapping\MappingException] Class 'Your\SyliusPlugin\Entity\YourEntity' does not exist

When your plugin is AbstractResourceBundle and all your entities should be and actually placed at Model directory, you have that exception (notice ...\Entity\... at exception rather than ..\Model\...) for your Your\SyliusPlugin\Model\YourEntity.php that is weird.

This happens when you accidentally have your mapping file at src/Resources/config/doctrine/YourEntity.orm.xml (without ../model/.. part) rather than src/Resources/config/doctrine/model/YourEntity.orm.xml.

This issue may happen when you convert some of your application code (which use Entity directory) to plugin (which use Model directory).

@nuryagdym
nuryagdym / LoginSubcriber.php
Last active November 2, 2021 15:02
Symfony 4.4 google captcha integration to login form using KarserRecaptcha3Bundle
<?php
namespace App\EventSubscriber;
use App\Form\LoginType;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;