It's been quite a while since I have done any heavy PHP development. I am trying to bring an older library up to date with composer
and namespaces
and am having a hard time fully understanding things.
Here is my composer.json
{
"description": "MyClass",
"require": {
"php": ">=5.3.0",
"guzzlehttp/guzzle": "~6.0"
},
"autoload": {
"psr-4": {
"MyClass\\": "src/"
}
}
}
I am trying to write some examples on how to use the updated library, but am having trouble getting my code to run. Here is my example file:
<?php
use MyClass;
$account_id = 123; // Replace with your account id
$public_key = '09876'; // Replace with your public key
$private_key = 'privkey'; // Replace with your private key
$klass = new MyClass($account_id, $public_key, $private_key);
echo $klass->myMethod();
Every time I run the above code I get the following error:
Warning: The use statement with non-compound name 'MyClass' has no effect
PHP Fatal error: Class 'MyClass' not found