问题描述
我有一个RSA算法库,由支付网关提供给我,而当我执行
I have an RSA algorithm Library giving to me by a payment gateway and When I do a
include (app_path().'/PaymentGateway/Crypt/RSA.php');
这并尝试将对象制作为$rsa = new Crypt_RSA();
,这给了我并且错误提示
this and try to make an object as $rsa = new Crypt_RSA();
this it gives me and error saying
Class 'App\Http\Controllers\Crypt_RSA' not found
我尝试将其包含在web.php
中,并使对象能够正常工作,当我尝试将其包含在Controller中时,就会出现问题.
I tried including it in web.php
and making an object it worked the problem occur when I try to include it in a Controller.
推荐答案
这就是我所做的.哦,还有一点背景,我曾经在Laravel 4,PHP 5,jpgraph 2中使用过.
This is what I did. Oh and a little back ground I use to have this in Laravel 4, PHP 5, jpgraph 2.
我正在使用PHP 7
在Laravel 5.5
上使用jpgraph 4.1
.
I am using jpgraph 4.1
on Laravel 5.5
using PHP 7
.
- 在应用程序下创建一个名为
jpgraph
的文件夹 - 将jpgraph压缩包中的
src
文件夹放置在该文件夹中 - 创建的文件调用
Graph1.php
是我使用jpgraph的代码,在jpgraph
文件夹中具有类Custom_GraphsJM
. -
在
composer.json
中将"app/jpgraph/Graph1.php"
添加到"classmap"
- Created a folder under app called
jpgraph
- Placed the
src
folder that is in the tarball of jpgraph in that folder - Created file call
Graph1.php
, is my code using jpgraph, with the classCustom_GraphsJM
in thejpgraph
folder. In
composer.json
added"app/jpgraph/Graph1.php"
to the"classmap"
"autoload": {
"classmap": [
"database/seeds",
"database/factories",
"app/jpgraph/Graph1.php"
],
"psr-4": {
"App\\": "app/"
}
},
在应用程序文件夹中:
In the application folder:
composer dump-autoload
检查了autoload_classmap.php
并且我有
'Custom_GraphsJM' => $baseDir . '/app/jpgraph/Graph1.php',
在顶部的模型中,我有
use Custom_GraphsJM;
要创建一个类
$Two_Graphs_Temp = new Custom_GraphsJM();
这篇关于向Laravel添加第三方库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!