Skip to content

Instantly share code, notes, and snippets.

View chalasr's full-sized avatar

Robin Chalas chalasr

View GitHub Profile
@chalasr
chalasr / pthreads.md
Created May 10, 2017 21:56 — forked from krakjoe/pthreads.md
pthreads.md

Multi-Threading in PHP with pthreads

A Brief Introduction to Multi-Threading in PHP

  • Foreword
  • Execution
  • Sharing
  • Synchronization
  • Pitfalls
@chalasr
chalasr / todo.md
Last active February 23, 2017 09:41
Riad tasks
  1. Cabler les liens sur vue "Espace adhésion"

Dans la vue adhesion/espace.html.twig, on a deux liens qui pointent vers rien pour l'instant, il faut en fixer un et préparer le terrain pour l'autre.

  • Faire en sorte que le lien "Je veux adhérer" redirige sur l'étape 1 de l'adhésion ("/69/adhesion/infos-basique")
  • Cabler la route pour le lien "Je renouvelle mon adhésion" inclus:
    • Controller RenewAdhesionController. il existe déjà mais n'est pas cablé, il faut le faire en se basant sur l'existant. Il a juste besoin d'une méthode simple qui renvoie une vue (index?), pas besoin d'aller dans le détail pour l'instant.
    • Créer la vue en se basant sur l'existant (on a es vues adhesion/new/* pour controller NewAdhesionController). La vue contient quasiment rien si ce n'est un titre genre "Je suis déjà adhérent"
  • Créer la route qui correspond, je te laisse proposer pour l'url
@chalasr
chalasr / commandbus.php
Last active February 22, 2017 11:22
CommandBus simple example
<?php
class Adhesion
{
private $firstname;
private $createdAt;
public function __construct(string $firstname, string $lastname)
{
$this->firstname = $firstname;
@chalasr
chalasr / FeatureContextElementWithIdShouldHaveAttributeContaining.php
Created July 7, 2016 13:10
Behat context feature: Element with id :id should have attribute :attribute containing :expectedValue
<?php
/**
* @Then element with id :id should have attribute :attribute containing :expectedValue
*/
public function elementWithIdShouldHaveAttributeContaining($id, $attribute, $expectedValue)
{
$this->assertSession()->elementAttributeContains('css', '#'.$id, $attribute , $expectedValue);
}
@chalasr
chalasr / example.md
Created July 7, 2016 11:59 — forked from ericclemmons/example.md
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 <summary>Summary Goes Here</summary>
@chalasr
chalasr / CustomThirdPartyService.md
Last active July 4, 2016 22:25
JWTProvider override
  • First, create your custom service class, it could looks like:
namespace AppBundle\Security;

use FooThirdPartyBundle\OriginalService;

class CustomService extends OriginlService
{
    protected function customMethodOverride()
@chalasr
chalasr / ContainerAwareVersion.php
Created June 9, 2016 13:34
DoctrineMigration - Container-aware migration with EntityManager example
<?php
namespace Application\Migrations;
use AppBundle\Entity\Foo;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@chalasr
chalasr / README.md
Last active July 19, 2016 22:27
"Did you mean ...?" exception sample

Did you mean ...?

This function takes two main arguments that are $search and $possibleMatches and looks for a the closest word to $search in the $possibleMatches list.

Usage

@chalasr
chalasr / pre-commit
Last active August 24, 2016 09:40
git pre-commit hook that clean each modified file using php-cs-fixer
#!/usr/bin/php
<?php
exec('git diff --cached --name-status --diff-filter=ACM', $output);
foreach ($output as $file) {
$fileName = trim(substr($file, 1) );
if ("php" == pathinfo($fileName, PATHINFO_EXTENSION)) {
$lint_output = array();
exec("php -l " . escapeshellarg($fileName), $lint_output, $return);
if ($return == 0) {
@chalasr
chalasr / CustomUpdateSchemaCommand.php
Created April 15, 2016 19:10
Overridde the Doctrine UpdateSchemaCommand (doctrine:schema:update command).
// src/AppBundle/Command/CustomUpdateSchemaCommand.php
<?php
namespace AppBundle\Command;
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\UpdateSchemaDoctrineCommand;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;