diff --git a/example/init_example.php b/example/init_example.php index 496edfd..238a82a 100644 --- a/example/init_example.php +++ b/example/init_example.php @@ -14,7 +14,7 @@ * @license https://opensource.org/licenses/MIT MIT License (MIT) */ -require(dirname(dirname(__FILE__)) . '/init.php'); +require(dirname(__DIR__) . '/init.php'); require(dirname(__FILE__) . '/Data.php'); $config = require(dirname(__FILE__) . '/config.php'); diff --git a/init.php b/init.php index 7956dc2..5de1862 100644 --- a/init.php +++ b/init.php @@ -14,9 +14,18 @@ * @license https://opensource.org/licenses/MIT MIT License (MIT) */ -require(dirname(__FILE__) . '/lib/ApiClient.php'); -require(dirname(__FILE__) . '/lib/Http/CurlClient.php'); -require(dirname(__FILE__) . '/lib/Http/Response.php'); -require(dirname(__FILE__) . '/lib/SignatureVerifier.php'); -require(dirname(__FILE__) . '/lib/Bolt.php'); -require(dirname(__FILE__) . '/lib/Helper.php'); +// Composer autoloader path +$vendorAutoload = dirname(dirname(__DIR__)) . '/autoload.php'; + +if (file_exists($vendorAutoload)) { + // Load classes via composer autoloader + require($vendorAutoload); +} else { + // Preload library classes + require(dirname(__FILE__) . '/lib/ApiClient.php'); + require(dirname(__FILE__) . '/lib/Http/CurlClient.php'); + require(dirname(__FILE__) . '/lib/Http/Response.php'); + require(dirname(__FILE__) . '/lib/SignatureVerifier.php'); + require(dirname(__FILE__) . '/lib/Bolt.php'); + require(dirname(__FILE__) . '/lib/Helper.php'); +} diff --git a/lib/playground.php b/lib/playground.php index 5547436..130a995 100644 --- a/lib/playground.php +++ b/lib/playground.php @@ -14,9 +14,7 @@ * @license https://opensource.org/licenses/MIT MIT License (MIT) */ -require(dirname(__FILE__) . '/ApiClient.php'); -require(dirname(__FILE__) . '/Http/CurlClient.php'); -require(dirname(__FILE__) . '/Http/Response.php'); +require(dirname(__DIR__) . '/init.php'); $client = new \BoltPay\ApiClient([ 'api_key' => 'c117fec29f5c1365dacbc62390b5b6f98c0698a812d7015849319f9f7b863064',