Question

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

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top