base on https://github.com/laruence/php-yaf