Good day, I'm trying to import stock quotes using IEX Trading API. I founded some php classes to use those apis but I'm having troubles in intalling them:
In my index.php page I'm including the main class file: include("DPRMC/IEXTrading/src/IEXTrading.php");
no problems here, the inclusion works (o tried echoing a variable and is actually printed on screen)
in the IEXTrading.php file I have this code:
namespace DPRMC\IEXTrading;
use DPRMC\IEXTrading\Exceptions\InvalidStockChartOption;
use DPRMC\IEXTrading\Exceptions\ItemCountPassedToStockNewsOutOfRange;
use DPRMC\IEXTrading\Exceptions\UnknownSymbol;
use DPRMC\IEXTrading\Responses\StockChart;
use DPRMC\IEXTrading\Responses\StockCompany;
use DPRMC\IEXTrading\Responses\StockFinancials;
use DPRMC\IEXTrading\Responses\StockLogo;
use DPRMC\IEXTrading\Responses\StockNews;
use DPRMC\IEXTrading\Responses\StockPeers;
use DPRMC\IEXTrading\Responses\StockPrice;
use DPRMC\IEXTrading\Responses\StockQuote;
use DPRMC\IEXTrading\Responses\StockRelevant;
use DPRMC\IEXTrading\Responses\StockStats;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
class IEXTrading { ............ }
but when in my index.php page I call
$stockQuote = IEXTrading::stockQuote( 'aapl' );
echo $stockQuote->companyName; // Apple Inc.
I get this error:
Fatal error: Class 'IEXTrading' not found
any help?
If the classes you are using is DPRMC/IEXTrading you can manage it via composer, using its composer package.
You have to:
In your project folder install the package with this command:
composer require dprmc/iex-trading
Add the composer requirement in your PHP file:
require __DIR__ . '/vendor/autoload.php';
Quote
// https://iextrading.com/developer/docs/#quote
$stockQuote = IEXTrading::stockQuote( 'aapl' );
echo $stockQuote->companyName; // Apple Inc.
Let me know :-)