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:5091208
Created March 5, 2013 15:45
class_alias experiment
// rename the Zend\Stdlib\ArrayObject in Zend\Stdlib\ArrayObjectPHPFuture
// and copy he Zend\Stdlib\compatibility\ArrayObject in Zend\Stdlib\ArrayObjectPHPLegacy
if (version_compare(PHP_VERSION, '5.3.4', 'lt') {
class_alias('Zend\Stdlib\ArrayObjectPHPLegacy', 'ArrayObject');
} else {
class_alias('Zend\Stdlib\ArrayObjectPHPFuture', 'ArrayObject');
}
$test = new ArrayObject();
@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'));
@ezimuel
ezimuel / pluginmanager.php
Last active November 7, 2015 16:54
Experimental plugin manager compliant with ContainerInterface
<?php
/**
* Experimantal plugin manager complaint with ContainerInterface with options support
* using the optional Interface rule of PHP
*/
use Interop\Container\ContainerInterface;
class PluginManager implements ContainerInterface
{
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;
}
/**