Skip to content

Instantly share code, notes, and snippets.

View ezimuel's full-sized avatar
🇮🇹
Working remotely, since 2008

Enrico Zimuel ezimuel

🇮🇹
Working remotely, since 2008
View GitHub Profile
@ezimuel
ezimuel / .htaccess
Created March 14, 2017 16:15
Create a PHP deploy package .zpk for Zend Server
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
@ezimuel
ezimuel / test_bench.php
Created March 8, 2017 12:15
MD5 vs. preg_replace_callback for PDOStament::bindParam() usage in zend-db
<?php
// Testing md5 vs. preg_replace_callback()
$execPreg = 0;
$execMd5 = 0;
for ($i=0; $i<100000; $i++) {
$name = randomName(10);
$start = microtime(true);
$result = preg_replace_callback(
@ezimuel
ezimuel / global.php
Created December 9, 2014 12:33
Example: OAuth2 configuration for Apigility
// config/autoload/global.php
// ...
'router' => array(
'routes' => array(
'oauth' => array(
'options' => array(
'route' => '/oauth',
),
),
@ezimuel
ezimuel / gist:f34b22f347d4a0c985a1
Created June 25, 2015 07:38
New stratigility example, updated with PR zendframework/zend-stratigility#12
<?php
use Zend\Stratigility\MiddlewarePipe;
use Zend\Diactoros\Server;
require 'vendor/autoload.php';
$app = new MiddlewarePipe();
$server = Server::createServer($app, $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
// Injected for all the URL
@ezimuel
ezimuel / encrypt_file.php
Created September 27, 2013 13:54
Example to encrypt a file (even big) using Zend\Filter\Encrypt of ZF2 with a simple block schema (low memory consumption).
<?php
// include the ZF2 library
use Zend\Filter\Encrypt;
if (!isset($argv[1]) or !isset($argv[2])) {
die("Usage: " . basename(__FILE__) . " <file_to_encrypt> <encryption_key>\n");
}
if (!file_exists($argv[1])) {
die("The file {$argv[1]} specified doesn't exist\n");
@ezimuel
ezimuel / gist:6138279
Created August 2, 2013 08:16
ZF2 blog simple schema
CREATE TABLE post (
id int(11) NOT NULL auto_increment,
title varchar(100) NOT NULL,
content TEXT NOT NULL,
user_id int(11),
category_id int(11),
publish_date DATETIME,
PRIMARY KEY (id)
);
@ezimuel
ezimuel / gist:6071979
Created July 24, 2013 16:05
API example calls
RPC: GET /getalbum
Request
{ "id" : 1 }
OK Response (200):
{
"id" : 1,
"artist" : {
"name" : "Metallica",
"history" : "Simply the best heavy metal band ever!",
"genre" : "Heavy metal, Hard rock, Speed metal, Thrash metal"
/GET /user
OK Response (200):
{
"user" : {
"name" : "Foo",
"email" : "foo@bar.com"
}
}
@ezimuel
ezimuel / gist:5301941
Created April 3, 2013 14:58
Db2 connect using ODBC parameters
<?php
$database = '';
$user = '';
$password = '';
$hostname = '';
$port = 446;
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;".
"HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";
@ezimuel
ezimuel / gist:5135662
Created March 11, 2013 16:55
DB2 configuration file connect using ZF2 and ODBC using config/autoload/local.php
<?php
$database = '';
$hostname = '';
$port = '';
$user = '';
$password = '';
return array(
'db' => array(