codeigniter: mongodb library unable to load - php

I am working with code-igniter in which I want to work with MONGODB at the backend. I used the drivers from https://github.com/huglester/MongoDB-CodeIgniter-Driver ,i.e. added the config (named mongo_db.php) and library files (named Mongo_db.php) as per instructed.
I load this library in the constructor method of my model. Now the issue is that this library class doesn't load and gives me the following error:
"Unable to load the requested class: Mongo_db"
What could be the issue?

I resolved the error.
Turns out, I need to extend my loader class and customize it such that other other "users" libraries can be loaded.
Here's the link to the solution

Related

Codeigniter 3 dev Unable to load the requested class

I'm new in CI and now I'm trying to use CodeIgniter 3 to develop my site. I just only extract the framework and change only one think in config/autoload.php file:
$autoload['libraries'] = array('database','input');
when I run the site, an error occur:
Unable to load the requested class: Input
When I tried it with CI version 2.2.0 stable, every thing is OK, no errors
Could some one explain why and help me to solve it?
As of documentation input library is loaded by default.
This class (input) is initialized automatically by the system so there is no need to do it manually.
Autoloading documentation http://www.codeigniter.com/userguide3/general/autoloader.html
By default the library load from system/core folder in you CI. But the Input library is located on the core folder so you need to give relative path to the Input.php like this
$autoload['libraries'] = array('database','../core/input');

Codeigniter DB Language extension not working

I'm trying to use this extension
But it gives me the following error when loading the library:
Unable to load the requested class: Language
Also if I write MY_Language instead, it gives me the following error:
Fatal error: Class 'CI_Language' not found in C:\wamp\www\ckphp\application\libraries\MY_Language.php on line 79
I am using WAMP and CI v. 2.2.0
Thanks!
I figured it out myself after some more researching...
Apparently the language class is not even in the library folder, but in core folder, meaning it should be placed in the core application/core folder. Also the name is not CI_Language, but CI_Lang, meaning the file name has to be MY_Lang (if MY_ is your prefix). The last thing to change in the extension is
parent::CI_Language();
to
parent::__construct();
and everything should work fine!
Usage:
$this->lang->load('set', 'language'); // To load a language
$this->lang->line('key'); // to display the text
or simply
lang('key'); // if using the language helper
Hope this will help others in the future!
I made a GIST for latest CodeIgniter 3.1.X including with migration to create the database structure
https://gist.github.com/cyberfly/885b320fdf914ae15f7316b22cc72f32

How to use ZF2 ZendPdf in Yii Framework

I want to parse a PDF document in my project, I'm using Yii framework and I'm able to load ZendFramework 1.12, actually I'm using Zend_Lucene and Zend_Mail successfully, but ZendPdf fails to parse the PDF, so I wanted to try with ZF2 (ZendFramework 2), but I'm not able to make it work... I just downloaded the ZF2 library and added the following to my base Controller:
public function __construct($id,$module=null){
Yii::import('application.vendors.ZendFramework.library.*');
Yii::setPathOfAlias('Zend',Yii::getPathOfAlias('application.vendors.ZendFramework.library.Zend'));
parent::__construct($id,$module);
}
So every time I use a Controller this code is executed. Then in the controller I have:
use ZendPdf\PdfDocument;
use Zend\Mail;
class AjaxController extends Controller{...
...
public function actionTestPdf(){
$filepath = realpath('./path/').'/pdftest2.pdf';
$pdf = PdfDocument::load($filepath);
}
When I run the controller: /ajax/TestPdf
I get: Fatal error: Class 'ZendPdf\PdfDocument' not found
What am I doing wrong?
I'd suggest you to install your ZF2 stuff with composer and include the autoloader from composer to get PSR compatible autoloading.
Alternative 1)
You may also try pointing an alias ZendPdf\PdfDocument to the class file location.
Alternative 2)
import the needed classes or directories in your application config.
In this particular case I would recommend NOT using ZendPdf from ZF2, because it is functionally equivalent to Zend_Pdf from ZF1 and so all you're going to do is add unnecessary complexity with classloading, etc, but not solve your underlying problem, as the document will still most likely NOT load using ZendPdf from ZF2.
You should investigate the underlying reason why the document is failing to load in ZF1.

Using models in third-party extensions

I'm using a third-party extension in Yii and I'd like to know, if it's possible to use the models in the extension.
The extension create a table on my database and the model has a relation rule to my user table. I have added a relation on my user model to the extension's model.
When I do a findAll query, it throws me an error: include(ExtensionModel.php): failed to open stream: No such file or directory.
How do I use models in third-party extensions?
Please have a look at the manual. In the simple case you only need to include this into the 3rd party files:
require_once('path/to/yii.php');
Yii::createWebApplication('path/to/config.php');
I think it would be helpful - see code below:
require_once('path/to/yii.php');
Yii::createWebApplication('path/to/config.php');

unable to load Assetes class with MY_Assetes in same directory

i have one third party asset library in my application folder, i am extending that library with MY_Assets library both are in same application/library directory, but when loading its giving error Unable to load the requested class: Assets, i want to add some extra features in library by extending it so if developer of main library make any update nothing effect to mine extension
Place the file in application folder and need to include the code manually then extends from it.
See the below code that I uses for extending the Facebook connect for Codeigniter.
include(APPPATH.'libraries/facebook/facebook.php');
class Fb_connect extends Facebook{
//my coding here
}
Here I have a folder named facebook inside the libraries folder for facebook related dowloaded files and FB_connect.php is my library file it is in application /libraries folder and fb_connect class that inherits from Facebook class.

Categories