I am using PHP 7.3.5 and Composer version 1.8.5 and would like to use "simplepie/simplepie": "^1.5" to get data from an rss feed.
When running the below script I get the error: Fatal error: Uncaught Error: Class 'SimplePie\SimplePie' not found
<?php
require 'vendor/autoload.php';
use SimplePie\SimplePie;
$url = 'https://www.reddit.com/r/worldnews/top.rss?t=day';
$feed = new SimplePie();
$feed->set_feed_url($url);
$feed->init();
How to correctly use simplepie with composer?
You can try:
This worked in one of my projects.
more complete example (with in composer.json : "simplepie/simplepie": "^1.5"):
I'm not a Composer/autoloading specialist, but since Simplepie uses its own autoloader, that may explain this writing.