Skip to content

Instantly share code, notes, and snippets.

View ludofleury's full-sized avatar
🐼
Yay

Ludovic Fleury ludofleury

🐼
Yay
View GitHub Profile
<?php
namespace Playbloom\Tests;
use Doctrine\DBAL\Driver\PDOMySql\Driver;
class MysqlDriver extends Driver
{
private static $connection;
<?php
$myCountry = // your api call ....
echo '<html><head></head><body>'
echo $myCountry;
echo '</body>';
<?php
$pattern = '#^((\+33[\s|\.]?[1-9]{1})|(0\d{1}))([\s|\.]?[0-9]{2})#';
// $pattern = '#^O{1}#';
// $subpattern = '([\s|\.]?[0-9]{2}){8}';
$samples = [
'+33 1 22 33 44 55',
'01 02 03 04 05',
@ludofleury
ludofleury / StockValidator.php
Last active December 15, 2015 18:38
atoum mock example
<?php
namespace MyLittle\Bundle\BoxBundle\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Doctrine\Common\Persistence\ManagerRegistry;
use MyLittle\Bundle\BoxBundle\Model\ProductInterface;
use DomainException;
use InvalidArgumentException;
@ludofleury
ludofleury / atoum-is-awesome.php
Created March 8, 2013 10:44
The power of atoum, everything in my job should be so simple.
<?php
public function testAddBox()
{
$package = new Entity\Package();
$box = new \Mock\MyLittle\Bundle\BoxBundle\Entity\Box;
$this
->object($package->addBox($box))
->isIdenticalTo($package)
@ludofleury
ludofleury / MysqlContext.php
Last active November 8, 2021 14:41
A Behat Context with a hook to kill the Mysql connections
<?php
use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Behat\Symfony2Extension\Context\KernelDictionary;
use Behat\MinkExtension\Context\MinkContext;
class MysqlContext extends MinkContext implements KernelAwareInterface
{
use KernelDictionary;
@ludofleury
ludofleury / getset.sublime-snippet
Created February 15, 2013 02:25
PHP (Symfony) oriented getter-setter snippet for Sublime Text
<snippet>
<content><![CDATA[
/**
* Get $1
*
* @return ${2:[type]} \$$1
*/
public function get${1/(.*)/\u$1/}()
{
return \$this->${1:$SELECTION};
<?php
include(__DIR__ . '/config.php');
use PhpAmqpLib\Connection\AMQPConnection;
$exchange = 'router';
$queue = 'msgs';
$consumer_tag = 'consumer';
$conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
@ludofleury
ludofleury / app_test.php
Created September 8, 2012 04:33
Swiftmailer redirecting plugin in Silex
<?php
$app['mailer'] = $app->share(function ($app) {
$app['mailer.initialized'] = true;
return new \Swift_Mailer($app['swiftmailer.transport']);
});
$app['mailer']->registerPlugin(new \Swift_Plugins_RedirectingPlugin($config['swiftmailer']['delivery_address'], array('#^'.$config['swiftmailer']['delivery_address'].'$#')));
@ludofleury
ludofleury / 1-hack-header.php
Created August 24, 2012 22:52
OAuth2 bearer token
// because php sucks at providing custom headers...
$headers = apache_request_headers();
if (isset($headers['Authorization'])) {
$this->headers->set('Authorization', $headers['Authorization']);
}