Skip to content

Instantly share code, notes, and snippets.

<?php
use Zend\Db\Adapter\Adapter;
use Zend\Db\Sql\Sql;
use Zend\Db\Sql\Where;
use Zend\Db\Adapter\Profiler\Profiler;
use Zend\Db\Adapter\StatementContainer;
/**
* @see http://blog.kazuhooku.com/2014/07/the-json-sql-injection-vulnerability.html
@sasezaki
sasezaki / sample.php
Last active August 29, 2015 14:03
frolic with zf-fr Hydrator
<?php
use Hydrator\ObjectPropertyHydrator;
use Hydrator\Strategy\DateStrategy;
use Hydrator\Strategy\StrategyInterface;
use Hydrator\Context\ExtractionContext;
use Hydrator\Context\HydrationContext;
use Zend\Uri\UriInterface;
use Zend\Uri\UriFactory;
<?php
// I'm not fun to see your handling data masturbation.
// (I'm not intend DDD, too)
// Don't annoy me with such article. http://www.1x1.jp/blog/2014/06/how-to-scan-array-in-php.html
use Zend\Stdlib\Hydrator;
require_once 'vendor/autoload.php';
$usersData = [
<?php
use Symfony\Component\DomCrawler\Crawler;
require 'vendor/autoload.php';
$html = mb_convert_encoding('<html><head><meta charset="Shift_JIS"></head><body>日本語①②③</body></html>', 'SJIS-win', 'UTF-8');
$crawler = new Crawler;
$crawler->addContent($html);
var_dump($crawler->filterXPath('//body')->text()); // string(9) "日本語"
@sasezaki
sasezaki / Module.php
Created February 17, 2014 15:44
Trap Reserved Username For ZfcUser module
<?php
namespace TrapReservedUsernameForZfcUser;
use Zend\Mvc\MvcEvent;
use Zend\Validator\ValidatorChain;
use Zend\Validator\Callback;
use ZfcUser\Validator\NoRecordExists;
class Module
@sasezaki
sasezaki / paralle_request.php
Created February 12, 2014 15:54
Sample - multi request and output to file with Artax
<?php
use Artax\Request;
$reactor = (new Alert\ReactorFactory)->select();
$client = new Artax\AsyncClient($reactor);
class OutputFileSpecifiedRequest extends Request
{
private $filename;
<?php
class TestClass
{
private $internalScalar;
public function __construct($arg)
{
$this->internalScalar = $arg;
}
@sasezaki
sasezaki / phpdbg.md
Last active July 30, 2023 13:51
phpdbg - 新しいオールドスクールデバッガ

phpdbg - 新しいオールドスクールデバッガ

phpdbgcom.png

PHPのコア周辺での活動が顕著な krakjoe -Joe Watkins氏に より新しいプロジェクトが発足した。PHP用デバッガ phpdbg だ。ここ数日karkjoe・felipensp両氏により活発に開発が行われている。

これは、C言語開発者にはお馴染みのGDBに似たデバッグ環境をPHP向けに提供する。

@sasezaki
sasezaki / index.php
Last active December 28, 2015 23:59
to run under phpdbg & react, react-zf
<?php
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
return false;
@sasezaki
sasezaki / myphpdbg.init
Created November 16, 2013 12:59
function completion phpdbg.init
<:
readline_completion_function(function(){return array_merge(get_defined_functions()['internal'],array_keys(get_defined_constants()));});
:>