|
| 1 | +Simple QrCode |
| 2 | +======================== |
| 3 | + |
| 4 | +[](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode) |
| 5 | +[](https://packagist.org/packages/simplesoftwareio/simple-qrcode) |
| 6 | +[](https://packagist.org/packages/simplesoftwareio/simple-qrcode) |
| 7 | +[](https://packagist.org/packages/simplesoftwareio/simple-qrcode) |
| 8 | +[](https://packagist.org/packages/simplesoftwareio/simple-qrcode) |
| 9 | + |
| 10 | +#### [Español](https://www.simplesoftware.io/simple-qrcode/es) | [Français](https://www.simplesoftware.io/simple-qrcode/fr) | [Italiano](https://www.simplesoftware.io/simple-qrcode/it) | [Português](https://www.simplesoftware.io/simple-qrcode/pt-br) | [Русский](https://www.simplesoftware.io/simple-qrcode/ru) | [हिंदी](https://www.simplesoftware.io/simple-qrcode/hi) | [汉语](https://www.simplesoftware.io/simple-qrcode/zh) |
| 11 | + |
| 12 | +- [Introduction](#docs-introduction) |
| 13 | +- [Translations](#docs-translations) |
| 14 | +- [Configuration](#docs-configuration) |
| 15 | +- [Simple Ideas](#docs-ideas) |
| 16 | +- [Usage](#docs-usage) |
| 17 | +- [Helpers](#docs-helpers) |
| 18 | +- [Common QrCode Usage](#docs-common-usage) |
| 19 | +- [Usage Outside of Laravel](#docs-outside-laravel) |
| 20 | + |
| 21 | +<a id="docs-introduction"></a> |
| 22 | +## イントロダクション |
| 23 | +Simple QrCode は [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode)を元に作られた 人気のあるLaravelフレームワークで簡単に使う事のできるラッパーです。 |
| 24 | + |
| 25 | + |
| 26 | +Simple QrCode is an easy to use wrapper for the popular Laravel framework based on the great work provided by [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode). We created an interface that is familiar and easy to install for Laravel users. |
| 27 | + |
| 28 | +<a id="docs-translations"></a> |
| 29 | +## 翻訳 |
| 30 | +この文書の翻訳を手伝ってくれるアラビア語、スペイン語、フランス語、韓国語、日本語を話すユーザーを探しています。 翻訳が可能な場合はプルリクエストを作成してください。 |
| 31 | + |
| 32 | +We are looking for users who speak Arabic, Spanish, French, Korean or Japanese to help translate this document. Please create a pull request if you are able to make a translation! |
| 33 | + |
| 34 | +<a id="docs-configuration"></a> |
| 35 | +## 設定 |
| 36 | + |
| 37 | +#### Composer |
| 38 | +最初にあなたの `composer.json` に Simple QrCode パッケージを追加する必要があります。 |
| 39 | + |
| 40 | + "require": { |
| 41 | + "simplesoftwareio/simple-qrcode": "~2" |
| 42 | + } |
| 43 | +追加したら `composer update` コマンドを実行します。 |
| 44 | + |
| 45 | +#### サービスプロバイダー |
| 46 | + |
| 47 | +###### Laravel <= 5.4 |
| 48 | +(あなたが Simple QrCode を入れる laravelの) `config/app.php` の `providers`配列 に `SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class` を登録します。 |
| 49 | + |
| 50 | +#### Aliases |
| 51 | + |
| 52 | +###### Laravel <= 5.4 |
| 53 | +最後に `config/app.php` の `aliases`配列に `'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class` を登録します。 |
| 54 | + |
| 55 | +<a id="docs-ideas"></a> |
| 56 | +## かんたんに使う |
| 57 | + |
| 58 | +#### 画面に表示する |
| 59 | + |
| 60 | +このパッケージの主なアイテムは 画面に表示する機能です。 |
| 61 | +カスタマーはコードをスキャンするだけで 画面に戻ることが出来ます。以下の内容をfooter.blade.php に追加しました。 |
| 62 | + <div class="visible-print text-center"> |
| 63 | + {!! QrCode::size(100)->generate(Request::url()); !!} |
| 64 | + <p>Scan me to return to the original page.</p> |
| 65 | + </div> |
| 66 | + |
| 67 | +#### QrCodeを埋め込む |
| 68 | + |
| 69 | +ユーザーがすばやくスキャンできるように、電子メールの中にqrcodeを埋め込むことができます。 以下はLaravelでこれを行う方法の例です。 |
| 70 | + |
| 71 | + //Inside of a blade template. |
| 72 | + <img src="{!!$message->embedData(QrCode::format('png')->generate('Embed me into an e-mail!'), 'QrCode.png', 'image/png')!!}"> |
| 73 | + |
| 74 | +<a id="docs-usage"></a> |
| 75 | +## Usage |
| 76 | + |
| 77 | +#### 基本的な使い方 |
| 78 | + |
| 79 | +QrCode Generatorを使うのはとても簡単です。 最も基本的な構文は次のとおりです。 |
| 80 | + |
| 81 | + QrCode::generate('Make me into a QrCode!'); |
| 82 | + |
| 83 | +これで「Make me into a QrCode!」というQrCodeが作成されます。 |
| 84 | + |
| 85 | +#### 生成する |
| 86 | + |
| 87 | +`Generate`はQrCodeを作るのに使われます。 |
| 88 | + |
| 89 | + QrCode::generate('Make me into a QrCode!'); |
| 90 | + |
| 91 | +>要注意: チェーン内で使用する場合は、このメソッドを最後に呼び出す必要があります。 |
| 92 | +
|
| 93 | +`Generate`はデフォルトで SVG イメージ文字列を返します。 |
| 94 | +Laravel Bladeに以下の様に書くことで モダンなブラウザに表示することができます。 |
| 95 | + |
| 96 | + {!! QrCode::generate('Make me into a QrCode!'); !!} |
| 97 | + |
| 98 | +`generate`メソッドの第二引数はQrCodeを保存するパスとファイルネームです。 |
| 99 | + |
| 100 | + QrCode::generate('Make me into a QrCode!', '../public/qrcodes/qrcode.svg'); |
| 101 | + |
| 102 | +#### フォーマットを変える |
| 103 | + |
| 104 | +>QrCode Generator のデフォルトフォーマットはSVGイメージです。 |
| 105 | +
|
| 106 | +>要注意: `format`メソッドは` size`、 `color`、` backgroundColor`、 `margin`のような他のフォーマットオプションの前に呼ばれなければなりません。 |
| 107 | +
|
| 108 | +現在PNG、EPS、およびSVGの 3つのフォーマットがサポートされています。 |
| 109 | +フォーマットを変更するには、次のコードを使用します。 |
| 110 | + |
| 111 | + QrCode::format('png'); //Will return a PNG image |
| 112 | + QrCode::format('eps'); //Will return a EPS image |
| 113 | + QrCode::format('svg'); //Will return a SVG image |
| 114 | + |
| 115 | +#### サイズの変更 |
| 116 | + |
| 117 | +>QrCode GeneratorはデフォルトでQrCodeを作成するためにピクセルで可能な最小サイズを返します。 |
| 118 | +
|
| 119 | +`size`メソッドを使うことでQrCodeのサイズを変えることができます。 次の構文を使用して、必要なサイズをピクセル単位で指定します。 |
| 120 | + |
| 121 | + QrCode::size(100); |
| 122 | + |
| 123 | +#### 色の変更 |
| 124 | + |
| 125 | +>要注意 色を変えるときには注意してください。QrCodeの読み込みが難しくなる 色が有ります。 |
| 126 | +
|
| 127 | +すべての色はRGB (Red Green Blue)で表現する必要があります。 次のようにしてQrCodeの色を変更できます: |
| 128 | + |
| 129 | + QrCode::color(255,0,255); |
| 130 | + |
| 131 | +背景色の変更もサポートされており、同じ方法で表現できます。 |
| 132 | + |
| 133 | + QrCode::backgroundColor(255,255,0); |
| 134 | + |
| 135 | +#### マージンの変更 |
| 136 | + |
| 137 | +QrCode周辺のマージンを変更する機能もサポートされています。 次の構文を使用してマージンを指定します: |
| 138 | + QrCode::margin(100); |
| 139 | + |
| 140 | +#### Error Correction |
| 141 | + |
| 142 | +Changing the level of error correction is easy. Just use the following syntax: |
| 143 | + |
| 144 | + QrCode::errorCorrection('H'); |
| 145 | + |
| 146 | +The following are supported options for the `errorCorrection` method. |
| 147 | + |
| 148 | +| Error Correction | Assurance Provided | |
| 149 | +| --- | --- | |
| 150 | +| L | 7% of codewords can be restored. | |
| 151 | +| M | 15% of codewords can be restored. | |
| 152 | +| Q | 25% of codewords can be restored. | |
| 153 | +| H | 30% of codewords can be restored. | |
| 154 | + |
| 155 | +>The more error correction used; the bigger the QrCode becomes and the less data it can store. Read more about [error correction](http://en.wikipedia.org/wiki/QR_code#Error_correction). |
| 156 | +
|
| 157 | +#### Encoding |
| 158 | + |
| 159 | +Change the character encoding that is used to build a QrCode. By default `ISO-8859-1` is selected as the encoder. Read more about [character encoding](http://en.wikipedia.org/wiki/Character_encoding) You can change this to any of the following: |
| 160 | + |
| 161 | + QrCode::encoding('UTF-8')->generate('Make me a QrCode with special symbols ♠♥!!'); |
| 162 | + |
| 163 | +| Character Encoder | |
| 164 | +| --- | |
| 165 | +| ISO-8859-1 | |
| 166 | +| ISO-8859-2 | |
| 167 | +| ISO-8859-3 | |
| 168 | +| ISO-8859-4 | |
| 169 | +| ISO-8859-5 | |
| 170 | +| ISO-8859-6 | |
| 171 | +| ISO-8859-7 | |
| 172 | +| ISO-8859-8 | |
| 173 | +| ISO-8859-9 | |
| 174 | +| ISO-8859-10 | |
| 175 | +| ISO-8859-11 | |
| 176 | +| ISO-8859-12 | |
| 177 | +| ISO-8859-13 | |
| 178 | +| ISO-8859-14 | |
| 179 | +| ISO-8859-15 | |
| 180 | +| ISO-8859-16 | |
| 181 | +| SHIFT-JIS | |
| 182 | +| WINDOWS-1250 | |
| 183 | +| WINDOWS-1251 | |
| 184 | +| WINDOWS-1252 | |
| 185 | +| WINDOWS-1256 | |
| 186 | +| UTF-16BE | |
| 187 | +| UTF-8 | |
| 188 | +| ASCII | |
| 189 | +| GBK | |
| 190 | +| EUC-KR | |
| 191 | + |
| 192 | +>An error of `Could not encode content to ISO-8859-1` means that the wrong character encoding type is being used. We recommend `UTF-8` if you are unsure. |
| 193 | +
|
| 194 | +#### Merge |
| 195 | + |
| 196 | +The `merge` method merges an image over a QrCode. This is commonly used to placed logos within a QrCode. |
| 197 | + |
| 198 | + QrCode::merge($filename, $percentage, $absolute); |
| 199 | + |
| 200 | + //Generates a QrCode with an image centered in the middle. |
| 201 | + QrCode::format('png')->merge('path-to-image.png')->generate(); |
| 202 | + |
| 203 | + //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. |
| 204 | + QrCode::format('png')->merge('path-to-image.png', .3)->generate(); |
| 205 | + |
| 206 | + //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. |
| 207 | + QrCode::format('png')->merge('http://www.google.com/someimage.png', .3, true)->generate(); |
| 208 | + |
| 209 | +>The `merge` method only supports PNG at this time. |
| 210 | +>The filepath is relative to app base path if `$absolute` is set to `false`. Change this variable to `true` to use absolute paths. |
| 211 | +
|
| 212 | +>You should use a high level of error correction when using the `merge` method to ensure that the QrCode is still readable. We recommend using `errorCorrection('H')`. |
| 213 | +
|
| 214 | + |
| 215 | + |
| 216 | +#### Merge Binary String |
| 217 | + |
| 218 | +The `mergeString` method can be used to achieve the same as the `merge` call, except it allows you to provide a string representation of the file instead of the filepath. This is usefull when working with the `Storage` facade. It's interface is quite similar to the `merge` call. |
| 219 | + |
| 220 | + QrCode::mergeString(Storage::get('path/to/image.png'), $percentage); |
| 221 | + |
| 222 | + //Generates a QrCode with an image centered in the middle. |
| 223 | + QrCode::format('png')->mergeString(Storage::get('path/to/image.png'))->generate(); |
| 224 | + |
| 225 | + //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. |
| 226 | + QrCode::format('png')->mergeString(Storage::get('path/to/image.png'), .3)->generate(); |
| 227 | + |
| 228 | +>As with the normal `merge` call, only PNG is supported at this time. The same applies for error correction, high levels are recommened. |
| 229 | +
|
| 230 | +#### Advance Usage |
| 231 | + |
| 232 | +All methods support chaining. The `generate` method must be called last and any `format` change must be called first. For example you could run any of the following: |
| 233 | + |
| 234 | + QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate('Make me a QrCode!'); |
| 235 | + QrCode::format('png')->size(399)->color(40,40,40)->generate('Make me a QrCode!'); |
| 236 | + |
| 237 | +You can display a PNG image without saving the file by providing a raw string and encoding with `base64_encode`. |
| 238 | + |
| 239 | + <img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(100)->generate('Make me into an QrCode!')) !!} "> |
| 240 | + |
| 241 | +<a id="docs-helpers"></a> |
| 242 | +## Helpers |
| 243 | + |
| 244 | +#### What are helpers? |
| 245 | + |
| 246 | +Helpers are an easy way to create QrCodes that cause a reader to perform a certain action when scanned. |
| 247 | + |
| 248 | +#### BitCoin |
| 249 | + |
| 250 | +This helpers generates a scannable bitcoin to send payments. [More information](https://bitco.in/en/developer-guide#plain-text) |
| 251 | + |
| 252 | + QrCode::BTC($address, $amount); |
| 253 | + |
| 254 | + //Sends a 0.334BTC payment to the address |
| 255 | + QrCode::BTC('bitcoin address', 0.334); |
| 256 | + |
| 257 | + //Sends a 0.334BTC payment to the address with some optional arguments |
| 258 | + QrCode::size(500)->BTC('address', 0.0034, [ |
| 259 | + 'label' => 'my label', |
| 260 | + 'message' => 'my message', |
| 261 | + 'returnAddress' => 'https://www.returnaddress.com' |
| 262 | + ]); |
| 263 | + |
| 264 | +#### E-Mail |
| 265 | + |
| 266 | +This helper generates an e-mail qrcode that is able to fill in the e-mail address, subject, and body. |
| 267 | + |
| 268 | + QrCode::email($to, $subject, $body); |
| 269 | + |
| 270 | + //Fills in the to address |
| 271 | + QrCode::email('foo@bar.com'); |
| 272 | + |
| 273 | + //Fills in the to address, subject, and body of an e-mail. |
| 274 | + QrCode::email('foo@bar.com', 'This is the subject.', 'This is the message body.'); |
| 275 | + |
| 276 | + //Fills in just the subject and body of an e-mail. |
| 277 | + QrCode::email(null, 'This is the subject.', 'This is the message body.'); |
| 278 | + |
| 279 | +#### Geo |
| 280 | + |
| 281 | +This helper generates a latitude and longitude that a phone can read and open the location up in Google Maps or similar app. |
| 282 | + |
| 283 | + QrCode::geo($latitude, $longitude); |
| 284 | + |
| 285 | + QrCode::geo(37.822214, -122.481769); |
| 286 | + |
| 287 | +#### Phone Number |
| 288 | + |
| 289 | +This helper generates a QrCode that can be scanned and then dials a number. |
| 290 | + |
| 291 | + QrCode::phoneNumber($phoneNumber); |
| 292 | + |
| 293 | + QrCode::phoneNumber('555-555-5555'); |
| 294 | + QrCode::phoneNumber('1-800-Laravel'); |
| 295 | + |
| 296 | +#### SMS (Text Messages) |
| 297 | + |
| 298 | +This helper makes SMS messages that can be prefilled with the send to address and body of the message. |
| 299 | + |
| 300 | + QrCode::SMS($phoneNumber, $message); |
| 301 | + |
| 302 | + //Creates a text message with the number filled in. |
| 303 | + QrCode::SMS('555-555-5555'); |
| 304 | + |
| 305 | + //Creates a text message with the number and message filled in. |
| 306 | + QrCode::SMS('555-555-5555', 'Body of the message'); |
| 307 | + |
| 308 | +#### WiFi |
| 309 | + |
| 310 | +This helpers makes scannable QrCodes that can connect a phone to a WiFI network. |
| 311 | + |
| 312 | + QrCode::wiFi([ |
| 313 | + 'encryption' => 'WPA/WEP', |
| 314 | + 'ssid' => 'SSID of the network', |
| 315 | + 'password' => 'Password of the network', |
| 316 | + 'hidden' => 'Whether the network is a hidden SSID or not.' |
| 317 | + ]); |
| 318 | + |
| 319 | + //Connects to an open WiFi network. |
| 320 | + QrCode::wiFi([ |
| 321 | + 'ssid' => 'Network Name', |
| 322 | + ]); |
| 323 | + |
| 324 | + //Connects to an open, hidden WiFi network. |
| 325 | + QrCode::wiFi([ |
| 326 | + 'ssid' => 'Network Name', |
| 327 | + 'hidden' => 'true' |
| 328 | + ]); |
| 329 | + |
| 330 | + //Connects to an secured, WiFi network. |
| 331 | + QrCode::wiFi([ |
| 332 | + 'ssid' => 'Network Name', |
| 333 | + 'encryption' => 'WPA', |
| 334 | + 'password' => 'myPassword' |
| 335 | + ]); |
| 336 | + |
| 337 | +>WiFi scanning is not currently supported on Apple Products. |
| 338 | +
|
| 339 | +<a id="docs-common-usage"></a> |
| 340 | +## Common QrCode Usage |
| 341 | + |
| 342 | +You can use a prefix found in the table below inside the `generate` section to create a QrCode to store more advanced information: |
| 343 | + |
| 344 | + QrCode::generate('http://www.simplesoftware.io'); |
| 345 | + |
| 346 | + |
| 347 | +| Usage | Prefix | Example | |
| 348 | +| --- | --- | --- | |
| 349 | +| Website URL | http:// | http://www.simplesoftware.io | |
| 350 | +| Secured URL | https:// | https://www.simplesoftware.io | |
| 351 | +| E-mail Address | mailto: | mailto:support@simplesoftware.io | |
| 352 | +| Phone Number | tel: | tel:555-555-5555 | |
| 353 | +| Text (SMS) | sms: | sms:555-555-5555 | |
| 354 | +| Text (SMS) With Pretyped Message | sms: | sms::I am a pretyped message | |
| 355 | +| Text (SMS) With Pretyped Message and Number | sms: | sms:555-555-5555:I am a pretyped message | |
| 356 | +| Geo Address | geo: | geo:-78.400364,-85.916993 | |
| 357 | +| MeCard | mecard: | MECARD:Simple, Software;Some Address, Somewhere, 20430;TEL:555-555-5555;EMAIL:support@simplesoftware.io; | |
| 358 | +| VCard | BEGIN:VCARD | [See Examples](https://en.wikipedia.org/wiki/VCard) | |
| 359 | +| Wifi | wifi: | wifi:WEP/WPA;SSID;PSK;Hidden(True/False) | |
| 360 | + |
| 361 | +<a id="docs-outside-laravel"></a> |
| 362 | +## Usage Outside of Laravel |
| 363 | + |
| 364 | +You may use this package outside of Laravel by instantiating a new `BaconQrCodeGenerator` class. |
| 365 | + |
| 366 | + use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator; |
| 367 | + |
| 368 | + $qrcode = new BaconQrCodeGenerator; |
| 369 | + $qrcode->size(500)->generate('Make a qrcode without Laravel!'); |
0 commit comments