SymfonyのTWIGテンプレートにURLを入力することで、QRコードを動的に作りたいと思っています。私はendroid/QrCodeバンドルをインストールしても問題ありませんが、TWIGにQRコードイメージを作成する方法がわかりません! GitHubのページからそうsymfonyのTWIGでのエンドウンドQrコード
、それはTWIGがあるために言うすべて:
<img src="{{ qrcode_url('http://www.test.com') }}" />
:
Twig extension
The bundle provides a Twig extension for generating a QR code URL, path or data URI. You can use the second argument of any of these functions to override any defaults defined by the bundle or set via your configuration.
<img src="{{ qrcode_path(message) }}" />
<img src="{{ qrcode_url(message, { writer: 'eps' }) }}" />
<img src="{{ qrcode_data_uri(message, { writer: 'svg', size: 150 }) }}" />
だから私はテストのために考え出し、一番簡単な方法は、のようなものになるだろう
ただし、これによりエラーが発生します。
An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "endroid_qrcode_generate" as such route does not exist.").
誰でもこの作業のためにTWIG拡張を取得しましたか?それはdocumentation
Add the following section to your routing to be able to handle QR code URLs. This step can be skipped if you only use data URIs to display your images.
に記載されているよう
あなたは 'Symfony'の権利にバンドルを登録しましたか? – DarkBee
確かに、AppKernel.phpでどうしたのか分からない場合は、関数を探す場所が分からないと思っています。qrcode_url – MicWit
[QrController](https://github.com/)でルートが定義されています。あなたのキャッシュをクリアしましたか? – DarkBee