I have a snippet of code that works fine. But this code has some login credentials (connecting to remote server) in it. So instead of typing the login details on each page, I would like to include the details to another include file. When I do this, i include('filename.php') in the new script and for some reason that does not work. I get the following error: Fatal error: Class 'Bigcommerce\Api\Client' not found in
The include file I created looks like this:
require_once ('../bigcommerce.php');
use Bigcommerce\Api\Client as Bigcommerce;
Bigcommerce::configure(array(
'store_url' => 'https://www.website.com',
'username' => 'username',
'api_key' => 'api_key'
));
Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);
The code file that has the code above as an include is:
<?php
include_once 'vendor/autoload.php';
$products = Bigcommerce::getProducts();
foreach($products as $product) {
echo $product->name;
echo $product->price;
echo ("<br />");
}
?>
This is the complete block of code that works in a single file:
<?php
require ('bigcommerce.php');
use Bigcommerce\Api\Client as Bigcommerce;
Bigcommerce::configure(array(
'store_url' => 'https://www.website.com',
'username' => 'username',
'api_key' => 'api_key'
));
Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);
$products = Bigcommerce::getProducts();
foreach($products as $product) {
echo $product->name;
echo $product->price;
echo ("<br />");
}
?>
How do I put this code in an external file so that I can include it throughout my site?
Thanks in advance for your help.