dougu5847 2013-04-30 19:29
浏览 22
已采纳

在Yii中使用Phpcassa

Has anyone been able to use Phpcassa in a Yii application. I have tried adding the phpcassa folder into the components which I have added to the config for auto loading but its not recognizing the phpcassa classes and they are not getting autoloaded.

I have used the phpcassa code in a standalone php file and it all works well so I know everythng is in place, just that I cant load the phpcassa classes in Yii.

Any help would be really appreciated.

Dave

I managed to get the necessary classes loaded. This may not be the right way but it works for me. I unloaded Yii autoload, added my classes and phpcassa autoloader like in the phpcassa examples and then registered the autoloaded again.

spl_autoload_unregister(array('YiiBase', 'autoload')); // Disable Yii autoloader
require_once(__DIR__.'/../extensions/lib/autoload.php');
use phpcassa\Connection\ConnectionPool;
use phpcassa\ColumnFamily;
use phpcassa\ColumnSlice;
use phpcassa\SystemManager;
use phpcassa\Schema\StrategyClass;
spl_autoload_register(array('YiiBase', 'autoload')); 

Thanks for the help Chris

  • 写回答

1条回答 默认 最新

  • drfm55597 2013-05-01 06:08
    关注

    The Applications components directory is autoloaded automatically, so you shouldn't need to change your config. I'm not familiar with phpcassa but things to check include:-

    • Is the filename identical to the classname?
    • Does phpcassa include sub-classes? These won't be auto-loaded by default.

    edit: Hi, try using Yii::registerAutoloader in your bootstrap. With Zend, I use the code like this:-

    Yii::import('application.vendors.*');
    require "Zend/Loader/Autoloader.php";
    Yii::registerAutoloader(array('Zend_Loader_Autoloader',  'autoload'), true);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路