Alias "bootstrap.components.Bootstrap" is invalid - yii

I've added bootstrap Extension To my yii webapp and installed as described in setup Guide. All Folders in Extension Folder are rwrwrw but i get the error written above. What could be the reason? I've already dumped the path from yii::Import and that path was correct.
Thanks!
Edit With Code
This is my config:
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
//Yii::setPathOfAlias('bootstrap', '/Users/gerritlober/Sites/yii/webapp/protected/extensions/bootstrap');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Carpool',
'theme' => 'bootstrap',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'xxx',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
'generatorPaths'=>array(
'bootstrap.gii',
),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to enable URLs in path-format
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
/*
'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),*/
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=carpool_dev',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'enableProfiling' => true,
),
'authManager'=>array(
'class'=>'CDbAuthManager',
'connectionID'=>'db',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
array(
'class'=>'CWebLogRoute',
'categories' => 'system.db.*,GLWeb.*,application.*'
),
),
),
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster#example.com',
),
);
My bootstrap extension is in ./protected/extensions/bootstrap

I was having the same problem. I granted full(777) permission to the folder.
Try it.

Update Component By :
ext.bootstrap.src.components.Bootstrap',
EG: If you are extracted under extension then follow above command:
Syntax: ext.path_to.Bootstrap

You have two options. One, in your config/main.php file, or equivalent, add the following line:
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/yii-bootstrap');
Where you need to replace yii-bootstrap with whatever your bootstrap folder is actually called.
Or two, you can simply refer to the that bootstrap folder correctly in the first place. If your bootstrap installation is installed in /extensions/yii-bootstrap as mine is, then use this alias to load components:
ext.yii-bootstrap.components.Bootstrap
In short, your problem is likely you aren't defining the path to your installation correctly. Use one of the two above solutions so remedy that problem.

Related

yii-user extension gives an invalid alias error

i'm new to yii and downloaded this extension
https://github.com/mishamx/yii-user
i've uploaded all the necessary files into the protected/ folder
but i keep getting this error. what am i missing?
Alias "user.UserModule" is invalid. Make sure it points to an existing PHP file and the file is readable.
/Applications/XAMPP/xamppfiles/htdocs/dev2/framework/YiiBase.php(322)
i edited my config/main/php which now looks like this
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// Define a path alias for the Bootstrap extension as it's used internally.
// In this example we assume that you unzipped the extension under protected/extensions.
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'my site',
'theme'=>'bootstrap', // requires you to copy the theme under your themes directory
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
'application.modules.user.models.*',
'application.modules.user.components.*',
),
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class' => 'system.gii.GiiModule',
'password' => 'gii', //Enter Your Password Here
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters' => array('127.0.0.1','::1'),
'generatorPaths' => array('bootstrap.gii'),
),
'user'=>array(
# encrypting method (php hash function)
'hash' => 'md5',
# send activation email
'sendActivationMail' => true,
# allow access for non-activated users
'loginNotActiv' => false,
# activate user on registration (only sendActivationMail = false)
'activeAfterRegister' => false,
# automatically login from registration
'autoLogin' => true,
# registration path
'registrationUrl' => array('/user/registration'),
# recovery password path
'recoveryUrl' => array('/user/recovery'),
# login form path
'loginUrl' => array('/user/login'),
# page after login
'returnUrl' => array('/user/profile'),
# page after logout
'returnLogoutUrl' => array('/user/login'),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
'class' => 'WebUser',
),
'bootstrap' => array(
'class' => 'bootstrap.components.Bootstrap',
),
// uncomment the following to enable URLs in path-format
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
/*'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),*/
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=DBNAME',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'admin#******.com',
),
);
?>
and this is my config/console.php file
<?php
// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
// preloading 'log' component
'preload'=>array('log'),
// application components
'components'=>array(
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=*****',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
),
),
),
'modules'=>array(
'user'=>array(
# encrypting method (php hash function)
'hash' => 'md5',
# send activation email
'sendActivationMail' => true,
# allow access for non-activated users
'loginNotActiv' => false,
# activate user on registration (only sendActivationMail = false)
'activeAfterRegister' => false,
# automatically login from registration
'autoLogin' => true,
# registration path
'registrationUrl' => array('/user/registration'),
# recovery password path
'recoveryUrl' => array('/user/recovery'),
# login form path
'loginUrl' => array('/user/login'),
# page after login
'returnUrl' => array('/user/profile'),
# page after logout
'returnLogoutUrl' => array('/user/login'),
),
)
);
if you are working with a linux enviroment, it's possible that your files do not have enough previlage to run files under users module directory.
try this to know if the problem is from here
chmod -R 777 /protected/modules/user/
not sure which version of yii-user you are using, but first download the latest version from here and follow the setting changes from that page too.
make sure you unzip all the files into protected/modules/user (NOTE: the modules and user folder doesn't exist so you will have to make one)
once done, insert items into zii.widgets.CMenu array (protected/views/layouts/main.php)
array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->profileUrl, 'label'=>Yii::app()->getModule('user')->t("Profile"), 'visible'=>!Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->logoutUrl, 'label'=>Yii::app()->getModule('user')->t("Logout").' ('.Yii::app()->user->name.')', 'visible'=>!Yii::app()->user->isGuest),
I don't know why, but I had also same issue after I loaded last version of yiibooster 4.0.1 version my issue solved by changing all "bootstrap" aliases with "booster" in all part of my application.
As example
'bootstrap' => array(
'class' => 'ext.yiibooster.components.Bootstrap',
),
with
'booster' => [
'class' => 'ext.yiibooster.components.Booster',
],
Also don't forget to use filter methods in all actions:
public function filters(){
return [
'accessControl',
'postOnly + delete',
['booster.filters.BoosterFilter - delete'],
];
}

Yii set language to directory protected/messages in components from config but not work

I have Yii project and change my language in config/main.php to fa_ir, and set components basePath = protected/messages but don't changed basePath, yet is selected fa_ir from framework directory !!!
my project main.php code :
return.array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'New web site',
'defaultController'=>'site',
//'timezone'=>'Asia/Tehran',
'language'=>'fa_ir',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
'application.extensions.*',
),
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'123',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
'messages'=>array(
'basePath'=>Yiibase::getPathOfAlias('application.messages'),
),
// uncomment the following to enable URLs in path-format
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
and ...
So directory files is : protect/message/fa_ir/yii.php and zii.php
I am very grateful from respondents.
Try it with a single language:
'language'=>'fa',
Or:
'language'=>'ir',
And use the same for your directory.

YII - define extracted bootstrap in config file

i'm new in Yii. and i'm using this LINK.
i'm extracted bootstrap on /blog/protected/extensions directory and define array into config/main.php like this:
//BOOT STRAP
'clientScript' => array(
'scriptMap' => array(
'jquery.js'=>false,
'jquery.min.js'=>false,
'core.css'=>false,
'styles.css'=>false,
'pager.css'=>false,
'default.css'=>false,
),
'packages'=>array(
'jquery'=>array(
'baseUrl'=>'bootstrap/',
'js'=>array('js/jquery.js'=>true /* SET AS DEFAULT*/ ),
),
'bootstrap'=>array(
'baseUrl'=>'bootstrap/',
'js'=>array('js/bootstrap.min.js',
'js/bootstrap-transition.js',
'js/bootstrap-alert.js',
'js/bootstrap-modal.js',
'js/bootstrap-dropdown.js',
'js/bootstrap-tab.js',
'js/bootstrap-tooltip.js',
'js/bootstrap-popover.js',
'js/bootstrap-button.js',
'js/bootstrap-collapse.js',
'js/bootstrap-carousel.js',
'js/bootstrap-typeahead.js',
'js/bootstrap-affix.js',
'js/holder.js',
'js/prettify.js',
'js/application.js',
),
'css'=>array(
'css/bootstrap.min.css',
'css/custom.css',
'css/bootstrap-responsive.min.css',
),
'depends'=>array('jquery'),
),
),
),
//BOOT STRAP
how to change 'baseUrl'=>'bootstrap/' to correct path of extension? this path does not work:
'baseUrl'=>'/protected/extensions/bootstrap/',
If you are new, learn about extensions.
Than download ready yii extension for bootstrap: Yii-Bootstrap or Yii-Booster.
You don't have to define any js package, bootstrap extension will do it for you.
Here is sample config part for yii-booster, which i use (actually for yii-bootstrap it should be same):
'components' => array(
// ... other components
'bootstrap' => array(
'class' => 'ext.bootstrap.components.Bootstrap',
'coreCss' => true,
'responsiveCss' => true,
'yiiCss' => true,
),
),
// .. other components
And thats it! Bootstrap will work.

yii-user-management install 404 error

I am using MAMP pro with yii-1.1.12. and I am trying to install the latest version of yii-user-management.
My route for the webapp is
/Users/myname/Sites/yii-1.1.12/htdocs
I created the 'modules' folder and copied the yii-user-management into it:
htdocs > protected > modules
(modules and subfolders set to rewrite)
config/main.php
'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'password',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
'modules' => array(
'user' => array(
'debug' => true,
)
),
),
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'class' => 'application.modules.user.components.YumWebUser',
'allowAutoLogin'=>true,
'loginUrl' => array('//user/user/login'),
),
'import'=>array(
'application.modules.user.models.*',
),
etc...
I have followed the instructions to the letter but when I call the user/install in the browser I get a 404 error.
http://yii.dev:8888/index.php/user/install
My page works okay http://yii.dev:8888/index.php/login (with or without index.php)
Very frustrating. Any help would be appreciated.
I just realized there's a problem with your config/main.php...
You have modules listed within modules:
'modules'=>array(
'gii'=>array(//...gii configuration...),
'modules' => array(
'user' => array(
'debug' => true,
)
),
It should just be:
'modules'=>array(
'gii'=>array(//...gii configuration...),
'user' => array(
'debug' => true,
)
),

Yii user module error

I have installed 1.1.9 Yii framework.Then I made copy paste user module in my application folder and made changes to my main.php file.After all the configuration when I browsed the app and used user/login to login into my application, it showed error like this
Alias "user.UserModule" is invalid. Make sure it points to an existing PHP file.
I have checked my main.php files many times.But why it is showing error like this?any help,suggestions will be highly appriciable.
Here is my main.php file code.
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Web Application',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
#user module starts
'application.modules.user.models.*',
'application.modules.user.components.*',
#user module ends
),
'modules'=>array(
'user'=>array(
'returnUrl'=>array('/site/index'),
),
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'XXXX',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
'loginUrl'=>array('/user/login'),
),
// uncomment the following to enable URLs in path-format
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
*/
//'db'=>array(
// 'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
//),
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=XXXX',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'tablePrefix'=> 'tbl_',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster#example.com',
),
);
I got the error. The user module should be made copy paste under protected directory.Not any other directory.
Do you have a custom user module class? Based on 'application.modules.user.models.*', it seems like you do. In that case I think you'll need to set the class in the module declaration as well.