我知道这不合法,而且看起来很奇怪。但这对我来说是必要的。我有两个项目,一个是自定义Open-Cart和第二个是在Yii。我在opencart中的主要项目。我的Yii项目保存在主项目根目录中。
现在我想在opencart中调用一个Yii函数。请任何人帮助我,告诉我如何在我的主项目中调用Yii函数?
这是我的yii函数:
$sm=Yii::app()->getSecurityManager();
if ($salt === null)
$salt = Yii::app()->params['password_security_salt'];
if($salt==null)
$salt=md5 (mt_rand ().mt_rand ().mt_rand ().mt_rand ());
$pass=sha1($salt.$pass.$salt);
return $sm->hashData($pass,$key).':'.$salt;.
我想为我的opencart项目手动创建新函数。请帮助我为相同的功能,如Yii (上层函数)功能创建新的项目。
发布于 2016-08-29 19:43:50
您可以通过初始化应用程序在Yii项目之外使用Yii功能,如下所示:
// this is in someotherfile.php outside of the yii project
require_once('framework/yii.php');
$config = require_once('protected/config/main.php');
Yii::createWebApplication($config);
// call your function
Yii::app()->getSecurityManager();显然,需要更改yii.php文件的路径和应用程序配置(main.php)以适应您的项目结构
https://stackoverflow.com/questions/39202898
复制相似问题