I want to be able to use SimplePie on Yii.
I'm using the 1.3-dev version of simplepie
I created a "vendors" folder, put all I had in the .tar.gz in a simplepie subfolder.
Then i add this lines at the beginning of my controller
Yii::import('application.vendors.SimplePie.*');
require_once 'SimplePieAutoloader.php';
spl_autoload_unregister(array('YiiBase','autoload'));
spl_autoload_register(array('SimplePie_Autoloader','autoload'));
spl_autoload_register(array('YiiBase','autoload'));
But when I try to use it, I get this error:
include(SimplePie_Core.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
C:\wamp\www\yii\fr\framework\YiiBase.php(418)
Any ideas why I get this error?
edit: i took the compiled version of simplepie and everything works like a charm
I think (not looked into it fully) that the Simple Pie library follows PSR-0 for class and file names. In which case you should be able to register its path and Yii's autoloader will know how to autoload it. Try adding the following to config.php;
Yii::setPathOfAlias('SimplePie', '/path/to/vendor/');
The second argument needs to point to the root folder of the library e.g. if your path is like this /var/lib/yiiproject/vendor/simplepie/lib/SimplePie then the register the path /var/lib/yiiproject/vendor/simplepie/lib
This yii widget use SimplePie
http://www.yiiframework.com/extension/yii-feed-widget/
Related
I'm working on a native PHP project. Using terminal in the root I added 2 github libraries and they get saved in the vendor folder. In a sub folder in the root in a PHP file I add
use nadar\quill\Lexer;
$lexer = new Lexer($row['reply']);
echo $lexer->render();
But I get
Uncaught Error: Class 'nadar\quill\Lexer' not found in /home/USER/public_html/production/filename.php:469
I tried another library and get the same error Cannot find the class. How to solve this? Tis is the first library url: https://github.com/nadar/quill-delta-parser
Every file where you need classes loaded by the autoloader need to include the autoload file. Otherwise, these classes are unknown by the interpreter.
Add this to the beginning of your file:
require __DIR__ . '/vendor/autoload.php';
I want to use the following AntiXSS library in one PHP file. It is my first time using Composer, but I followed their installation steps and I installed it successfully. I downloaded the library through Composer, updated it and Composer created the vendor/ folder in my directory with the necessary files.
Now I added the following require 'vendor/autoload.php' into my PHP file. I created a new AntiXSS class but I obtain the following error:
Class AntiXSS not found in my directory on line 3.
I tried to use an absolute path instead of vendor/autoload.php but it isn't working yet and I don't know if I should do something more.
Best regards
The class is located in the voku\helper namespace. Use new \voku\helper\AntiXSS() to instantiate it or use use imports to import the namespace.
See php.net for more information about namespaces.
I'm trying to implement Amazon WebServices PHP SDK into my Zend 1 project, but it seems to fail loading the classes.
I have got the library into library/Eplan/AmazonCloudSearch and after investigation it seems that in order to be able to load the namespace I need to call the registerNamespace method from Zend_Loader_Autoloader::getInstance() so I've got this on the top of the autoloader (I also tried to put it in the bootstrap without luck):
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace("Aws");
Namespaces of the AWS library are like this: Aws\namespace
The errors I get are like Warning: include_once(Aws/Common/Aws.php): failed to open stream: No such file or directory in /srv/www_nfs_desarrollo/vhosts/desarrollo.techmaker.net/httpdocs/library/Zend/Loader.php on line 134
Autoloader full code: http://pastebin.com/gS9mcntK
I've been the full day struggling my head trying to solve this without luck, any ideas?
In order to use $autoloader->registerNamespace('Aws'), the AWS lib you seek must be on your PHP include path, which probably includes your ./library directory. Instead, you have the AWS lib buried down in ./library/Eplan/AmazonCloudSearch, which almost certainly is not on your PHP include_path.
Try moving the AWS library up two levels, directly into the ./library directory.
You can autoload using your application.ini file using following code.
autoloaderNamespaces[] = "Aws"
I'm trying to load a custom library in Concrete5.
I've created a library file, internallib.php, and placed the file in the /libraries folder. This file does not extend any core library files. I keep getting this error:
Warning: require_once(/var/www/concrete/libraries/internalauth.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/portal/concrete/core/libraries/loader.php on line 30
Though if I move the file into the folder /concrete/libraries, I don't get this error. Should I be putting my library file into the concrete/libraries, or /libraries folder? I assumed that since this is a 3rd party library, it should go into the root libraries folder, as not to conflict with any future core updates.
I'm currently running v.5.6.0.2
Any ideas?
You are right, the root libraries folder is the place to go.
You could try to put it in libraries/3rdparty which is where 3rd party libraries should be.
The problem however might come from the way you are calling the library, not from the library itself.
Maybe you could tell us more?
I am trying to extend a library in codeigniter. The only way to do so seems to include the original library using require_once then load the extended library using $this->load->library()
right now I have tried
require_once('ion_auth.php');
require_once('home/SITE_NAME/public_html/FOLDER_NAME/application/libraries/ion_auth.php')
require_once('/home/SITE_NAME/public_html/FOLDER_NAME/application/libraries/ion_auth.php')
but unfortunately not luck..... I keep getting this error
Message: require_once(...) [function.require-once]: failed to open stream: No such file or directory
Weird thing is though this works on my local xampp environment but not on the actual server.
Use CodeIgniter's built in constant, APPPATH
require_once(APPPATH.'libraries/ion_auth.php');
If the library is a codeigniter specific library, as sbaaaang points out, you should use:
$this->load->library('ion_auth');
However, if the library is just a generic PHP class or set of functions, the codeiginter loader may not recognize it. Then you will need to use either one of the generic loading operators (include, include_once, require, require_once), with the APPPATH constant, as also pointed out:
require_once(APPPATH.'libraries/ion_auth.php');
Do you know that Codeigniter has a loader class?
change this
require_once('/home/SITE_NAME/public_html/FOLDER_NAME/application/libraries/ion_auth.php')
to
$this->load->library('ion_auth');
and be sure your libraries/ion_auth.php file it's a class named `class ion_auth{}`