rhysnhall / etsy-php-sdk

PHP SDK for Etsy API v3.
MIT License
47 stars 36 forks source link

Minor documentation update #22

Closed MikeWillis closed 1 year ago

MikeWillis commented 1 year ago

Hi, first, thanks for setting this up! I'm just starting to use it and I'm sure it will save me (and everyone else) a ton of time!

In a quick test to get started, using the code in the Usage section, I was getting fatal errors:

use Etsy\Etsy;
use Etsy\OAuth\Client;
$client = new Etsy\OAuth\Client( "asdf" );

PHP Fatal error: Uncaught Error: Class 'Etsy\Etsy\OAuth\Client' not found in /......./path/...../test.php:4

I had to change it to this:

require_once( __DIR__ . '/vendor/autoload.php' );
use Etsy\Etsy;
use Etsy\OAuth\Client;
$client = new \Etsy\OAuth\Client( "asdf" );

Autoload was needed, and it seems that the first use statement was causing Etsy to become Etsy\Etsy which made the path come up wrong, so adding the slash fixed it.

rhysnhall commented 1 year ago

Hey Mike, Thanks for reaching out. This is relevant to your specific project and composer setup. I deliberately left it as minimal as possible, as it is the responsibility of the user to load the package into their project correctly. There are too many variables for me to write examples that would work 100% of the time. When testing the package, I use a very barebones PHP environment, and the provided examples are what I use and are copied from that environment.