$v = new sfValidatorEmail(); try { $v->clean(trim($email)); } catch (sfValidatorError $e) { // not valid }
Wednesday, July 11, 2012
Using Validators in Actions in Symfony
Check whether an email address is valid or not with sfValidatorEmail:
Tuesday, July 10, 2012
phpMyAdmin: No activity within 1440 seconds
At the end of /etc/phpmyadmin/config.inc.php:
$cfg['LoginCookieValidity'] = 60 * 60 * 8;
/etc/php5/apache2/php.ini:
$cfg['LoginCookieValidity'] = 60 * 60 * 8;
/etc/php5/apache2/php.ini:
session.gc_maxlifetime = 30000
Thursday, July 5, 2012
Log to Custom Log File in Symfony
$logger = new sfFileLogger($this->getContext()->getEventDispatcher(), array('file' => sfConfig::get('sf_log_dir').'/CronSendOrderEmail.log'));
Wednesday, July 4, 2012
Symfony Email Validator Accepts Accents
Use this validator to ignore accents:
- Put this after sfCoreAutoload::register(); in config/ProjectConfiguration.class.php:
require_once dirname(__FILE__).'/../lib/validator/sfValidatorEmail.class.php'; - Create lib/validator/sfValidatorEmail.class.php with this content:
class sfValidatorEmail extends sfValidatorRegex { // const REGEX_EMAIL = '/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'; // const REGEX_EMAIL = '/^([^@öüóőúéáűíÖÜÓŐÚÉÁŰÍ\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'; const REGEX_EMAIL = '/^([A-Z0-9._%+-]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'; /** * @see sfValidatorRegex */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $this->setOption('pattern', self::REGEX_EMAIL); } }
Subscribe to:
Posts (Atom)