Error with CUrlManager

I’m trying to move a Yii application from a development machine to Amazon EC2 instance. I’m getting an exception on the Amazon server related to CUrlManager which is:

The URL pattern "<controller:\w+>/<id:\d+>" for route "<controller>/view" is not a valid regular expression.

The settings in my config are:


            

                'urlManager' => array(

                'urlFormat' => 'path',

                'showScriptName' => false,

                'rules' => array(

                    '<controller:\w+>/<id:\d+>' => '<controller>/view',

                    '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',

                    '<controller:\w+>/<action:\w+>' => '<controller>/<action>',

                ),

            ),



This is working fine on my dev machine. The only noticable differences is that I am running PHP 5.3.10 and the EC2 instance is on 5.3.14.

Any thoughts?

Shawn

Did you work this out? got the same problem. read here that it can be solved by adding FollowSymLinks to htaccess, but didn’t work for me:




Options +FollowSymLinks



After a bit of trial and error, i did figure out one thing, that:




Options +FollowSymLinks



has nothing to do with this problem.

Removing the ‘rules’ array from the ‘urlManager’ component removes this error, while keeping the ‘path’ format working, so my urlManager looks like this right now:




'urlManager' => array(

                'urlFormat' => 'path',

/*

                'showScriptName' => false,

                'rules' => array(

                    '<controller:\w+>/<id:\d+>' => '<controller>/view',

                    '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',

                    '<controller:\w+>/<action:\w+>' => '<controller>/<action>',

                ),

*/

            ),



So now the question is what to do when we want url rules?

What distro are you running?

Currently running Yii on PHP 5.3.8 and 5.4.4 with no probs.

I’d run up another instance with maybe different OS, or certainly a different image.

Outrage, thank you for the reply. i’m just running the "Amazon Linux AMI 2012.03 " . php version is 5.3.15 , my local machine has 5.3.10 and it works fine locally. I’ll try with a different distro and see how it goes.

This error is thrown in line 700 in CUrlManager.php by the CUrlRule class’s ‘__construct()’ method :




if(YII_DEBUG && @preg_match($this->pattern,'test')===false)

             throw new CException(Yii::t('yii','The URL pattern "{pattern}" for route "{route}" is not a valid regular expression. Also this pattern is {thispatt}',

                 array('{route}'=>$route,'{pattern}'=>$pattern,'{thispatt}'=>$this->pattern)));

// i added $this->pattern to the message to know the pattern that errors



After the above modification i get the error message as:

The URL pattern "<controller:\w+>/<id:\d+>" for route "<controller>/view" is not a valid regular expression. Also this pattern is /^(?P<controller>\w+)\/(?P<id>\d+)\/$/u

Any hints? (Obviously something to do with the preg_match, but what?)

Funnily enough, a restart solved this problem! I hadn’t restarted my ami since i started it, i had also applied quite a few updates since then. So i guess some update required a restart, which was effecting this. Wish i knew what it was though.

Just got this error again, when trying to use nginx + php-fpm with php-5.4.6.

This time i figured it out.

So what i did:

@ in php suppresses error messages, so to find out the real error in


@preg_match($this->pattern,'test')===false

i removed @ and checked again, which gave me this error:

Compilation failed: this version of PCRE is not compiled with PCRE_UTF8 support at at offset 0

I had installed php with external PCRE library using the –with-pcre-regex=DIR configure option, and

i had installed pcre 8.31 without any configure options, and i guess by default pcre doesn’t install with utf support.

Therefore i re-installed pcre 8.31 with configure option : –enable-utf , restarted php-fpm, nginx and voila error gone, app working.

Note: I think if php is installed with the default (bundled) pcre library, then this error shouldn’t occur.

plz < i need help

this is the error:

Property "CWebApplication.CURL" is not defined.

in the config main :

‘CURL’ =>array(

‘class’ => ‘application.extensions.curl.Curl’,

),

in the extensions/curl/Curl.php :

i put the file that has posted to the site .

where is the error plz, i wanna learn it

I have the same issue on my (shared) webserver (php 5.4.16). However only that check fails, I thinking to disable that check on my webserver. Could it hurt?