Skip to content

Instantly share code, notes, and snippets.

@sun
sun / config-dev.patch
Last active August 29, 2015 13:59
D8 config in files for development
diff --git a/sites/default/settings.php b/sites/default/settings.php
index b2ce930..9d0514e 100644
--- a/sites/default/settings.php
+++ b/sites/default/settings.php
@@ -611,7 +611,8 @@
* The 'bootstrap_config_storage' setting needs to be a callable that returns
* core.services.yml.
*/
- # $settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage');
+$settings['bootstrap_config_storage'] = 'Drupal\Core\Config\BootstrapConfigStorageFactory::getFileStorage';
@mathiasverraes
mathiasverraes / max.php
Created December 9, 2014 19:40
max($list, $function) in php
<?php
// test data
class Foo {
private $a;
private $b;
function __construct($a, $b)
{
@igorw
igorw / gist:1050974
Created June 28, 2011 11:42
Controllers as services with Silex.
<?php
class LazyServiceController
{
private $container;
private $serviceName;
public function __construct(\Pimple $container, $serviceName)
{
$this->container = $container;
@antillas21
antillas21 / sites.php
Created April 16, 2012 21:23
Steps to take Drupal site out of multi-site install
<?php
$sites = array(
'sitename.com' => 'sitename.com',
// the first sitename.com in the file, refers to the url content in the browser's window,
//you may/probably should replace this with a FQDN.
// the second sitename.com appearing after '=>' is the directory name inside sites/ where
//the site files are stored.
);
@tPl0ch
tPl0ch / FixtureTestCase.php
Created August 9, 2012 15:37
FixtureTestCase
<?php
namespace Reizwerk\TestSuiteBundle\Test;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Common\DataFixtures\Executor\MongoDBExecutor;
use Doctrine\Common\DataFixtures\Purger\MongoDBPurger;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
@cgmartin
cgmartin / pre-commit
Last active October 9, 2015 06:17
ZF2 Git pre-commit hook
#!/usr/bin/env php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP errors (lint), and make sure the
* code is PSR-2 compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*/
@davedevelopment
davedevelopment / index.php
Created November 13, 2012 16:36
Tinkering with a Hal resource DTO, separating the framework from the app and content negotiation
<?php
namespace Demo {
require __DIR__."/vendor/autoload.php";
use Nocarrier\Hal;
class Resource extends Hal {}
class ResourceResponse
@johnkary
johnkary / ReadOnlyFieldSubscriber.php
Created November 30, 2012 16:09
Display read-only Phone Number field in browser, while disallowing editing via form, even if user modifies the DOM to remove the readonly attribute
<?php
namespace Acme\UserBundle\Listener;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
@jonhattan
jonhattan / mycommands.drush.inc
Last active December 10, 2015 15:28
Example Drush commandfile. Place it in $HOME/.drush or /usr/share/drush/commands or any other valid location and clear drush cache afterwards.
<?php
function mycommands_drush_command() {
$items = array();
$items['one-command'] = array(
'description' => 'A command requiring two arguments.',
// Declare required arguments.
'arguments' => array(
'arg1' => 'arg1 description',
'arg2' => 'arg2 description',
@keopx
keopx / Vagrant_nfs_debian8.sh
Last active December 10, 2015 16:00
Vagrant NFS in Debian 8
sudo su
modprobe nfsd
# https://bugzilla.mozilla.org/show_bug.cgi?id=1056049#c8
systemctl stop nfs-kernel-server.service
systemctl disable nfs-kernel-server.service
systemctl enable nfs-kernel-server.service
systemctl start nfs-kernel-server.service