Skip to content

Instantly share code, notes, and snippets.

View basz's full-sized avatar

Bas Kamer basz

View GitHub Profile
@basz
basz / module.config.php
Created March 16, 2012 22:01 — forked from SocalNick/module.config.php
Instantiating Zend Cache Adapter using Factory through Di
<?php
return array(
'di' => array(
'definition' => array(
'class' => array(
'Zend\Cache\StorageFactory' => array(
'methods' => array(
'factory' => array(
'cfg' => array(
'required' => true,
@basz
basz / gist:2215184
Created March 27, 2012 11:35
Phing, create uniquely named build directory in a tmp directory task
<target name="createbuilddir">
<php expression="substr(md5(microtime(true)), 0, 1)" returnProperty="uniquestamp" />
<property name="build.dir" value="${build.tmp}/phing_build_${uniquestamp}" override="true" />
<echo msg="Testing tmp dir ${build.dir}" />
<if>
<available file="${build.dir}" type="dir" value="Yes"/>
<then>
<phingcall target="createbuilddir">
@basz
basz / gist:2226624
Created March 28, 2012 14:29
a threesome
<?php
return array(
'di' => array(
'definition' => array(
'class' => array(
'PhingBundle\Configuration' => array(
'methods' => array(
'setRunnerDefaults' => array(
bootstrap file
<?php
require_once __DIR__ . '/../autoload_register.php';
$rootPath = realpath(dirname(__DIR__));
$testsPath = "$rootPath/tests";
if (is_readable($testsPath . '/TestConfiguration.php')) {
require_once $testsPath . '/TestConfiguration.php';
@basz
basz / gist:2350974
Created April 10, 2012 12:15
events - locator - lazy vs non lazy
// Could the event manager handle this better? I would want the lazy behavior without typing as much...
$events = StaticEventManager::getInstance();
// obvious method (Application\Service\StoreService is instanciated even when the event has not been triggered)
$events->attach('Application\Controller\PaypalController', 'transaction.completed', array($locator->get('Application\Service\StoreService'), 'processTransaction'), 100);
// lazy method (Application\Service\StoreService is instanciated when the event has been triggered)
$events->attach('Application\Controller\PaypalController', 'transaction.completed', function($e) use ($locator) {
$service = $locator->get('Application\Service\StoreService');
@basz
basz / gist:2568952
Created May 1, 2012 15:41
DI parameters woes
<?php
return array(
'di' => array(
'definition' => array(
'class' => array(
'Zend\Log\Logger' => array(
'addWriter' => array(
'writer' => array('required' => true),
)
@basz
basz / gist:2585767
Created May 3, 2012 13:48
conig override pattern
<?php
/**
* Global Configuration Override
*
* You can use this file for overridding configuration values from modules, etc.
* You would place values in here that are agnostic to the environment and not
* sensitive to security.
*
* @NOTE: In practice, this file will typically be INCLUDED in your source
* control, so do not include passwords or other sensitive information in this
@basz
basz / gist:2762126
Created May 21, 2012 12:35
composer
{
"name": "PhingService",
"description": "Zend Framework 2 module for Phing, a PHP project build system or build tool based on Apache Ant.",
"authors": [
{
"name": "Bas Kamer",
"email": "bas@bushbaby.nl"
}
],
@basz
basz / gist:2762772
Created May 21, 2012 14:57
vendor/bin/phing not created
// PROJECT THAT DEFINES BIN FILE
{
"name": "phing/phing",
"description": "PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.",
"keywords": ["build", "tool", "task"],
"homepage": "http://www.phing.info/",
"license": "LGPL3",
"authors": [
{
@basz
basz / application.config.php
Created May 21, 2012 22:06
module conf and composer
suppose this app is installed with composer and it has a dependancy on a module known to composer as 'vendor/moduleName'.
Would this work?
return array(
'modules' => array(
'Application',
'vendor/moduleName',
),
'module_listener_options' => array(
'config_glob_paths' => array(