Yii Framework Forum: Yiiboilerplate: Invalid Alias - Yii Framework Forum

Jump to content

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

Yiiboilerplate: Invalid Alias but Yii::getPathOfAlias returns true ?! Rate Topic: -----

#1 User is offline   tomvdp 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 06-November 12

Posted 06 November 2012 - 10:17 AM

Hi people,

Making my first steps with Yii. :)

I am trying to setup an application that will make use of YiiBoilerplate. (*)

So far so good: after the install (and moving directories, simplifying the environment switching code, etcetera) I do get the expected output from "index.php" of the frontend.

Next step I am trying: get the Bootstrap extension loaded. I am following the instructions from the link above below.(*) But I am afraid these are not complete.

Here is what I added in main.php:
Yii::setPathOfAlias('ext', $root . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'extensions');

...

		'preload' => array('log', 'bootstrap'),
...
     	'components' => array(
			...,
            'bootstrap' => array(
                'class' => 'ext.bootstrap.components.Bootstrap',
                'responsiveCss' => false,
            ),


The site no longer works, but returns an error:
Alias "ext.bootstrap.components.Bootstrap" is invalid. Make sure it points to an existing PHP file and the file is readable.
(Error 500) 


Yet, the following prints "1", so the file does exist and is readable, no ?

echo "<pre>" . is_file(Yii::getPathOfAlias('ext.bootstrap.components.Bootstrap') . ".php") . "</pre>";


Any ideas where to look ?
Even better: is anybody willing to share a minimalistic YiiBoilerplate application that actually loads the Bootstrap component and displays some widgets ? It would definitely help me climb the learning curve! ;)

Cheers & thanks,
Tom
(*) I am not allowed to post links yet, so here it is spelled out: yii-booster.clevertech.biz/getting-started.html
0

#2 User is offline   tomvdp 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 06-November 12

Posted 06 November 2012 - 03:00 PM

I think I am getting closer to the problem.

In main.php I have this:

...
Yii::setPathOfAlias('root', $root);
Yii::setPathOfAlias('ext', $root . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'extensions');

return
array(
'basePath' => $root . '/frontend',
...



If I run the test for the correct interpretation of the classname ext.bootstrap.components.Bootstrap:

$yii=dirname(__FILE__).'/../../../yii/yii-1-1-12/framework/yii.php';
require_once($yii);
$config=dirname(__FILE__).'/../config/main.php';
require_once($config);
echo "<pre>" . Yii::getPathOfAlias('ext.bootstrap.components.Bootstrap') . "</pre>";

then this returns (correctly)

/var/www/YiiBoilerplate-dev/common/extensions/bootstrap/components/Bootstrap


When I try to instantiate a CWebApplication it seems to ignore the previous calls to Yii::setPathOfAlias. I amended the raised exception to include the missing path instead of only reporting the problematic alias name (line 382 in YiiBase.php). The error reads:

Alias "ext.bootstrap.components.Bootstrap" is invalid. Make sure it points to an existing PHP file and the file is readable. This is the presumed path: "/var/www/YiiBoilerplate-dev/frontend/extensions/bootstrap/components/Bootstrap.php"


It seems that basePath takes precedence over earlier setPathOfAlias calls ? Is this expected behaviour ? If so, how to set the "ext" alias to some location out of basePath ?

Thank you,
Tom
0

#3 User is offline   tomvdp 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 06-November 12

Posted 07 November 2012 - 05:43 AM

Ok, found it! :)

The creation of a CWebApplication object resets some aliases to default loations starting from the basePath, one of them being "ext".

I had to change
Yii::setPathOfAlias('ext', $root . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'extensions');

to
Yii::setPathOfAlias('extcommon', $root . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'extensions');

and then in the config settings:
'bootstrap' => array('class' => 'extcommon.bootstrap.components.Bootstrap')


Thank you for listening ;)
0

#4 User is offline   sefburhan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 136
  • Joined: 08-February 12
  • Location:islamabad

Posted 25 March 2013 - 12:34 AM

i had the same problem, But i realize that , i have the same copy (common) in root (outside of project) folder (like in www), when i delete i got the solution !!!
0

#5 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 25 March 2013 - 07:42 AM

/* moved from Installation & Setup */
"Less noise - more signal"
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