I keep getting this error when I try to execute a simple script on the server while it runs fine on my local machine.
Error
Fatal error: Class 'Bigcommerce\Api\Error' not found in
/customers/0/4/1/myDomainName/httpd.www/demo/hello/bigcommerce.php on
line 370
link to API
Sample Code
require_once 'bigcommerce.php';
use Bigcommerce\Api\Client as Bigcommerce;
Bigcommerce::configure(array(
'store_url' => 'https://www.mystore.com/',
'username' => 'myUsername',
'api_key' => 'myPass'
));
Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);
?>
Php Version
Server: 5.3.23
Local: 5.3.13
I fixed it by moving the declaration of class Error to just above the line 370 where class ClientError was declared.
Related
I try to implement some unit tests with phpUnit, on a project that uses Eloquent. The installation is made with composer for both frameworks. But when I try to implement a simple example test, it fails loading database.php
the example test
include("database.php");
class ArticleControllerTest extends TestCase
{
public function testAccueil()
{
//récupère la date du jour
$a = \app\model\Article::first();
$this->assertInternalType("string", $a->titreGeneral);
}
}
Database.php
<?php
require 'vendor/autoload.php';
use Illuminate\Container\Container;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;
$capsule = new Capsule;
$capsule->addConnection(array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'spectacles',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => ''
));
$capsule->setEventDispatcher(new Dispatcher(new Container));
$capsule->setAsGlobal();
$capsule->bootEloquent();
error message with these script (the database is in the right folder)
PHP Warning: include(../../database.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
Warning: include(../../database.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
PHP Warning: include(): Failed opening '../../database.php' for inclusion (include_path='.:') in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
Warning: include(): Failed opening '../../database.php' for inclusion (include_path='.:') in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
And error messages when I try to put the code in database.php directly in the example test :
PDOException: SQLSTATE[HY000] [2002] No such file or directory
I don't think the problem comes prom the paths (they are the right paths). Did I miss something ?
PDOException: SQLSTATE[HY000] [2002] No such file or directory means the database could not connect.
The other errors are clearly telling you that the script could not include the database.php file.
The paths are not correct. You are not properly understanding how include() works. Read http://php.net/manual/en/function.include.php.
In a nutshell, the following code expects the database.php file to exist in the same directory as the file itself, or on the include path.
include("database.php");
class ArticleControllerTest extends TestCase
{
...
These may also help:
Understanding include_path output PHP
Include Config and Database from other files
first of all, sorry for this silly question
but I am new to use big commerce API and I searched and found many threads but not works for me .
the composer created a directory vendor
then its root I have to create a file index.php and put this code but it's showing me the blank page
<?php
require 'vendor/autoload.php';
use Bigcommerce\Api\Client as Bigcommerce;
Bigcommerce::configure(array(
'store_url' => 'https://store-xxxx.mybigcommerce.com/api/v2/',
'username' => 'xxxx',
'api_key' => 'xxxx'
));
Bigcommerce::verifyPeer(false);
$ping = Bigcommerce::getTime();
if ($ping) echo $ping->format('H:i:s');
$filter = array("page" => 3, "limit" => 30);
$products = Bigcommerce::getProducts($filter);
?>
Please, someone, explain all steps with the easy understandable process ?
Sometimes it's giving
Fatal error: Class 'Bigcommerce_Api' not found in C:\xampp\htdocs\bigcommerceapi\index.php on line 30
I followed this community
https://c9.io/oschino/bigcommerce-api-php-oauth
when I clicking the single file link it's showing 404 not found where from I can download big commerce.php file
Also, I want to know if composer created a whole PHP API then is it it is necessary to download big commerce PHP API from Github ?
I have checked the folder structure and files are same in vendor folder and big commerce git hub files.
Please help
I got solution the bigcoomerce store URL call process is now changed
I changed
Bigcommerce::configure(array(
'store_url' => 'https://store-xxxx.mybigcommerce.com/api/v2/',
'username' => 'xxxx',
'api_key' => 'xxxx'
));
to like this
Bigcommerce::configure(array(
'store_url' => 'https://store-xxxx.mybigcommerce.com',
'username' => 'xxxx',
'api_key' => 'xxxx'
));
I was trying to follow https://github.com/double-z/chef-metal-ssh
I'm running the code below, it throws the exception:
[2015-01-19T06:03:39-06:00] ERROR: machineone had an error: ArgumentError: wrong number of arguments (2 for 0)
require 'chef_metal_ssh'
name = "one"
with_ssh_cluster("~/metal_ssh")
machine name do
action [:ready, :converge]
machine_options 'ip_address' => '10.62.56.209',
'ssh_options' => {
'user' => 'root',
'keys' => ['/home/chefuser/test.rsa']
}
files '/remote/path.txt' => { :content => 'foo' }
end
machine_execute name do
command "pwd" # this uses new_daemon_key to register with halo
end
I want to know what's wrong of this code. And I don't understand for with_ssh_cluster("~/metal_ssh") what content should be in "~/metal_ssh"? thanks.
I had to dig a little with the code to understand (I'm not using it).
According to the comment below found here
# cluster_path - path to the directory containing the vagrant files,
# which should have been created with the vagrant_cluster resource.
The "~/metal_ssh" file should be the Vagrantfile path.
chaf-metal-ssh is a driver for chef-metal, I'm not sure you're comfortable with chef-metal, so I would advise starting by reading This and This
I've found that the issue is I was using chef 12.0.3, and in line 109 of /usr/local/rvm/gems/ruby-2.0.0-p598/gems/chef-12.0.3/lib/chef/dsl/recipe.rb
resource.load_prior_resource(type, name)
But in chef-metal-ssh-0.1.2/lib/chef/resource/ssh_cluster.rb:18
it's defined as
def load_prior_resource
Chef::Log.debug("Overloading #{resource_name}.load_prior_resource with NOOP")
end
so it throws
ArgumentError: wrong number of arguments (2 for 0)
I downloaded AWS SDK and stored it in the same directory of this file, but every tyme this simple script gives this error:
"Fatal error: Undefined class constant 'ACL_PUBLIC_READ'"
This script is for uploading a simple png image on s3:
require 'aws.phar';
$bucket='example';
use Aws\S3\S3Client;
use Aws\Common\Enum\Region;
$client = S3Client::factory(array(
'key' => 'mykey',
'secret' => 'mysecretkey'
));
$client->putObject($_FILES['myfile']['tmp_name'], $bucket , 'file.png', S3Client::ACL_PUBLIC_READ);
How can I solve it?
That constant doesn't exist in SDK 2.x. I think you're looking for this:
http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.Enum.CannedAcl.html
I want to use sentry 1.x with Laravel 3.x in the migrations I use, but when I try to migrate I get this error:
PHP Fatal error: Class 'Sentry' not found in /var/www/laravel.dev/application/migrations/2013_03_06_183713_add_user_to_database.php on line 34
This is what I try to do in function up():
$user_id = Sentry::user()->create(array(
'email' => 'admin#test.com',
'password' => 'testpass',
'metadata' => array(
'first_name' => 'Test',
'last_name' => 'Test'
)
));
What am I missing ?
p.s: I know having the password in PHP is insecure, this is just a test environment.
Thanks,
You need to start the bundle.
Bundle::start( 'sentry' );
Add 'Cartalyst\Sentry\SentryServiceProvider' to the list of service providers in app/config/app.php