Skip to content

Instantly share code, notes, and snippets.

View chalasr's full-sized avatar

Robin Chalas chalasr

View GitHub Profile
@chalasr
chalasr / DoctrineDbalStatementInterface.php
Created February 1, 2016 12:28 — forked from gnutix/DoctrineDbalStatementInterface.php
Mock Builder for Doctrine EntityManager / Connection mock objects.
<?php
namespace Mocks;
use Doctrine\DBAL\Driver\Statement;
/**
* Doctrine DBAL Statement implementing \Iterator.
*
* This class has been created because of a bug in PHPUnit Mock Objects.
@chalasr
chalasr / tasks-2401.md
Last active December 23, 2016 11:49
Tasks Sportroops 24/01 - 28/01
@chalasr
chalasr / fosuser_password_generator.php
Last active January 20, 2016 10:16 — forked from Kydoh/new_gist_file
Generate random password (require FOSUserBundle)
<?php
$tokenGenerator = $this->getContainer()->get('fos_user.util.token_generator');
$password = substr($tokenGenerator->generateToken(), 0, 8); // 8 chars
@chalasr
chalasr / config.yml
Created January 19, 2016 15:06
FOSRestBundle Config
fos_rest:
view:
# default_engine: php
view_response_listener: force
force_redirects:
html: true
# xml: true
formats:
jsonp: true
json: true
@chalasr
chalasr / composer.json
Created January 18, 2016 15:21
Symfony 2.3 + FOSUserBUndle fresh installation
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
@chalasr
chalasr / EnhancedRepository.php
Last active September 26, 2023 00:59
Implements a custom EntityRepository using Factory in Symfony2.6+
<?php
namespace App\Util\Doctrine\Repository;
use App\Util\Doctrine\Entity\AbstractEntity;
use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
@chalasr
chalasr / ExampleRepository.php
Created January 13, 2016 18:06 — forked from gnugat/ExampleRepository.php
Declaring a Doctrine Repository as a service and injecting it a dependency.
<?php
namespace Acme\DemoBundle\Repository;
use Acme\DemoBundle\Dependency;
use Doctrine\ORM\EntityRepository;
/**
* Get this repository directly from the container: it will set the $dependency attribute.
* If you get it using Doctrine's "getRepository()", don't forget to call setDependency().
@chalasr
chalasr / pre-commit
Created January 12, 2016 09:31
Pre-commit hook that performs php-cs-fixer on each changed files.
#!/usr/bin/php
<?php
exec('git diff --cached --name-status --diff-filter=ACM', $output);
foreach ($output as $file) {
$fileName = trim(substr($file, 1) );
if (pathinfo($fileName,PATHINFO_EXTENSION) == "php") {
$lint_output = array();
exec("php -l " . escapeshellarg($fileName), $lint_output, $return);
@chalasr
chalasr / README.md
Last active January 8, 2016 22:52
Exclude specific extension from git add

Exclude files with ".php~" from GIT ADD :

git ls-files . | grep '\.php~$' | xargs git add

Exclude files already added by GIT ADD :

git ls-files . | grep '\.php~$' | xargs git reset --
@chalasr
chalasr / README.md
Last active January 8, 2016 12:36
Multiple remote on git-hosted repository

Assuming you have a repository hosted on git.server1.com and you want push it to another host.
Your remote "origin" is set to git.server1.com:username/repository.git

1- Create an empty repository from github interface

2- Add the "github" remote to your local repository

$ git remote add github [email protected]:username/repository.git

3- Add your previous commits into