|
| 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 | +[Русский](https://www.simplesoftware.io/docs/simple-qrcode/ru) | |
| 10 | +[汉语](https://www.simplesoftware.io/docs/simple-qrcode/zh) |
| 11 | + |
| 12 | +- [Introdução](#docs-introduction) |
| 13 | +- [Traduções](#docs-translations) |
| 14 | +- [Configuração](#docs-configuration) |
| 15 | +- [Simples ideias](#docs-ideas) |
| 16 | +- [Uso](#docs-usage) |
| 17 | +- [Ajuda](#docs-helpers) |
| 18 | +- [Uso comum do QrCode](#docs-common-usage) |
| 19 | +- [Uso sem Laravel](#docs-outside-laravel) |
| 20 | + |
| 21 | +<a id="docs-introduction"></a> |
| 22 | +## Introdução |
| 23 | +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. |
| 24 | + |
| 25 | +<a id="docs-translations"></a> |
| 26 | +## Traduções |
| 27 | +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! |
| 28 | + |
| 29 | +<a id="docs-configuration"></a> |
| 30 | +## Configuração |
| 31 | + |
| 32 | +#### Composer |
| 33 | + |
| 34 | +Primeiramente, adicione o pacote Simple QrCode ao seu `require` no arquivo `composer.json`: |
| 35 | + |
| 36 | + "require": { |
| 37 | + "simplesoftwareio/simple-qrcode": "~1" |
| 38 | + } |
| 39 | + |
| 40 | +Próximo, execute o comando `composer update`. |
| 41 | + |
| 42 | +#### Provedor de Serviço |
| 43 | + |
| 44 | +###### Laravel 4 |
| 45 | +Registre o `SimpleSoftwareIO\QrCode\QrCodeServiceProvider` em seu `app/config/app.php` dentro do array`providers`. |
| 46 | + |
| 47 | +###### Laravel 5 |
| 48 | +Registre a `SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class` em seu `config/app.php` dentro do array `providers`. |
| 49 | + |
| 50 | +#### Aliases |
| 51 | + |
| 52 | +###### Laravel 4 |
| 53 | +Finalmente, registre o `'QrCode' => 'SimpleSoftwareIO\QrCode\Facades\QrCode'` em seu arquivo de configuração `app/config/app.php` dentro do array `aliases`. |
| 54 | + |
| 55 | +###### Laravel 5 |
| 56 | +Finally, register the `'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class` em seu arquivo de configuração `config/app.php` dentro do array `aliases`. |
| 57 | + |
| 58 | +<a id="docs-ideas"></a> |
| 59 | +## Simple Ideas |
| 60 | + |
| 61 | +#### Print View |
| 62 | + |
| 63 | +One of the main items that we use this package for is to have QrCodes in all of our print views. This allows our customers to return to the original page after it is printed by simply scanning the code. We achieved this by adding the following into our footer.blade.php file. |
| 64 | + |
| 65 | + <div class="visible-print text-center"> |
| 66 | + {!! QrCode::size(100)->generate(Request::url()); !!} |
| 67 | + <p>Scan me to return to the original page.</p> |
| 68 | + </div> |
| 69 | + |
| 70 | +#### Embarcando um QrCode |
| 71 | + |
| 72 | +Você pode incorporar um qrcode dentro de um e-mail, que permita que seus usuários escaneiem rapidamente. Abaixo, um exemplo de como fazer isso utilizando o Laravel. |
| 73 | + |
| 74 | + //Inside of a blade template. |
| 75 | + <img src="{!!$message->embedData(QrCode::format('png')->generate('Embed me into an e-mail!'), 'QrCode.png', 'image/png')!!}"> |
| 76 | + |
| 77 | +<a id="docs-usage"></a> |
| 78 | +## Uso |
| 79 | + |
| 80 | +#### Uso Básico |
| 81 | + |
| 82 | +É muito fácil utilizar o gerador de Qrcode. A sintaxe mais básica é: |
| 83 | + |
| 84 | + QrCode::generate('Me transforme em um QrCode!'); |
| 85 | + |
| 86 | +Isso criará um Qr que diz "Me transforme em um QrCode!" |
| 87 | + |
| 88 | +#### Generate |
| 89 | + |
| 90 | +`Generate` é usado para criar o QrCode. |
| 91 | + |
| 92 | + QrCode::generate('Me transforme em um QrCode!'); |
| 93 | + |
| 94 | +>Atenção! Esse método deve ser chamado por último dentro da cadeia. |
| 95 | +
|
| 96 | +`Generate` por padrão irá retornar uma string de imagem SVG. Você pode exibir diretamente em seu browser, utilizando o Laravel's Blade com o código abaixo: |
| 97 | + |
| 98 | + {!! QrCode::generate('Me transforme em um QrCode!'); !!} |
| 99 | + |
| 100 | +O método `generate` tem um segundo parametro que aceita um arquivo e um path para salvar o Qrcode. |
| 101 | + |
| 102 | + QrCode::generate('Me transforme em um QrCode!', '../public/qrcodes/qrcode.svg'); |
| 103 | + |
| 104 | +#### Alteração de Formato |
| 105 | + |
| 106 | +>Por padrão o gerador de QrCode está configurado para retornar uma imagem SVG. |
| 107 | +
|
| 108 | +>Cuidao! O método `format` deve ser chamado antes de qualquer outra opção de formatação como `size`, `color`, `backgroundColor` e `margin`. |
| 109 | +
|
| 110 | +Atualmente são suportados três tipos de formatos; PNG, EPS, and SVG. Para alterar o formato, use o seguinte código: |
| 111 | + |
| 112 | + QrCode::format('png'); //Retornará uma imagem no formato PNG |
| 113 | + QrCode::format('eps'); //Retornará uma imagem no formato EPS |
| 114 | + QrCode::format('svg'); //Retornará uma imagem no formato SVG |
| 115 | + |
| 116 | +#### Alteração de Tamanho |
| 117 | + |
| 118 | +>Por padrão, o gerador QrCode retornará o menos tamanho possível em pixels para criar o QrCode. |
| 119 | +
|
| 120 | +Você pode alterar o tamanho do QrCode usando o método `size`. Simplesmente especificando o tamanho desejado em pixels usando a seguinte sintaze: |
| 121 | + |
| 122 | + QrCode::size(100); |
| 123 | + |
| 124 | +#### Alteração de cor |
| 125 | + |
| 126 | +>Cuidado quando estiver alterando a cor de um QRCode. Alguns leitores tem uma grande dificuldade em ler QrCodes coloridos. |
| 127 | +
|
| 128 | +Todas as cores devem ser definidas em RGB(Red Green Blue). Você pode alterar a cor de um qrCode usando o código abaixo. You can change the color of a QrCode by using the following: |
| 129 | + |
| 130 | + QrCode::color(255,0,255); |
| 131 | + |
| 132 | +Alterações do plano de fundo também são suportadas e definidas da mesma maneira. |
| 133 | + |
| 134 | + QrCode::backgroundColor(255,255,0); |
| 135 | + |
| 136 | +#### Alteração de Margem |
| 137 | + |
| 138 | +A capacidade de alterar a margem ao redor do QrCode também é suportada. Simplesmente especifique o tamenho desejado da margem, utilizando a sintaxe abaixo: |
| 139 | + |
| 140 | + QrCode::margin(100); |
| 141 | + |
| 142 | +#### Correção de erros |
| 143 | + |
| 144 | +Alterar o nível de correção de erros é simples. Utilize a seguinte sintaxe: |
| 145 | + |
| 146 | + QrCode::errorCorrection('H'); |
| 147 | + |
| 148 | +As seguintes opções são suportadas para o método `errorCorrection`. |
| 149 | + |
| 150 | +| Error Correction | Assurance Provided | |
| 151 | +| --- | --- | |
| 152 | +| L | 7% of codewords can be restored. | |
| 153 | +| M | 15% of codewords can be restored. | |
| 154 | +| Q | 25% of codewords can be restored. | |
| 155 | +| H | 30% of codewords can be restored. | |
| 156 | + |
| 157 | +>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). |
| 158 | +
|
| 159 | +#### Encoding |
| 160 | + |
| 161 | +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: |
| 162 | + |
| 163 | + QrCode::encoding('UTF-8')->generate('Make me a QrCode with special symbols ♠♥!!'); |
| 164 | + |
| 165 | +| Character Encoder | |
| 166 | +| --- | |
| 167 | +| ISO-8859-1 | |
| 168 | +| ISO-8859-2 | |
| 169 | +| ISO-8859-3 | |
| 170 | +| ISO-8859-4 | |
| 171 | +| ISO-8859-5 | |
| 172 | +| ISO-8859-6 | |
| 173 | +| ISO-8859-7 | |
| 174 | +| ISO-8859-8 | |
| 175 | +| ISO-8859-9 | |
| 176 | +| ISO-8859-10 | |
| 177 | +| ISO-8859-11 | |
| 178 | +| ISO-8859-12 | |
| 179 | +| ISO-8859-13 | |
| 180 | +| ISO-8859-14 | |
| 181 | +| ISO-8859-15 | |
| 182 | +| ISO-8859-16 | |
| 183 | +| SHIFT-JIS | |
| 184 | +| WINDOWS-1250 | |
| 185 | +| WINDOWS-1251 | |
| 186 | +| WINDOWS-1252 | |
| 187 | +| WINDOWS-1256 | |
| 188 | +| UTF-16BE | |
| 189 | +| UTF-8 | |
| 190 | +| ASCII | |
| 191 | +| GBK | |
| 192 | +| EUC-KR | |
| 193 | + |
| 194 | +>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. |
| 195 | +
|
| 196 | +#### Merge |
| 197 | + |
| 198 | +The `merge` method merges an image over a QrCode. This is commonly used to placed logos within a QrCode. |
| 199 | + |
| 200 | + QrCode::merge($filename, $percentage, $absolute); |
| 201 | + |
| 202 | + //Generates a QrCode with an image centered in the middle. |
| 203 | + QrCode::format('png')->merge('path-to-image.png')->generate(); |
| 204 | + |
| 205 | + //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. |
| 206 | + QrCode::format('png')->merge('path-to-image.png', .3)->generate(); |
| 207 | + |
| 208 | + //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. |
| 209 | + QrCode::format('png')->merge('http://www.google.com/someimage.png', .3, true)->generate(); |
| 210 | + |
| 211 | +>The `merge` method only supports PNG at this time. |
| 212 | +>The filepath is relative to app base path if `$absolute` is set to `false`. Change this variable to `true` to use absolute paths. |
| 213 | +
|
| 214 | +>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')`. |
| 215 | +
|
| 216 | + |
| 217 | + |
| 218 | +#### Merge Binary String |
| 219 | + |
| 220 | +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. |
| 221 | + |
| 222 | + QrCode::mergeString(Storage::get('path/to/image.png'), $percentage); |
| 223 | + |
| 224 | + //Generates a QrCode with an image centered in the middle. |
| 225 | + QrCode::format('png')->mergeString(Storage::get('path/to/image.png'))->generate(); |
| 226 | + |
| 227 | + //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. |
| 228 | + QrCode::format('png')->mergeString(Storage::get('path/to/image.png'), .3)->generate(); |
| 229 | + |
| 230 | +>As with the normal `merge` call, only PNG is supported at this time. The same applies for error correction, high levels are recommened. |
| 231 | +
|
| 232 | +#### Advance Usage |
| 233 | + |
| 234 | +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: |
| 235 | + |
| 236 | + QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate('Make me a QrCode!'); |
| 237 | + QrCode::format('png')->size(399)->color(40,40,40)->generate('Make me a QrCode!'); |
| 238 | + |
| 239 | +You can display a PNG image without saving the file by providing a raw string and encoding with `base64_encode`. |
| 240 | + |
| 241 | + <img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(100)->generate('Make me into an QrCode!')) !!} "> |
| 242 | + |
| 243 | +<a id="docs-helpers"></a> |
| 244 | +## Helpers |
| 245 | + |
| 246 | +#### What are helpers? |
| 247 | + |
| 248 | +Helpers are an easy way to create QrCodes that cause a reader to perform a certain action when scanned. |
| 249 | + |
| 250 | +#### E-Mail |
| 251 | + |
| 252 | +This helper generates an e-mail qrcode that is able to fill in the e-mail address, subject, and body. |
| 253 | + |
| 254 | + QrCode::email($to, $subject, $body); |
| 255 | + |
| 256 | + //Fills in the to address |
| 257 | + QrCode::email('foo@bar.com'); |
| 258 | + |
| 259 | + //Fills in the to address, subject, and body of an e-mail. |
| 260 | + QrCode::email('foo@bar.com', 'This is the subject.', 'This is the message body.'); |
| 261 | + |
| 262 | + //Fills in just the subject and body of an e-mail. |
| 263 | + QrCode::email(null, 'This is the subject.', 'This is the message body.'); |
| 264 | + |
| 265 | +#### Geo |
| 266 | + |
| 267 | +This helper generates a latitude and longitude that a phone can read and open the location up in Google Maps or similar app. |
| 268 | + |
| 269 | + QrCode::geo($latitude, $longitude); |
| 270 | + |
| 271 | + QrCode::geo(37.822214, -122.481769); |
| 272 | + |
| 273 | +#### Phone Number |
| 274 | + |
| 275 | +This helper generates a QrCode that can be scanned and then dials a number. |
| 276 | + |
| 277 | + QrCode::phoneNumber($phoneNumber); |
| 278 | + |
| 279 | + QrCode::phoneNumber('555-555-5555'); |
| 280 | + QrCode::phoneNumber('1-800-Laravel'); |
| 281 | + |
| 282 | +#### SMS (Text Messages) |
| 283 | + |
| 284 | +This helper makes SMS messages that can be prefilled with the send to address and body of the message. |
| 285 | + |
| 286 | + QrCode::SMS($phoneNumber, $message); |
| 287 | + |
| 288 | + //Creates a text message with the number filled in. |
| 289 | + QrCode::SMS('555-555-5555'); |
| 290 | + |
| 291 | + //Creates a text message with the number and message filled in. |
| 292 | + QrCode::SMS('555-555-5555', 'Body of the message'); |
| 293 | + |
| 294 | +#### WiFi |
| 295 | + |
| 296 | +This helpers makes scannable QrCodes that can connect a phone to a WiFI network. |
| 297 | + |
| 298 | + QrCode::wiFi([ |
| 299 | + 'encryption' => 'WPA/WEP', |
| 300 | + 'ssid' => 'SSID of the network', |
| 301 | + 'password' => 'Password of the network', |
| 302 | + 'hidden' => 'Whether the network is a hidden SSID or not.' |
| 303 | + ]); |
| 304 | + |
| 305 | + //Connects to an open WiFi network. |
| 306 | + QrCode::wiFi([ |
| 307 | + 'ssid' => 'Network Name', |
| 308 | + ]); |
| 309 | + |
| 310 | + //Connects to an open, hidden WiFi network. |
| 311 | + QrCode::wiFi([ |
| 312 | + 'ssid' => 'Network Name', |
| 313 | + 'hidden' => 'true' |
| 314 | + ]); |
| 315 | + |
| 316 | + //Connects to an secured, WiFi network. |
| 317 | + QrCode::wiFi([ |
| 318 | + 'ssid' => 'Network Name', |
| 319 | + 'encryption' => 'WPA', |
| 320 | + 'password' => 'myPassword' |
| 321 | + ]); |
| 322 | + |
| 323 | +>WiFi scanning is not currently supported on Apple Products. |
| 324 | +
|
| 325 | +<a id="docs-common-usage"></a> |
| 326 | +##Common QrCode Usage |
| 327 | + |
| 328 | +You can use a prefix found in the table below inside the `generate` section to create a QrCode to store more advanced information: |
| 329 | + |
| 330 | + QrCode::generate('http://www.simplesoftware.io'); |
| 331 | + |
| 332 | + |
| 333 | +| Usage | Prefix | Example | |
| 334 | +| --- | --- | --- | |
| 335 | +| Website URL | http:// | http://www.simplesoftware.io | |
| 336 | +| Secured URL | https:// | https://www.simplesoftware.io | |
| 337 | +| E-mail Address | mailto: | mailto:support@simplesoftware.io | |
| 338 | +| Phone Number | tel: | tel:555-555-5555 | |
| 339 | +| Text (SMS) | sms: | sms:555-555-5555 | |
| 340 | +| Text (SMS) With Pretyped Message | sms: | sms::I am a pretyped message | |
| 341 | +| Text (SMS) With Pretyped Message and Number | sms: | sms:555-555-5555:I am a pretyped message | |
| 342 | +| Geo Address | geo: | geo:-78.400364,-85.916993 | |
| 343 | +| MeCard | mecard: | MECARD:Simple, Software;Some Address, Somewhere, 20430;TEL:555-555-5555;EMAIL:support@simplesoftware.io; | |
| 344 | +| VCard | BEGIN:VCARD | [See Examples](https://en.wikipedia.org/wiki/VCard) | |
| 345 | +| Wifi | wifi: | wifi:WEP/WPA;SSID;PSK;Hidden(True/False) | |
| 346 | + |
| 347 | +<a id="docs-outside-laravel"></a> |
| 348 | +##Uso fora do Laravel |
| 349 | + |
| 350 | +Você pode usar o pacote fora do Laravel instanciando a classe `BaconQrCodeGenerator`. |
| 351 | + |
| 352 | + use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator; |
| 353 | + |
| 354 | + $qrcode = new BaconQrCodeGenerator; |
| 355 | + $qrcode->size(500)->generate('Make a qrcode without Laravel!'); |
0 commit comments