Skip to content

Instantly share code, notes, and snippets.

In your repositories, watching your code. Always watching.

Marco Pivetta Ocramius

In your repositories, watching your code. Always watching.
View GitHub Profile
Ocramius / quick-doctrine-orm-zf2-sql-logging.local.php
Last active Oct 19, 2021
SQL Logger in Doctrine 2 ORM and ZF2
View quick-doctrine-orm-zf2-sql-logging.local.php
use Zend\ServiceManager\ServiceLocatorInterface;
return [
'service_manager' => [
'delegator' => [
'doctrine.entitymanager.orm_default' => [
function (ServiceLocatorInterface $sl, $name, $requestedName, $callback) {
/* @var $em \Doctrine\ORM\EntityManager */
Ocramius / psalm-compendium.php
Last active Oct 17, 2021
A small compendium of what is possible with `vimeo/psalm` 3.9.x to add some decent type system features to PHP
View psalm-compendium.php
// -- types are a compile-time propagated concept
class TheType
/** @var string */
public $foo = 'bar';
Ocramius /
Last active Aug 27, 2021
`__invoke` vs `function` vs `Closure`
Ocramius / User.php
Last active Aug 20, 2021
Doctrine 2 ManyToMany - the correct way
View User.php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
* @ORM\Entity()
* @ORM\Table(name="user")
class User
Ocramius / Caddyfile
Last active Jun 4, 2021
Example docker + docker-compose + caddy + traefik setup that routes to multiple apps from one exposed HTTP port
View Caddyfile
:80 {
root /serve
Ocramius / Foo.php
Last active Mar 12, 2021
Self hydrating object proxy in PHP Provides faster hydration by removing the need for reflection.
View Foo.php
class Foo
protected $foo;
protected $bar;
protected $baz;
View User.php
namespace HelloWorld;
use InvalidArgumentException;
* This class is somewhere in your library
* @Entity
* @Table(name="users")
Ocramius / BrutalForeignKeyDisablingMySQLPurger.php
Created Mar 4, 2015
Brutal ORM Purger for doctrine/data-fixtures
View BrutalForeignKeyDisablingMySQLPurger.php
namespace FixturesStuff
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\ORM\EntityManagerInterface;
* @TODO this has to go once we implement correct purging of entities
Ocramius / .gitignore
Last active Aug 26, 2020
`in_array` vs `array_unique` performance example (just a test, not really interesting data)
View .gitignore
View .gitlab-ci.yml
- docker:dind
image: tiangolo/docker-with-compose
- docker info