Skip to content

Instantly share code, notes, and snippets.

View stefankleff's full-sized avatar

Stefan Kleff stefankleff

View GitHub Profile
@stefankleff
stefankleff / UploadListener.php
Last active April 14, 2021 07:17
Usage of IDs in files and directories for VichUploader bundle
<?php
namespace App\EventListener;
use Doctrine\Common\EventArgs;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\OnFlushEventArgs;
use Vich\UploaderBundle\EventListener\Doctrine\BaseListener;
class UploadListener extends BaseListener
@stefankleff
stefankleff / gist:f6d16a882fabe8c19dc8
Created July 4, 2014 13:32
Escaping with a proxy
/** @var Bar $bar */
$bar = new EscapingProxy(new Bar());
echo $bar->qux;
echo $bar->getFoo()->baz;
echo $bar->getFoo()->getBaz();
@stefankleff
stefankleff / composer.json
Created May 2, 2013 08:23
External tools for PHPStorm
{
"name": "goalio/phpstorm",
"description": "External tools for phpstorm",
"require": {
"php": ">=5.3.0",
"phpmd/phpmd" : "1.4.*",
"zerkalica/phpcs": "dev-master",
"phpunit/phpunit": "3.7.*",
"phing/phing": "2.5.*"
@stefankleff
stefankleff / gist:5143827
Last active December 14, 2015 20:28
Deferred loading of inherited classes
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
<?php
interface A {
public function foo();
}
abstract class B implements A {
abstract public function foo();
}
class C extends B {
@stefankleff
stefankleff / gittyup.sh
Created August 30, 2012 13:10 — forked from EvanDotPro/gittyup.sh
Easily keep master in sync with upstream.
####################################################################################
## ##
## gittyup() - Easily keep master in sync with upstream. ##
## ##
## Author: Evan Coury, http://blog.evan.pro/ ##
## URL: https://gist.github.com/1506822 ##
## ##
## This bash function is a simple shortcut for keeping your local (and public ##
## fork / origin remote) master branch up to date and in sync with the upstream ##
## master. To use gittyup(), simply drop this in your ~/.bashrc. ##
@stefankleff
stefankleff / gist:3237158
Created August 2, 2012 13:38
Json aware POST/PUT processing
/**
* Process post data and call create
*
* @param Request $request
*/
public function processPostData(Request $request)
{
$contentType = $request->getHeaders('Content-Type')->getFieldValue();
switch(true) {
@stefankleff
stefankleff / ZfClassmapTask.php
Created May 29, 2012 07:40 — forked from shevron/ZfClassmapTask.php
Zend Framework 2.0 style autoloader classmap generator task for Phing
<?php
/**
* Phing task to generate a Zend Framework style autoloader classmap file
*
* This task requires ZF 2.x to be in your include_path. You can run phing like
* so to enforce this:
*
* $ export PHP_COMMAND="php -d include_path=.:<path to zf library>:<path to pear>"
* $ phing ...