- SQL実行の入出力の連想配列をarray shapeでタイプする例です
$age
で指定されたユーザーリストがusers_by_age.sql
のSQL実行され結果(array<array{id: string, name: string}>
が返ります。- SQLへのリクエストと結果が補完できるようになります。(echo $user['name']
の
name`は入力補完されます。) - 連想配列の使い方に間違いないかpsalmやphpstanで静的解析出来ます。
- 入力補完にはdeep-assoc-completionが必要です。
- array shapek記法については https://phpstan.org/writing-php-code/phpdoc-types#array-shapes を参照してください。
- Ray.QueryModuleはSQLをSQL実行オブジェクトに変換します。
@Query
はメソッドインターセプトしてidで指定したSQLを実行してメソッドの結果として返します。 - メソッドは入出力のシグネチャーだけ利用し中身はなしでもOKです。SQL実行の結果を更新したい場合にはSQL実行結果がセットされた
$body
を変更しreturn $this;
します。(BEAR.Sundayの場合) - psalmを使っている場合には
@psalm-suppress
でエラー抑制するか(メソッド内に記述がないため)、ダミーのデータを返却する必要があります。 - Ray.Di + Ray.QueryModuleをインストールすればBEAR.Sundayでなくても使えます。
View file0.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;zend_extension = "/path/to/my/xdebug.so" |
View How I explained REST to my wife...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Wife: Who is Roy Fielding? | |
Ryan: Some guy. He's smart. | |
Wife: Oh. What did he do? | |
Ryan: He helped write the first web servers and then did a ton of research explaining why the web works the way it does. Oh yea, his name is on the specification for the protocol that is used to get pages from servers to your browser. | |
Wife: How does it work? |
View bearsunday-query-example.md
View example_binding_auth_intercepter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function configure() | |
{ | |
$this->bindInterceptor( | |
$this->matcher->logicalAnd( | |
$this->matcher->logicalAnd( | |
$this->matcher->logicalNot( | |
$this->matcher->annotatedWith(PublicDomain::class) | |
), |
View BEAR.Sunday.design.md
BEAR.Sunday デザインメモ
wiki https://github.com/koriym/BEAR.Sunday/wiki に移動しました
View SqlTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Aura\Sql\ExtendedPdoInterface; | |
use BEAR\Package\AppInjector; | |
use Koriym\QueryLocator\QueryLocatorInterface; | |
use PHPUnit\Framework\TestCase; | |
use Ray\Di\InjectorInterface; | |
use Ray\Query\RowInterface; | |
/** |
View v8js_install_error.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AkiBook2016:v8js akihito$ ./configure --with-php-config=/usr/local/php5/bin/php-config --with-v8js=/usr/local/opt/v8\@3.15 | |
checking for grep that handles long lines and -e... /usr/bin/grep | |
checking for egrep... /usr/bin/grep -E | |
checking for a sed that does not truncate output... /usr/bin/sed | |
checking for cc... cc | |
checking whether the C compiler works... yes | |
checking for C compiler default output file name... a.out | |
checking for suffix of executables... | |
checking whether we are cross compiling... no | |
checking for suffix of object files... o |
View osxphpdev.md
OSX PHP環境構築メモ
PHP 7.x
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.x
View aop.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Guice / Ray.Di way | |
$injector = new Injecotr($loggerBindings); // "Matcher" search the method to attache interceptor. Changed on the context. | |
$foo = $injector->getInstance(FooInterface::class); // logger interceptor was attached with $foo. | |
// $foo is not "Foo", somehing generagted new name but implemented FooInterface. This is OK for me. | |
// AOP is cooperating OOP design. | |
// $loggerBindingsの中でマッチャーが実行コンテキストによって、インターセプターとメソッドを束縛する。 |