Skip to content

Instantly share code, notes, and snippets.

@sasezaki
sasezaki / japanese_mixed.txt
Created July 20, 2012 08:40
just a note -ZF2 Alnum/Alpha in Filter/Validator (for zf contributors ML)
Hi, all.
Currently, ZF2 Alnum/Alpha is under Zend\I18n's.
About alphabet checking is,(アルファベットをチェックすることについて現在のZF2の実装とともにいくつか問題や議論の余地がある)
There is some issue.
- Alnum/Alpha rely on ext_intl(Locale)
- because ja/ka/ch user often think English's Alphabet is theire Alphabet.
そしてpreg's "/u" で日本語などにマッチするのを割けなければいけない。
@sasezaki
sasezaki / Module.php
Created July 11, 2012 15:13
Zend Framework 2 GyaruMoji Module for demo
<?php
namespace GyaruMoji;
class Module
{
public function getConfig()
{
return array(
'service_manager' => array(
'factories' => array(
@sasezaki
sasezaki / zf2_alpha_locale.patch
Created July 6, 2012 14:11
ZF2 Alpha/Alnum 's depend on Locale refactor
diff --git library/Zend/I18n/Filter/Alnum.php library/Zend/I18n/Filter/Alnum.php
index a18e4e6..c42d5c6 100644
--- library/Zend/I18n/Filter/Alnum.php
+++ library/Zend/I18n/Filter/Alnum.php
@@ -38,6 +38,7 @@ class Alnum extends AbstractLocale
protected $options = array(
'locale' => null,
'allow_white_space' => false,
+ 'depend_on_locale' => false,
);
@sasezaki
sasezaki / locale.php
Created July 6, 2012 10:18
locale "**_**" detector for using in ZF2 module/Application/config/module.config.php
<?php
// // 'locale' => 'en_US',
// 'locale' => include __DIR__.'/locale.php',
return call_user_func(function () {
// borrowed from ZF1 Zend_Locale::getBrowser
$localer = function () {
$httplanguages = getenv('HTTP_ACCEPT_LANGUAGE');
if (empty($httplanguages) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
$httplanguages = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
<?php
require_once __DIR__.'/library/Zend/Loader/StandardAutoloader.php';
use Zend\Loader\StandardAutoloader;
use Zend\Filter\StringTrim;
$autoloader = new StandardAutoloader;
$autoloader->register();
class Before extends StringTrim
@sasezaki
sasezaki / gist:2881304
Created June 6, 2012 11:10
PHP testing header*
<?php
/**
* server
* $php -S localhost:8080 server.php
*/
use Zend\Http\PhpEnvironment\Response;
use Zend\Http\Header\ContentType;
include 'tests/_autoload.php';
@sasezaki
sasezaki / zf2_view_not_merged_yet_list.md
Created June 1, 2012 11:52
zf2 view not merged yet list
@sasezaki
sasezaki / goutte_wrapper.php
Created May 29, 2012 14:29
Goutte Wrapper by Diggin_Http_Charset for CP932
<?php
use Goutte\Client;
use Guzzle\Http\Message\Response as GuzzleResponse;
use Symfony\Component\BrowserKit\Response;
use Diggin\Http\Charset\WrapperFactory;
class GoutteWrapper extends Client
{
protected function createResponse(GuzzleResponse $response)
{
@sasezaki
sasezaki / proposal_component_directory.ja.md
Created May 22, 2012 14:04
PSR-3 PHP Component Standard Structures草案

(※以下の内容は思いつきレベルです)

以下の項目は相互運用のためのコンポーネントリポジトリーの標準的な構成です。

  • pyrusのgenerate-pear2 の構成、composer・PHP Project Wizard などのデフォルト値を参考にします。

Mandatory

  • コンポーネントのソースファイルはプロジェクトのルートディレクトリにsrcディレクトリを作成し、その下にファイル群を格納します。(libやlibrary、VendorNameではありません。)
  • ユニットテスト一式はプロジェクトのルートディレクトリにtestsディレクトリを作成し、その下にファイル群を格納します。またユニットテストに必要なファイル群(bootstrapなど)もこのディレクトリ下に格納します。テストファイルもPSR-0に準拠するのを推奨します
  • そのプロジェクトが依存するほかのVendorコンポーネントについては、ルートディレクトリにvendorディレクトリを作成しその下に配置します。
@sasezaki
sasezaki / a.php
Created May 12, 2012 00:19
just sandbox prototype for async spider
<?php
namespace Miffie;
use Zend\Stdlib\Parameters as StdlibParameters;
class Parameters extends StdlibParameters
{
public function __invoke($response)