我在Ubuntu上开发了Yii应用程序。在此之后,我提交了项目并将操作系统重新安装到Windows 8.我使用PHP版本5.4.22安装“XAMPP”。所以,我的应用程序没有在新服务器上运行。我有Yii版本1.1.13,我收到此错误:
Invalid argument supplied for foreach()
C:\xampp\htdocs\storespace.loc\Yii_1.1.13\framework\base\CModule.php(191)
public function setParams($value)
189 {
190 $params=$this->getParams();
191 foreach($value as $k=>$v)
192 $params->add($k,$v);
193 }
配置数组
return CMap::mergeArray(
require(dirname( __FILE__ ) . '/main.php'),
array(
'name'=>'Store Space Local',
'serverName'=>'storespace.loc',
'components'=>array(
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=storespace',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix'=>'ss_',
'enableProfiling'=>true,
'enableParamLogging'=>true,
'schemaCachingDuration'=>1000
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CProfileLogRoute',
'levels'=>'profile',
'enabled'=>true,
),
),
),
'cache'=>array(
'class'=>'system.caching.CFileCache',
// 'class'=>'system.caching.CApcCache',
// 'class'=>'system.caching.CDummyCache',
/*'class'=>'system.caching.CMemCache',
'servers'=>array(
array('host'=>'localhost', 'port'=>11211),
),*/
),
),
)
);
数组的print_r
Array
(
[basePath] => C:\xampp\htdocs\storespace.loc\protected\config\..
[name] => Store Space Local
[theme] => storespace
[sourceLanguage] => en
[language] => en
[aliases] => Array
(
[dashboard] => C:\xampp\htdocs\storespace.loc\protected\config/../modules/dashboard
[admin] => C:\xampp\htdocs\storespace.loc\protected\config/../modules/admin
[manager] => C:\xampp\htdocs\storespace.loc\protected\config/../modules/manager
[store] => C:\xampp\htdocs\storespace.loc\protected\config/../modules/store
)
[preload] => Array
(
[0] => log
[1] => bootstrap
)
[import] => Array
(
[0] => application.models.*
[1] => application.components.*
[2] => application.behaviors.*
[3] => application.helpers.*
[4] => application.validators.*
[5] => application.widgets.*
[6] => application.extensions.yii-mail.*
[7] => application.extensions.image.*
[8] => application.extensions.config.*
[9] => ext.bootstrap.components.Bootstrap
[10] => ext.bootstrap.widgets.*
[11] => ext.payments.models.*
)
[controllerNamespace] => \application\controllers
[behaviors] => Array
(
[start] => Array
(
[class] => application\behaviors\StartBehavior
)
)
[modules] => Array
(
[gii] => Array
(
[class] => system.gii.GiiModule
[password] => 123456
[ipFilters] => Array
(
[0] => 127.0.0.1
[1] => ::1
)
[generatorPaths] => Array
(
[0] => bootstrap.gii
)
)
[dashboard] => Array
(
[class] => \dashboard\DashboardModule
)
[admin] => Array
(
[class] => \admin\AdminModule
)
[manager] => Array
(
[class] => \manager\StoreManagerModule
)
[store] => Array
(
[class] => \store\StoreModule
)
)
[components] => Array
(
[bootstrap] => Array
(
[class] => application\components\Bootstrap
[responsiveCss] => 1
)
[cfg] => Array
(
[class] => ext\config\DbConfig
[table] => {{config}}
[cacheId] => SITE_CONFIG
)
[similar] => Array
(
[class] => ext\similar\PhpCalculator
)
[actorsRating] => Array
(
[class] => \application\components\ActorsRating
)
[image] => Array
(
[class] => CImageComponent
[driver] => GD
)
[mailFactory] => Array
(
[class] => application\components\MailFactory
)
[mail] => Array
(
[class] => YiiMail
[transportType] => php
[viewPath] => application.views.mail
[layoutName] => main
)
[stringHelper] => Array
(
[class] => StringHelper
)
[user] => Array
(
[class] => application\components\WebUser
[allowAutoLogin] => 1
[loginUrl] => Array
(
[0] => dashboard/user/login
)
)
[urlManager] => Array
(
[class] => ext\languages\UrlManager
[urlSuffix] => /
[urlFormat] => path
[showScriptName] =>
[rules] => Array
(
[/] => /site/index
[/site] => /site/index
[/login/] => /dashboard/user/login
[login/] => /dashboard/user/login
[/get-trial/] => /dashboard/user/trial
[get-trial/] => /dashboard/user/trial
[/register//] => /dashboard/user/register
[register//] => /dashboard/user/register
[/pay//] => /dashboard/payment/pay
[pay//] => /dashboard/payment/pay
[/article/-] => /article/view
[article/-] => /article/view
[/contact-us] => /site/contactUs
[contact-us] => /site/contactUs
[/] =>
[/] => /index
[//] => /
[///] => //
)
)
[errorHandler] => Array
(
[errorAction] => /site/error
)
[log] => Array
(
[class] => CLogRouter
[routes] => Array
(
[0] => Array
(
[class] => CFileLogRoute
[levels] => error, warning
)
[1] => Array
(
[class] => \application\components\FileLogRoute
[levels] => ipn
[logFile] => ipn.log
)
[2] => Array
(
[class] => \application\components\FileLogRoute
[levels] => recurring-response
[logFile] => recurring-response.log
)
[3] => Array
(
[class] => \application\components\FileLogRoute
[levels] => info
[logFile] => info.log
)
[4] => Array
(
[class] => \application\components\FileLogRoute
[levels] => dibs
[logFile] => dibs.log
)
[5] => Array
(
[class] => CProfileLogRoute
[levels] => profile
[enabled] => 1
)
)
)
[clientScript] => Array
(
[scriptMap] => Array
(
)
)
[session] => Array
(
[autoStart] => 1
)
[authManager] => Array
(
[class] => application\components\PhpAuthManager
)
[db] => Array
(
[connectionString] => mysql:host=localhost;dbname=storespace
[username] => root
[password] =>
[charset] => utf8
[tablePrefix] => ss_
[enableProfiling] => 1
[enableParamLogging] => 1
[schemaCachingDuration] => 1000
)
[cache] => Array
(
[class] => system.caching.CFileCache
)
)
[params] => 1
[serverName] => storespace.loc
)
我可以用什么方法解决这个问题呢? 谢谢!
答案 0 :(得分:1)
在数组的print_r
中,params
的值为1
,无效。 Yii希望这是一个阵列。如果您不想要任何参数,请将其设置为array()
。