Skip to content

Instantly share code, notes, and snippets.

@haswalt
haswalt / ngxin.symfony
Created March 5, 2011 13:01
ngxin config for working with php-fpm and symfony using wildcard vhosts. "sfdev" is the suffix for hosts so to get to the site for example you would use http://example.sfdev/
server {
server_name .sfdev;
index index.php;
autoindex on;
client_max_body_size 256M;
charset utf-8;
set $root "";
@haswalt
haswalt / nginx.static
Created March 5, 2011 13:03
nginx config for loading generic php and html websites running php-fpm using wildcard vhosts. "webdev" is the suffix for hosts so to get to the site for example you would use http://example.webdev/
server {
server_name .webdev;
index index.html index.php;
autoindex on;
set $root "";
if ($host ~* ^(www\.)?(.+)\.webdev) {
set $root $2;
}
@haswalt
haswalt / SearchListener.php
Created May 4, 2011 16:22
Doctrine event listener
public function getSubscribedEvents()
{
return array(Events::postPersist);
}
public function postPersist(LifecycleEventArgs $args)
{
$em = $args->getEntityManager();
$uow = $em->getUnitOfWork();
@haswalt
haswalt / gist:1416060
Created December 1, 2011 11:36
Mapped Superclass example
<?php
namespace UKWM\Bundle\DictionaryBundle\Entity;
use \Doctrine\ORM\Mapping as ORM;
/**
* @ORM\MappedSuperclass
*/
class Definition
@haswalt
haswalt / gist:1416066
Created December 1, 2011 11:37
Subclass from Mapped superclass example
<?php
namespace UKWM\Bundle\DictionaryBundle\Entity;
use \Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="dictionary_colours", indexes={
* @ORM\Index(name="text_idx", columns={"text"})
<?php
namespace \Acme\Bundle\ExampleBundle\Entity;
use \Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="product_variants", indexes={
* @ORM\index(name="variant_name_idx", columns={"name"})
{% for competition in competitions %}
<tr>
<td>{{ competition.title }}</td>
<td>{{ competition.searchPhrase }}</td>
<td>{{ competition.openAt|date }}</td>
<td>{{ competition.closeAt|date }}</td>
<td>{{ competition.total }}</td>
</tr>
{% endfor %}
protected function parseResponse($raw)
{
$raw = trim($raw);
$response = null;
switch (substr($raw, 0, 1)) {
case '-':
throw new ResponseException(substr($raw, 4));
break;
case '+':
@haswalt
haswalt / TestWrapper.php
Created August 3, 2012 14:09
Stream wrapper to funit testing
<?php
namespace Versionable\Ration\Stream;
/**
* Dummy stream wrapper for unit tests
*
* @author Harry Walter <harry.walter@lqdinternet.com>
*/
class TestWrapper
@haswalt
haswalt / .gitconfig
Created February 4, 2013 18:00
My global git config
[user]
name = Harry Walter
email = ***********
[branch "master"]
remote = origin
merge = refs/heads/master
[color]
diff = auto