Skip to content

Instantly share code, notes, and snippets.

View ahmed-bhs's full-sized avatar
👽

Ahmed EBEN HASSINE 脳の流れ ahmed-bhs

👽
View GitHub Profile
@silverbackdan
silverbackdan / OrSearchFilter.php
Last active July 12, 2023 09:30
The API Platform filter will allow you to pass a query `or[field1,field2]=value` to search multiple fields for a search value. It works by using the standard API Platform SearchFilter as a basis, and wrapping all of your OR queried inside a single AND query so you can combine with other where bys
<?php
declare(strict_types=1);
namespace App\Filter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Core\Exception\InvalidArgumentException;
use App\Entity\Term;
@vudaltsov
vudaltsov / Condition.php
Last active September 22, 2021 15:18
Conditional validator
<?php
declare(strict_types=1);
namespace App\Validator\Constraints;
use Symfony\Component\Validator\Constraints\Composite;
/**
* @Annotation()
@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.
*/
@lolautruche
lolautruche / autocomplete.php
Created July 16, 2017 09:31 — forked from pspanja/autocomplete.php
How to implement suggest/autocomplete for Solr Search Engine for eZ Platform
<?php
namespace Vendor\Bundle\ProjectBundle\Core\Search\Solr\Query\Content\FacetBuilder;
use eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder;
class SuggestionFacetBuilder extends FacetBuilder
{
public $prefix;
}
$ composer require --no-update symfony/framework-bundle "~2.3.3|~2.6.6"
$ composer require --no-update symfony/symfony "*"
$ composer update -q
$ composer show -i
...
symfony/framework-bundle v2.6.12
symfony/symfony          v2.8.1
@jpchateau
jpchateau / Interview back-end developer
Last active May 15, 2024 08:34
Entretien développeur back : PHP / Symfony / MySQL
Cible : Développeur PHP / Symfony / MySQL
Niveau : Senior
Ce document propose des questions classiques, sans piège, à poser lorsque vous désirez valider un candidat pour un poste de développeur back.
J'utilise personnellement cette trame de questions, libre à vous de vous en inspirer, d'ajouter vos propres questions, et de déterminer lesquelles sont éliminatoires à vos yeux.
Veille technologique
Quelle est la version actuelle de PHP ?
> http://php.net/supported-versions.php

What's the difference between cascade="remove" and orphanRemoval=true in Doctrine 2

TLDR: The cascade={"remove"} is like a "software" onDelete="CASCADE", and will remove objects from the database only when an explicit call to $em->remove() occurs. Thus, it could result in more than one object being deleted. orphanRemoval can remove objects from the database even if there was no explicit call to ->remove().

I answered this question a few times to different people so I will try to sum things up in this Gist.

Let's take two entities A and B as an example. I will use a OneToOne relationship in this example but it works exactly the same with OneToMany relationships.

class A
service class
annotation_reader Doctrine\Common\Annotations\FileCacheReader
assetic.asset_manager Assetic\Factory\LazyAssetManager
assetic.controller Symfony\Bundle\AsseticBundle\Controller\AsseticController
assetic.filter.cssrewrite Assetic\Filter\CssRewriteFilter
assetic.filter_manager Symfony\Bundle\AsseticBundle\FilterManager
assetic.request_listener Symfony\Bundle\AsseticBundle\EventListener\RequestListener
cache_clearer Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer
cache_warmer Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate
@rainyjune
rainyjune / gist:4084886
Created November 16, 2012 06:48
The best way to retry an AJAX request on failure using jQuery
$.ajax({
url : 'someurl',
type : 'POST',
data : ....,
tryCount : 0,
retryLimit : 3,
success : function(json) {
//do something
},
error : function(xhr, textStatus, errorThrown ) {
@mattbrictson
mattbrictson / 01-headers
Created October 29, 2011 00:08
How to Defeat the Browser Back Button Cache
Cache-Control: no-cache, max-age=0, must-revalidate, no-store