本文介绍了向Laravel添加第三方库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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 7Laravel 5.5上使用jpgraph 4.1.

I am using jpgraph 4.1 on Laravel 5.5 using PHP 7.

  1. 在应用程序下创建一个名为jpgraph
  2. 的文件夹
  3. 将jpgraph压缩包中的src文件夹放置在该文件夹中
  4. 创建的文件调用Graph1.php是我使用jpgraph的代码,在jpgraph文件夹中具有类Custom_GraphsJM.
  5. composer.json中将"app/jpgraph/Graph1.php"添加到"classmap"

  1. Created a folder under app called jpgraph
  2. Placed the src folder that is in the tarball of jpgraph in that folder
  3. Created file call Graph1.php, is my code using jpgraph, with the class Custom_GraphsJM in the jpgraph folder.
  4. 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添加第三方库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 07-18 12:50