Reputation: 181
Excuse me, I want to use this sdk GitHub
I try include file php into laravel controller , but is not work.
then, I'll update composer.json, using PSR-4 .. is class XXX/XXX/ not found..
error message Class 'App\Http\Controllers\ECPay_AllInOne' not found
how can I do? please help me, thanks~
my project sdk file :
composer.json
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"ECPaySDK\\": "ECPaySDK/"
},
"files": [
"ECPaySDK/ECPayPaymentIntegration.php"
]
},
my controller
<?php
namespace App\Http\Controllers;
use ECPaySDK;
use Illuminate\Http\Request;
use Mail;
use App\Http\Requests;
use App\Travel_user;
use App\Travel_user_place;
use App\Place;
use App\Files;
use App\House;
use DB;
use Illuminate\Support\Facades\File;
class BackendController extends Controller
sdk class
<?php
namespace ECPaySDK;
abstract class ECPay_PaymentMethod {
const ALL = 'ALL';
Upvotes: 0
Views: 892
Reputation: 13259
After adding it to composer.json, import it to your class with use
keyword. Change this
namespace ECPaySDK;
To
use ECPaySDK\ECPay_AllInOne;
In the format NAMESPACE\CLASSNAME;
For this to work, go at the top of your file and define a namespace. It seems there is no namespace for now. You can define like this
namespace ECPaySDK;
So depending on the class you want to use, prefix it with ECPaySDK
namespace. Assuming you put your your SDK directory at the root of your application.
Update
You have a single file with multiple class declarations. Go to your composer file in the autoload part, just below "psr-4"
create a new entry called files
.
"files": [
"ECPaySDK/ECPaymentIntegration.php"
]
Then run composer dumpautoload
Upvotes: 1