为了账号安全,请及时绑定邮箱和手机立即绑定

在 laravel 7 中找不到类 'SimpleSoftwareIO\QrCode\QrCode

在 laravel 7 中找不到类 'SimpleSoftwareIO\QrCode\QrCode

PHP
肥皂起泡泡 2023-05-26 09:57:45
我的 php 版本是 7.4,laravel 版本是 7.0'providers' => [SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class,],别名'aliases' => ['QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class,],在我的 composer.json 文件中"require": {    "php": "^7.2.5",    "fideloper/proxy": "^4.2",    "fruitcake/laravel-cors": "^1.0",    "guzzlehttp/guzzle": "^6.3",    "laravel/framework": "^7.0",    "laravel/tinker": "^2.0",    "simplesoftwareio/simple-qrcode": "^3.0"},添加别名后,提供者无法在 laravel 根路径中运行任何命令,它会显示如下错误In ProviderRepository.php line 208: Class 'SimpleSoftwareIO\QrCode\QrCodeServiceProvider' not foundPHP拉维
查看完整描述

5 回答

?
尚方宝剑之说

TA贡献1788条经验 获得超4个赞

我使用 Laravel7 并找到了解决方案。安装 QR“simplesoftwareio/simple-qrcode”后:“^3.0”

  1. (不要在 config/app.php 中添加这个)'providers' 和 'aliases' 在 config/app.php

#'providers' => [SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class,],
#'aliases' => ['QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class,],
  1. 尝试在刀片模板 test.blade.php 中添加 qr

{!! QrCode::size(250)->generate('www.google.com'); !!}
  1. 它对我有用


查看完整回答
反对 回复 2023-05-26
?
千巷猫影

TA贡献1829条经验 获得超7个赞

config\app.php在这样的更新下:

供应商:

SimpleSoftwareIO\QrCode\ServiceProvider::class,

别名:

'QrCode' => SimpleSoftwareIO\QrCode\Facade::class,

或者删除此提供程序和 .


查看完整回答
反对 回复 2023-05-26
?
幕布斯7119047

TA贡献1794条经验 获得超8个赞

没有一个答案对我有用。以下是我如何使用 PHP8 在 Laravel 9 上修复它。

首先,我们必须安装 PHP GD 库。

sudo apt-get install php-gd

安装 Simple QRcodde 版本 4 或更高版本。

composer require simplesoftwareio/simple-qrcode "~4" --with-all-dependencies

无需更改 config/app.php。

我们可以简单地在刀片视图文件上使用它:

{!! QrCode::size(250)->generate('mailto:SampathPerera@hotmail.com'); !!}


查看完整回答
反对 回复 2023-05-26
?
白猪掌柜的

TA贡献1893条经验 获得超10个赞

首先使用此命令安装作曲家


composer require simplesoftwareio/simple-qrcode

在您的 web.php 文件中添加以下内容


    Route::get('qr-code-g', function () {

    \QrCode::size(500)

            ->format('png')

            ->generate('www.google.com', public_path('images/qrcode.png'));

return view('qrCode');

});

在名为qrcode.blade.php的刀片文件中必须如下所示


<!DOCTYPE html>

<html>

    <head>

        <title>QR code Generator</title>

    </head>

<body>

    <div class="visible-print text-center">

        <h1>Laravel 7 - QR Code Generator Example</h1> 

        {!! QrCode::size(250)->generate('www.google.com'); !!} 

    </div>

</body>

</html>

使用 laravel 7 时无需在config/app.php中添加别名和提供者


需要运行以下命令来安装 imagemagick


sudo apt-get update


sudo apt-get install -y imagemagick php-imagick

您可以检查安装以运行命令


php -m | grep imagick

如果安装成功,会显示如下


imagick

然后,需要重新启动您的 apache 服务器或重新启动您的系统它会正常工作。


查看完整回答
反对 回复 2023-05-26
?
紫衣仙女

TA贡献1839条经验 获得超15个赞

在命令行上执行composer dump-autoload,你可以从别名调用\QrCode::method()



查看完整回答
反对 回复 2023-05-26
  • 5 回答
  • 0 关注
  • 290 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信