Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend InputFilter requires intl PHP extension?

I am setting up some filters and validators for my form, but when I submit it, this error appears: "Zend\I18n\Filter component requires the intl PHP extension". Is this because of the Alnum and Alpha validators ?

Code:

     public function getInputFilter() {
        if (!$this->inputFilter) {
            $inputFilter = new InputFilter();

            $inputFilter->add(array(
                'name' => 'email',
                'required' => true,
                "filters" => array(
                    array('name' => 'StringTrim'),
                    array('name' => 'StripTags')),
                'validators' => array(
                    array(
                        'name' => 'Regex',
                        'options' => array(
                            'pattern' => '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/',
                            'messages' => array(
                                Regex::NOT_MATCH => 'Е-майл адреса е невалиден.',
                            ),
                        ),
                        'break_chain_on_failure' => true
                    ),
                    array(
                        'name' => 'EmailAddress',
                        'options' => array(
                            'messages' => array(
                                EmailAddress::INVALID_FORMAT => "Е-майл адреса е невалиден.",
                                EmailAddress::INVALID => "",
                                EmailAddress::INVALID_LOCAL_PART => "",
                                EmailAddress::INVALID_HOSTNAME => "",
                                EmailAddress::INVALID_SEGMENT => "",
                                EmailAddress::DOT_ATOM => "",
                                EmailAddress::INVALID_MX_RECORD => "",
                            ),
                        ),
                    ),
                ),
            ));

            $inputFilter->add((array(
                'name' => 'name',
                'required' => true,
                "filters" => array(
                    array('name' => 'StringTrim'),
                    array('name' => 'StripTags')),
                'validators' => array(
                    array(
                        'name' => 'Alpha',
                    ),
                ),
            )));

            $inputFilter->add((array(
                'name' => 'password',
                'required' => true,
                "filters" => array(
                    array('name' => 'StringTrim'),
                    array('name' => 'StripTags')),
                'validators' => array(
                    array(
                        'name' => 'Alnum',
                    ),
                    array(
                        'name' => 'StringLength',
                        'options' => array(
                            'min' => 6,
                            'max' => 12,
                            'messages' => array(
                                StringLength::INVALID => "Паролата трябва да е от 6 до 12 символа",
                            ),
                        ),
                    ),
                ),
            )));
          }
like image 743
Milen Pivchev Avatar asked May 14 '15 17:05

Milen Pivchev


3 Answers

Fixed it by going to php.ini and uncommenting extension=php_intl.dll

like image 65
Milen Pivchev Avatar answered Nov 02 '22 01:11

Milen Pivchev


On Ubuntu 16.04, with php 5.6, try:

sudo apt-get install php5.6-intl

and then

sudo service apache2 restart
like image 24
Rômulo Z. C. Cunha Avatar answered Nov 01 '22 23:11

Rômulo Z. C. Cunha


On Ubuntu 18.04, with PHP 7.2, try:

sudo apt-get install php7.2-intl
sudo service apache2 restart

If don't works enable extension=php_intl.dll in:

vim /etc/php/7.2/apache2/php.ini
sudo service apache2 restart
like image 26
JorgeM Avatar answered Nov 01 '22 23:11

JorgeM