Skip to content

Instantly share code, notes, and snippets.

@pylebecq
pylebecq / .php_cs
Created July 29, 2015 13:05
My PHP CS Fixer config file
<?php
$finder = Symfony\CS\Finder\DefaultFinder::create()
->exclude(['vendor', 'storage'])
->in(__DIR__)
;
return Symfony\CS\Config\Config::create()
->fixers([
'align_double_arrow',
@pylebecq
pylebecq / augment-maxfiles-limit.md
Last active August 29, 2015 14:25
Augment maxfiles limit on OS X

How to augment maxfiles limit in OS X

  1. Create a plist file in /Library/LaunchDaemon (/Library/LaunchDaemons/limit.maxfiles.plist for example) with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 Label

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

Keybase proof

I hereby claim:

  • I am pylebecq on github.
  • I am pylebecq (https://keybase.io/pylebecq) on keybase.
  • I have a public key whose fingerprint is 1525 E15C 607B 330A C5C9 6467 C059 6538 FF59 8702

To claim this, I am signing this object:

Port Forwarding in Mavericks


Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

####1. anchor file Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like:

@pylebecq
pylebecq / pre-commit
Last active December 22, 2015 09:09
Git pre-commit hook that checks the syntax of commited php files and runs the php-cs-fixer on them.
#!/usr/bin/env php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependency: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*/
@pylebecq
pylebecq / FakeEntity.php
Created July 5, 2012 13:52
[Symfony2][2.0] A validator which trigger validation constraints only if an entity has some values in its properties. All properties of the entity must have a getter or must be public, otherwise the PropertyPath will throw an exception.
<?php
namespace Sensio\Bundle\FakeBundle\Entity;
use Sensio\Component\Validator\Constraints\ValidateIfNeeded;
use Symfony\Component\Validator\Constraints as Assert;
/**
* FakeEntity.
*