[英]Yii - call member function out of Yii?
我知道這不合法,而且看起來很奇怪。 但這對我來說是必要的。 我有兩個項目,一個是自定義 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(上層功能)功能。
你可以像這樣初始化應用程序,在 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
)的main.php
需要更改以適合您的項目結構
只是復制
$ sm-> hashData(..)的實現
到任何文件(yii-functions.php)包含並使用哈哈? 它的孩子院子?
您的升級框架多久一次? 只需升級和yii-functions.php。 當然,如果您想在框架之外使用lightfull腳本。 在其他地方使用,則需要屈服。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.