Skip to content

Instantly share code, notes, and snippets.

@mnapoli
mnapoli / README.md
Last active August 29, 2015 14:23
Boot2docker on OS X

Boot2docker on OS X

Problems:

  • permissions
  • slow I/O because of vboxfs

Solution: mount the disk using NFS.

On OS X

<?php
return [
'doctrine.orm.configuration' => [
'driver' => 'pdo_mysql',
'user' => 'root',
'password' => '',
'dbname' => get('doctrine.orm.db_name'),
],
@mnapoli
mnapoli / gist:3752568
Created September 19, 2012 21:57
PHP Dependency Injection
class MyClass {
/**
* @Inject
* @var MyService
*/
private $service;
}
@mnapoli
mnapoli / php-hotkey.ahk
Created October 17, 2012 08:46
Autohotkey script for PHP developers on the BÉPO layout
; PHP developer shortcuts for BÉPO keyboard layouts
; Need AutoHotkey_L to support unicode encoding (http://www.autohotkey.com/download/)
; "->" for PHP (when typing <Alt>+8)
!-::
Send ->
return
@mnapoli
mnapoli / DDC1734Article.php
Created December 3, 2012 08:53
Test for Doctrine Issue DDC-1734
<?php
namespace Doctrine\Tests\Models\DDC1734;
/**
* @Entity
*/
class DDC1734Article
{
@mnapoli
mnapoli / install.sh
Created December 13, 2012 14:33
Basic linux package installation for development
sudo apt-get install subversion git mercurial python perl ruby
@mnapoli
mnapoli / DI-Configuration.md
Last active December 15, 2015 06:19
PHP-DI alternative configuration options

Reflections on PHP-DI configuration.

Currently, the configuration is in PHP or annotations, PHP config has the following advantages:

  • PHP developpers know PHP
  • IDE autocompletion/error detection
  • Bean definition using closures

Disadvantages of PHP:

@mnapoli
mnapoli / optional singleton pattern.php
Last active December 15, 2015 07:09
"Optional singleton" pattern
<?php
// See also http://en.mnapoli.fr/the-optional-singleton-pattern/
class MyService
{
private static $singletonInstance = null;
/**
* Keep the constructor public
*/
@mnapoli
mnapoli / Collection.php
Last active December 16, 2015 16:49
Collection and Map interface
<?php
/**
* In this example, a collection is a map of values indexed by a key (numeric or string)
*/
interface Collection extends Countable, IteratorAggregate, ArrayAccess
{
function add($value);
function set($key, $value);
@mnapoli
mnapoli / gist:5874705
Last active December 19, 2015 01:19
PHP 5.5 ::class feature
<?php
use A\Long\Namespace\User;
use Some\Namespace\ProductService;
// Doctrine: get entity
$user = $entityManager->find('A\Long\Namespace\User', 1234);
$user = $entityManager->find(User::class, 1234);
// Doctrine repositories