1. Define a class QrCode.php
under app\Libraires<?php
/**
* Created by PhpStorm.
* User: AIMPER
* Date: 2016/11/30
* Time: 10:13
*/
namespace App\Libaries;
use Endroid\QrCode;
use Illuminate\Support\Facades\DB;
class QrCode{
public static function generateQrCode($type = null, $id = null){
$code = random_string(32,true);
$create_date = time();
$expires = 0;
$qrcodeType = DB::table('qrcode_type')->where('id','=',$type)->select('code','params')-first();
return $qrcodeType;
}
}
2. Call the method of this class
...
use App\Libaries\QrCode;
class TestController extends Controller{
public function index(){
QrCode::generateQrCode(11,1);
}
}
3. Error message
ReflectionException in Route.php line 286:
Class App\Libaries\QrCode does not exist
4. Solution attempt
I have used composer dump-autoload, but the class still cannot be loaded. How can I automatically load custom classes into the project?
Classes obtained through dependency injection in routing need to be registered with the container.
Check the settings of the composer.json file in the project root directory.
And the error occurred during the route definition process. You need to check the settings of route.php