Domanda

I tried to use the SimplePie feed parser in Laravel. I pushed autoloader.php and library folder of SimplePie in the Laravel libraries folder, then I added a map for SimplePie in start.php

// folder tree

  • libraries/
    • simple/
      • library/
        • SimplePie/
        • SimplePie.php
      • autoloader.php

// start.php map

Autoloader::map(array(
'Base_Controller' => path('app').'controllers/base.php',
'SimplePie'     => path('app').'libraries/simple/autoloader.php',
));

// new object of simplepie

$feed = new SimplePie();
$feed->set_feed_url($feed_url);
$feed->enable_cache(false);
$feed->set_output_encoding('utf-8');

When I create a new object from SimplePie I see this error:

Message:

Autoloader not registered properly

È stato utile?

Soluzione 2

I'm not familiar with Laravel, but the SimplePie install instructions tell you to put the php and cache directories in the root.

"In your root directory, if they don't already exist, create two folders: php and cache."

Try putting them there instead of nested like you have them. The error message means that SimplePie can't find the class files, so it's a path issue. I would also just stick to the "php" directory instead of creating one called "simple". You might be able to change the directory names in SimplePie somewhere if you want to try and modify their code.

Altri suggerimenti

In my case, SimplePie literally "just worked".

In my composer.json, include

"simplepie/simplepie": "dev-master"

Then do "composer update" - this will download SimplePie to your Laravel "vendor" folder.

Then in your Controller, do

$feed = new SimplePie();

Voila!

Since simplepie has is composer compatible (i.e. is available on packagist.org), add it to your project from your command-line using the following

composer require simplepie/simplepie
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top