Skip to content

Instantly share code, notes, and snippets.

View juriansluiman's full-sized avatar

Jurian Sluiman juriansluiman

View GitHub Profile
@juriansluiman
juriansluiman / Module.php
Created January 30, 2014 09:15
Example how to integrate an EmailService into the ArticleService
<?php
namespace MyEmailThingy;
class Module
{
public function onBootstrap($e)
{
$app = $e->getApplication();
$em = $app->getEventManager();
@juriansluiman
juriansluiman / benchmark-beanstalkd.pull.php
Created January 24, 2014 07:24
Benchmarks ran for comparing Beanstalkd and Gearman
<?php
include 'vendor/autoload.php';
$pheanstalk = new Pheanstalk_Pheanstalk('127.0.0.1');
$pheanstalk->useTube('default');
$n = 1000000;
$start = microtime(true);
'slm_queue' => [
'worker' => [
'max_runs' => 100,
],
'queues' => [
'default' => [
'deleted_lifetime' => -1
],
],
<?php
class DbResolver implements ResolverInterface
{
protected $adapter;
public function __construct(AuthAdapter $adapter)
{
$this->adapter = $adapter;
}
@juriansluiman
juriansluiman / Module.php
Last active December 31, 2015 03:19
A Christmas #zf2 easter egg
<?php
namespace EasterEgg;
use DateTime;
class Module
{
public function onBootstrap(MvcEvent $e)
{
@juriansluiman
juriansluiman / BarController.php
Last active December 16, 2015 17:49
Standard CRUD methods in Controllers / Services / Repositories for Zend Framework 2
<?php
namespace Foo\Controller;
use Foo\Repository\BarInterface as Repository;
use Foo\Form\BarInterface as Form;
use Foo\Service\BarInterface as Service;
use Foo\Options\ModuleOptions;
use Zend\Mvc\Controller\AbstractActionController;
@juriansluiman
juriansluiman / DI.php
Created March 31, 2013 13:25
Dependency injection versus Service Locator pattern
<?php
// Dependency
class Dependency
{
}
// Service
@juriansluiman
juriansluiman / RFC.md
Created August 19, 2012 12:28
New Navigation module for Zend Framework 2

Proposal for a new navigation component

This document is a start to get a new navigation component of the ground. The current Zend\Navigation has shown to be a powerful component for navigation purposes. On the other hand, the code is since it's introduction in Zend Framework 1.8 not really updated. The complexity is for some features very difficult to comprehend. In ZF2, the overhaul of the view helpers made it even more difficult to customize the behaviour of Zend\Navigation.

The good parts:

  1. A structure of containers and pages to create hierarchal trees
  2. A set of domain layer-like objects (containers and pages) and view helpers to render them into html
  3. The option to mark pages as "active"
  4. The option to tune visibility of pages
  5. The option to attach an ACL object to the navigation list to show or hide parts based on access permission
@juriansluiman
juriansluiman / Module.php
Created July 11, 2012 13:14
Set a default locale for your application in Zend Framework 2
<?php
namespace Application;
use Locale;
use Zend\EventManager\Event;
use Zend\ModuleManager\Feature;
class Module implements
Feature\BootstrapListenerInterface
{
@juriansluiman
juriansluiman / Requirements.md
Created March 13, 2012 10:00
Requirements for an Assetic module in ZF2

Assetic module in ZF2

This file describes my opinion of the integration of a public asset management tool within Zend Framework 2. It doesn't necessarily involve Assetic, but because Assetic is the most advanced and most used tool, I will focus on that. There is already an alternative module for Assetic integration, but the configuration of this module strikes 100% against my opinion of usage patterns. Therefore I write this document, to open up the discussion about improvements of zf2-assetic-module or write an alternative module.

Main usage pattern

The people using asset management tools are probably the frontend developers, as they write the html code in views, layouts etc. Currently they use helpers like headLink, headScript and inlineScript to control the assets. Starting point for this text is their workflow should not change as much as possible.

This means, an Assetic module should override the view helpers plugin broker, providing al