Phalcon7 发布 Dao7-1.3.0,增强了验证组件功能

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

View original post here – 

Phalcon7 发布 Dao7-1.3.0,增强了验证组件功能