Skip to content

Instantly share code, notes, and snippets.

set_exception_handler($app->wrap(function (\Exception $exception, \Whoops\Run $run) {
$run->handleException($exception);
}));
@hannesvdvreken
hannesvdvreken / travis.yml
Last active August 29, 2015 14:13
travis.yml
- before_script:
- travis_retry composer self-update
- travis_retry composer install --ignore-platform-reqs --no-interaction --prefer-source
@hannesvdvreken
hannesvdvreken / name-route-segments.php
Created January 29, 2015 13:24
Named route segments
<?php
use League\Container\Container;
use League\Route\RouteCollection;
use League\Route\Strategy\MethodArgumentStrategy;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
require 'vendor/autoload.php';
@hannesvdvreken
hannesvdvreken / htaccess
Last active August 29, 2015 14:15
htaccess
RewriteCond %{REQUEST_URI} =~ "/public.(pictures.(products|banners)|images.default\-).*/"
RewriteRule ^ - [E=cache_control:1,L]
Header unset Last-Modified env=cache_control
Header unset ETag env=cache_control
FileETag None env=cache_control
Header set cache-control "public, max-age=26426400" env=cache_control
ExpiresDefault "access plus 10 months" env=cache_control
function helper(arg1, callback) {
// do something…
callback(data);
}
obj = {
name: 'John Doe',
bar: function() {
helper('foo', function(data) {
console.log(this);
function helper(arg1, callback, context) {
// do something…
callback.call(context, data);
}
obj = {
name: 'John Doe',
bar: function() {
helper('foo', function(data) {
console.log(this);
@hannesvdvreken
hannesvdvreken / index.php
Created March 3, 2015 19:00
league/route with methodargumentstrategy and registered callables
<?php
use League\Container\Container;
use League\Route\RouteCollection;
use League\Route\Strategy\MethodArgumentStrategy;
use Symfony\Component\HttpFoundation\Request;
require 'vendor/autoload.php';
$container = new Container();
@hannesvdvreken
hannesvdvreken / index.php
Last active August 29, 2015 14:16
proton script to test booboo integration
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
require 'vendor/autoload.php';
$app = new Proton\Application();
$app->get('/user/{username}', function (Request $request, Response $response, $args) {
@hannesvdvreken
hannesvdvreken / phpunit
Created March 3, 2015 20:51
phpunit output for alexbilbie/proton
vagrant@ubuntu:~/code/Proton$ vendor/bin/phpunit
PHPUnit 4.5.0 by Sebastian Bergmann and contributors.
Configuration read from /home/vagrant/code/Proton/phpunit.xml
Deprecated configuration setting "strict" used
...........
Time: 2.46 seconds, Memory: 7.25Mb
@hannesvdvreken
hannesvdvreken / results.md
Last active August 29, 2015 14:17
Reflection tests accross php

These are the results of my experiments using league/container to create 100k objects and calling 100k callables. When using no reflection, the container is first made aware of all the object/functions and their dependencies.

PHP Version Time creating objects (in ms) Time to call callables (in ms)
5.3.29 (no reflection) 2057 2957
5.3.29 (with reflection) 2297 3387
5.4.38 (no reflection) 1315 1906
5.4.38 (with reflection) 1396 2252
5.5.22 (no reflection) 1263 1825