I created a custom module and installed the endroid/qrcode library in my module using Composer. When I try to use that library, I get the following error.
Error: Class ‘EndroidQrCodeQrCode’ not found in DrupalshopexpPluginBlockShopExp->build() (line 25 of modulescustomshopexpsrcPluginBlockShopExp.php).
The code using the library is the following one.
namespace DrupalshopexpPluginBlock;
use DrupalCoreBlockBlockBase;
use EndroidQrCodeQrCode;
class ShopExp extends BlockBase {
public function createpr() {
$qr = QrCode::create("https://site.com");
}
public function build() {
$qr = new QrCode();
return [
'#markup' => 'test msg',
];
}
}
The composer.json file used by the module is the following one.
{
"require": {
"endroid/qr-code": "^2.5"
}
}
The folder structure is the following one.