Yii Framework Forum: Error with CUrlManager - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Error with CUrlManager The URL pattern "<controller:\w+>/<id:\d+>" fo Rate Topic: ***** 1 Votes

#1 User is offline   Shawn Morgan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 27-April 12

Posted 15 July 2012 - 05:06 PM

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
0

#2 User is offline   bool.dev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 07-September 11

Posted 16 August 2012 - 04:27 PM

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

0

#3 User is offline   bool.dev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 07-September 11

Posted 16 August 2012 - 05:10 PM

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?
0

#4 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 16 August 2012 - 07:21 PM

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.
0

#5 User is offline   bool.dev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 07-September 11

Posted 17 August 2012 - 01:43 AM

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?)
0

#6 User is offline   bool.dev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 07-September 11

Posted 17 August 2012 - 07:58 AM

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.
0

#7 User is offline   bool.dev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 07-September 11

Posted 04 September 2012 - 03:01 AM

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.
0

#8 User is offline   khalid 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 24-June 13

Posted 24 June 2013 - 04:05 AM

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
0

#9 User is offline   gerrit_ 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 06-February 12

Posted 30 December 2013 - 02:26 PM

View Postbool.dev, on 17 August 2012 - 01:43 AM, said:

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?)



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?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users