发布于 2017-05-27 00:01:30 | 189 次阅读 | 评论: 0 | 来源: 网友投递
Phalcon开源PHP框架
PhalconPHP 是一个使用 C 扩展开发的 PHP Web 框架,提供高性能和低资源占用。
Phalcon7 发布 Dao7-1.3.0,增强了验证组件功能,支持对单个字段设置多个验证器,验证器可以使用字符串(类名或者在DI中注入的名称):
$validation = new PhalconValidation(); $validation->add('last_name', ['PresenceOf', 'StringLength' => ['min' => 10]]); $messages = $validation->validate($_POST); ``` 增加了命令行选项类: ```php $ops = new PhalconCliOptions('Phalcon CLI'); $ops->add([ 'type' => PhalconCliOptions::TYPE_INT, 'name' => 'min' ]); $ops->add([ 'type' => PhalconCliOptions::TYPE_INT, 'name' => 'max', 'shortName' => 'm', 'required' => false, 'desc' => "int", 'help' => "must be int", 'defaultValue' => 1 ]); $ops->add(PhalconCliOptions::TYPE_STRING, 'name', 'n', true, "name", "must be string", "Phalcon"); $values = $ops->parse(); if (!$values) { return; }
增加了通用的Profiler,通过设置事件监听器,可以方便记录消耗时间和内存:
$profiler = new PhalconProfiler; $name = 'AppHanler'; $profiler->startProfile($name, $data); $profiler->startProfile('DbQuery', $data); $profiler->stopProfile(); $profiler->stopProfile(); echo $profiler->getTotalElapsedSeconds() * 1000; echo $profiler->getTotalUsageMemory(); foreach ($profiler->getAllProfiles() as $profile) { echo $profile->getName() . PHP_EOL; echo $profile->getTotalElapsedSeconds() * 1000; echo $profile->getTotalUsageMemory(); }
更多的改动说明可以查看 https://github.com/dreamsxin/cphalcon7/releases