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 / gist:5036694
Last active December 14, 2015 05:39
Proposal for Improvement of ZF2 RND
/**
* Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback
*
* @param integer $length
* @param bool $strong true if you need a strong random generator (cryptography)
* @return string
* @throws Exception\RuntimeException
*/
public static function getBytes($length, $strong = false)
{
@ezimuel
ezimuel / gist:4996164
Created February 20, 2013 15:02
Strange composer installation for ZFTool
$ ./composer.phar install
Loading composer repositories with package information
Installing dependencies
- Installing zendframework/zend-version (2.1.1)
Loading from cache
- Installing zendframework/zendframework (2.1.1)
Loading from cache
zendframework/zendframework suggests installing doctrine/common (Doctrine\Common >=2.1 for annotation features)
@ezimuel
ezimuel / gist:4707734
Created February 4, 2013 16:15
Strange error, PHPUnit is 3.7.13 but the error says PHPUnit 3.5.14
enrico@enrico-desktop:~/Lavoro/Git/zf2/tests$ phpunit Zend\Mvc
PHPUnit 3.7.13 by Sebastian Bergmann.
Cannot open file "ZendMvc.php".
enrico@enrico-desktop:~/Lavoro/Git/zf2/tests$ phpunit ZendTest/Mvc
PHPUNIT: 3.7.13
PHPUnit 3.7.13 by Sebastian Bergmann.
Configuration read from /home/enrico/Lavoro/Git/zf2/tests/phpunit.xml.dist
@ezimuel
ezimuel / gist:4566485
Created January 18, 2013 17:40
Usage of Zend\Crypt\Password\Apache
use Zend\Crypt\Password\Apache;
$apache = new Apache();
$apache->setFormat('crypt');
printf ("CRYPT output: %s\n", $apache->create('password'));
$apache->setFormat('sha1');
printf ("SHA1 output: %s\n", $apache->create('password'));
ZF2 Documentation State of Art
------------------------------
Authentication (ok)
Barcode (ok)
Cache (to fix)
Captcha (ok)
Code (to be completed)
Config (ok)
Console (to be completed)
@ezimuel
ezimuel / gist:3129733
Created July 17, 2012 14:30
Script to convert all the ZF2 docs from DocBook to reStructuredText
<?php
require 'RstConvert.php';
$zf2Bin = '/path_to_zf2/bin';
$docbookPath = '/path_to_zf2/documentation/manual/en/module_specs';
foreach (glob("$docbookPath/*.xml") as $filename) {
$fileout = RstConvert::xmlFileNameToRst(basename($filename));
echo "Generating...$fileout\n";
@ezimuel
ezimuel / zend.barcode.objects.rst
Created July 17, 2012 12:13
zend.barcode.objects

Zend\Barcode\Barcode Objects

Barcode objects allow you to generate barcodes independently of the rendering support. After generation, you can retrieve the barcode as an array of drawing instructions that you can provide to a renderer.

Objects have a large number of options. Most of them are common to all objects. These options can be set in three ways:

@ezimuel
ezimuel / gist:2972974
Created June 22, 2012 14:14
Proposal for support ignore annotation with wildcard for Doctrine
namespace MyCompany\Annotations {
/**
* @Annotation
*/
class Foo
{
public $bar;
}
/**
@ezimuel
ezimuel / gist:2955319
Created June 19, 2012 17:06
Idea for a Factory abstract class
interface FactoryInterface {
public static function factory($classname, $options = null);
public static function validate($classname);
public static function getClassMap();
}
abstract class AbstractFactory {
public static function factory($name, $options = null)
{
@ezimuel
ezimuel / password.php
Created June 18, 2012 17:37 — forked from ircmaxell/password.php
Password API Example
<?php
define('PASSWORD_SHA256', '$5$');
define('PASSWORD_SHA512', '$6$');
define('PASSWORD_BCRYPT', '$2y$');
define('PASSWORD_SCRYPT', '$7$'); // made up here
function password_hash($password, $algo = PASSWORD_BCRYPT, array $options = array()) {
$salt = '';