By far, it seems that yii has no any cloud compute tools or extensions integrated, but the related product is more and more popular, like amazon cloud aws.
so i want to integrate the popular aws tools tarzan into yii as a third party.
the following are the steps :
1.make a dir 'vendors' under the 'protected' folder
2.copy the tarzan folder(tarzan_2.0.5) into it
3.add these lines at the begining of a controller class file:
Yii::import('application.vendors.*');
require once('tarzan_2.0.5/tarzan.class.php');
{the tarzan documentation said: In your application (e.g. a specific PHP document), simply use require_once() (or require() or include_once() or include()) to add the tarzan.class.php file to your page. This will load the core Tarzan API.}
4. add a test action,like that:
public function actionTest()
{
$sdb = new AmazonSDB();
/**
* Create a new SimpleDB domain.
*/
$domain = $sdb->create_domain('mysdb_test2');
// As long as the request was successful...
if ($domain->isOK())
{
echo('create domain successfully');
}
}
but when i access the action, an error occurs:
PHP Error
Description
YiiBase::include(AmazonSDB.php) [<a href='yiibase.include'>yiibase.include</a>]: failed to open stream: No such file or directory
Source File
/var/www/yii-1.0.9.r1396/framework/YiiBase.php(324)
00312: * @param string class name
00313: * @return boolean whether the class has been loaded successfully
00314: */
00315: public static function autoload($className)
00316: {
00317: // use include so that the error PHP file may appear
00318: if(isset(self::$_coreClasses[$className]))
00319: include(YII_PATH.self::$_coreClasses[$className]);
00320: else if(isset(self::$_classes[$className]))
00321: include(self::$_classes[$className]);
00322: else
00323: {
00324: include($className.'.php');
00325: return class_exists($className,false) || interface_exists($className,false);
00326: }
00327: return true;
00328: }
00329:
00330: /**
00331: * Writes a trace message.
00332: * This method will only log a message when the application is in debug mode.
00333: * @param string message to be logged
00334: * @param string category of the message
00335: * @see log
00336: */
the tarzan.class.php also relies on SPL autoload to perform class file inclusion.
i am really confused why yii cannot include the tarzan class file.
does anyone has any suggestion?
and brother Qiang ,pls help me.
thanks
Page 1 of 1
How to add the tarzan(aws tools) as a third party?
#2
Posted 10 October 2009 - 10:44 AM
when i add this line at the begining of the function actionTest()
require_once('tarzan_2.0.5/sdb.class.php'); //i know it's redundant, just make a try
the Stack Trace show:
#0 /var/www/yii-1.0.9.r1396/framework/YiiBase.php(324): autoload()
#1 unknown(0): autoload()
#2 /var/www/xxxx/protected/vendors/tarzan_2.0.5/tarzan.class.php(290): spl_autoload_call()
#3 /var/www/xxxx/protected/vendors/tarzan_2.0.5/sdb.class.php(99): AmazonSDB->__construct()
#4 /var/www/xxxx/protected/controllers/TestController.php(51): AmazonSDB->__construct()
#5 /var/www/yii-1.0.9.r1396/framework/web/actions/CInlineAction.php(32): TestController->actionTest()
#6 /var/www/yii-1.0.9.r1396/framework/web/CController.php(300): CInlineAction->run()
#7 /var/www/yii-1.0.9.r1396/framework/web/filters/CFilterChain.php(129): TestController->runAction()
#8 /var/www/yii-1.0.9.r1396/framework/web/filters/CFilter.php(41): CFilterChain->run()
#9 /var/www/yii-1.0.9.r1396/framework/web/CController.php(957): CAccessControlFilter->filter()
#10 /var/www/yii-1.0.9.r1396/framework/web/filters/CInlineFilter.php(59): TestController->filterAccessControl()
#11 /var/www/yii-1.0.9.r1396/framework/web/filters/CFilterChain.php(126): CInlineFilter->filter()
#12 /var/www/yii-1.0.9.r1396/framework/web/CController.php(283): CFilterChain->run()
#13 /var/www/yii-1.0.9.r1396/framework/web/CController.php(257): TestController->runActionWithFilters()
#14 /var/www/yii-1.0.9.r1396/framework/web/CWebApplication.php(332): TestController->run()
#15 /var/www/yii-1.0.9.r1396/framework/web/CWebApplication.php(120): CWebApplication->runController()
#16 /var/www/yii-1.0.9.r1396/framework/base/CApplication.php(135): CWebApplication->processRequest()
#17 /var/www/xxxx/index.php(11): CWebApplication->run()
require_once('tarzan_2.0.5/sdb.class.php'); //i know it's redundant, just make a try
the Stack Trace show:
#0 /var/www/yii-1.0.9.r1396/framework/YiiBase.php(324): autoload()
#1 unknown(0): autoload()
#2 /var/www/xxxx/protected/vendors/tarzan_2.0.5/tarzan.class.php(290): spl_autoload_call()
#3 /var/www/xxxx/protected/vendors/tarzan_2.0.5/sdb.class.php(99): AmazonSDB->__construct()
#4 /var/www/xxxx/protected/controllers/TestController.php(51): AmazonSDB->__construct()
#5 /var/www/yii-1.0.9.r1396/framework/web/actions/CInlineAction.php(32): TestController->actionTest()
#6 /var/www/yii-1.0.9.r1396/framework/web/CController.php(300): CInlineAction->run()
#7 /var/www/yii-1.0.9.r1396/framework/web/filters/CFilterChain.php(129): TestController->runAction()
#8 /var/www/yii-1.0.9.r1396/framework/web/filters/CFilter.php(41): CFilterChain->run()
#9 /var/www/yii-1.0.9.r1396/framework/web/CController.php(957): CAccessControlFilter->filter()
#10 /var/www/yii-1.0.9.r1396/framework/web/filters/CInlineFilter.php(59): TestController->filterAccessControl()
#11 /var/www/yii-1.0.9.r1396/framework/web/filters/CFilterChain.php(126): CInlineFilter->filter()
#12 /var/www/yii-1.0.9.r1396/framework/web/CController.php(283): CFilterChain->run()
#13 /var/www/yii-1.0.9.r1396/framework/web/CController.php(257): TestController->runActionWithFilters()
#14 /var/www/yii-1.0.9.r1396/framework/web/CWebApplication.php(332): TestController->run()
#15 /var/www/yii-1.0.9.r1396/framework/web/CWebApplication.php(120): CWebApplication->runController()
#16 /var/www/yii-1.0.9.r1396/framework/base/CApplication.php(135): CWebApplication->processRequest()
#17 /var/www/xxxx/index.php(11): CWebApplication->run()
#3
Posted 19 November 2009 - 09:06 AM
Hey bro, did you ever figure this one out? ...maybe it's just a Simple DB thing? Tarzaan wrappers for Yii sound like a great idea. If you've made some progress on this, you should make a Yii extension for Tarzaan.
http://www.faceyspacey.com - I'm a Web 2.0 Development Monster.
#4
Posted 17 December 2009 - 05:59 AM
This happen because yii try to include the class name by it file name (see YiiBase.php:337) because class AmazonSDB exist in sdb.class.php you got the first faile, requre will not work well in yii. to solved it i can suggest this sed, running in tarzan root
(in your case tarzan_2.0.5)
1. egrep "^class " * | sed -n 's/\([^:]*\):class \([^ ]*\).*/echo \"<?php include_once \\"\1\\";?>\" >.\/\2.php/p' >l.l
2. source l.l
this will create files named by the Tarzan classes using include_once to include he right file for relevant class.
I use include_once to prevent future errors because class AmazonSQS & AmazonSDB are located in the same file.
have fun.
(in your case tarzan_2.0.5)
1. egrep "^class " * | sed -n 's/\([^:]*\):class \([^ ]*\).*/echo \"<?php include_once \\"\1\\";?>\" >.\/\2.php/p' >l.l
2. source l.l
this will create files named by the Tarzan classes using include_once to include he right file for relevant class.
I use include_once to prevent future errors because class AmazonSQS & AmazonSDB are located in the same file.
have fun.
Share this topic:
Page 1 of 1

Help
This topic is locked












