├── .github ├── stale.yml └── workflows │ └── php.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── composer.json ├── docs ├── ar │ └── README.md ├── de │ └── README.md ├── en │ └── README.md ├── es │ └── README.md ├── fr │ └── README.md ├── hi │ └── README.md ├── imgs │ ├── 200-pixels.png │ ├── 250-pixels.png │ ├── circle-eye.png │ ├── diagonal.png │ ├── dot.png │ ├── example-1.png │ ├── example-2.png │ ├── eye-0.png │ ├── eye-1.png │ ├── eye-2.png │ ├── horizontal.png │ ├── inverse_diagonal.png │ ├── make-me-into-a-qrcode.png │ ├── merged-qrcode.png │ ├── radial.png │ ├── red-25-transparent-background.png │ ├── red-25-transparent.png │ ├── red-background.png │ ├── red-qrcode.png │ ├── round.png │ └── vertical.png ├── it │ └── README.md ├── ja │ └── README.md ├── kr │ └── README.md ├── pt-br │ └── README.md ├── ru │ └── README.md └── zh-cn │ └── README.md ├── phpunit.xml ├── src ├── DataTypes │ ├── BTC.php │ ├── DataTypeInterface.php │ ├── Email.php │ ├── Geo.php │ ├── PhoneNumber.php │ ├── SMS.php │ └── WiFi.php ├── Facades │ └── QrCode.php ├── Generator.php ├── Image.php ├── ImageMerge.php └── QrCodeServiceProvider.php └── tests ├── DataTypes ├── BTCTest.php ├── EmailTest.php ├── GeoTest.php ├── PhoneNumberTest.php ├── SMSTest.php └── WiFiTest.php ├── GeneratorTest.php ├── ImageMergeTest.php ├── ImageTest.php └── Images ├── 200x300.png └── simplesoftware-icon-grey-blue.png /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 90 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - bug 8 | # Label to use when marking an issue as stale 9 | staleLabel: stale 10 | # Comment to post when marking an issue as stale. Set to `false` to disable 11 | markComment: > 12 | This issue has been automatically marked as stale because it has not had 13 | recent activity. It will be closed if no further activity occurs. Thank you 14 | for your contributions. 15 | # Comment to post when closing a stale issue. Set to `false` to disable 16 | closeComment: true 17 | -------------------------------------------------------------------------------- /.github/workflows/php.yml: -------------------------------------------------------------------------------- 1 | name: Unit Tests 2 | 3 | on: 4 | push: 5 | branches: [ master, develop ] 6 | pull_request: 7 | branches: [ master, develop ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - name: Validate composer.json and composer.lock 18 | run: composer validate 19 | 20 | - name: Install dependencies 21 | run: composer install --prefer-dist --no-progress 22 | 23 | - name: Run test suite 24 | run: composer run-script test 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | /vendor 3 | composer.lock -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Simple QrCode 2 | ============= 3 | 4 | ##Change Log 5 | 6 | #### 2.0.0 7 | * Fixed a bug where the merge image was not reset correctly. (#93) 8 | * Added Laravel auto discovery support. (#82) - Thanks [mazedlx](https://github.com/mazedlx) 9 | 10 | #### 1.5.1 11 | * Fixed a bug where a QrCode used within a loop would not generate correctly. 12 | 13 | #### 1.5.0 14 | * Added Portuguese translation. -Thanks [francisek](https://github.com/francisek) and [Varpie!](https://github.com/Varpie) 15 | * Added BitCoin helper 16 | 17 | #### 1.4.6 18 | * Added Portuguese translation. -Thanks [felipewmartins!](https://github.com/felipewmartins) 19 | 20 | #### 1.4.5 21 | * Added Spanish translation. -Thanks [gtarraga!](https://github.com/gtarraga) 22 | * Added Hindi translation. -Thanks [himanshu81494!](https://github.com/himanshu81494) 23 | 24 | #### 1.4.4 25 | * Added Italian translation. -Thanks [simocosimo!](https://github.com/simocosimo) 26 | 27 | #### 1.4.3 28 | * Updated the docs to our new format. 29 | * Correct some typos in the Russian translation. 30 | 31 | #### 1.4.2 32 | * Added Russian translation. -Thanks Victoria! 33 | * Added Chinese translation. -Thanks [blusewang!](https://github.com/blusewang) 34 | 35 | #### 1.4.1 36 | * Improved the quality of QrCodes with logos merge on them. -Thanks [tuupke!](https://github.com/tuupke) 37 | 38 | #### 1.4.0 39 | * Added the `mergeString` method. This method adds the ability to pass in a binary string to create a QrCode with an image on it. -Thanks [tuupke!](https://github.com/tuupke) 40 | 41 | #### 1.3.3 42 | * Allow absolute paths to be used with the `merge` method. 43 | 44 | #### 1.3.2 45 | * Changed `bindShared` to `singleton` to support Laravel 5.2 -Thanks [lhdev!](https://github.com/lhdev) 46 | 47 | #### 1.3.1 48 | * Fixed a bug where `merge` did not work as expected when used with `size.` 49 | 50 | #### 1.3.0 51 | * Added `merge` method. 52 | * Fixed a typo in the readme. 53 | 54 | #### 1.2.0 55 | * Added full support for Laravel 5 56 | * Added the following helpers. 57 | * E-Mail 58 | * Geo 59 | * Phone Number 60 | * SMS 61 | * WiFi 62 | 63 | #### 1.1.1 64 | * Update dependencies. 65 | * Corrected some composer file issues. 66 | * Added some missing Laravel information to the QrCode Service Provider. 67 | 68 | ####1.1.0 69 | * Added the ability to change the character encoding. 70 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | Please submit all issues and pull requests to the [simplesoftwareio/simple-qrcode](https://github.com/simplesoftwareio/simple-qrcode) repository on the develop branch! -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2020 Simple Software LLC www.simplesoftware.io 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Simple QrCode 2 | ======================== 3 | 4 | ![Unit Tests](https://github.com/SimpleSoftwareIO/simple-qrcode/workflows/Unit%20Tests/badge.svg) 5 | [![Latest Stable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/stable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 6 | [![Latest Unstable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/unstable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 7 | [![License](https://poser.pugx.org/simplesoftwareio/simple-qrcode/license.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 8 | [![Total Downloads](https://poser.pugx.org/simplesoftwareio/simple-qrcode/downloads.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 9 | 10 | ## [Deutsch](https://www.simplesoftware.io/#/docs/simple-qrcode/de) | [Español](https://www.simplesoftware.io/#/docs/simple-qrcode/es) | [Français](https://www.simplesoftware.io/#/docs/simple-qrcode/fr) | [Italiano](https://www.simplesoftware.io/#/docs/simple-qrcode/it) | [Português](https://www.simplesoftware.io/#/docs/simple-qrcode/pt-br) | [Русский](https://www.simplesoftware.io/#/docs/simple-qrcode/ru) | [日本語](https://www.simplesoftware.io/#/docs/simple-qrcode/ja) | [한국어](https://www.simplesoftware.io/#/docs/simple-qrcode/kr) | [हिंदी](https://www.simplesoftware.io/#/docs/simple-qrcode/hi) | [简体中文](https://www.simplesoftware.io/#/docs/simple-qrcode/zh-cn) | [العربية](https://www.simplesoftware.io/#/docs/simple-qrcode/ar) 11 | 12 | Language files are currently out of date. We need volunteers to upgrade them to v4! Please submit a PR request! 13 | 14 | ## Introduction 15 | 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. 16 | 17 | ## Official Documentation 18 | 19 | Documentation for Simple QrCode can be found on our [website.](http://www.simplesoftware.io/#/docs/simple-qrcode) 20 | 21 | ## Examples 22 | 23 | ![Example 1](docs/imgs/example-1.png) ![Example 2](docs/imgs/example-2.png) 24 | 25 | ## Use Cases 26 |

27 | 28 | 29 | 30 |

31 |

32 | Platform to sell tickets online 33 |

34 | 35 | ## Contributing 36 | 37 | Please submit all issues and pull requests to the [simplesoftwareio/simple-qrcode](https://github.com/simplesoftwareio/simple-qrcode) repository on the develop branch! 38 | 39 | ## License 40 | 41 | This software is released under the [MIT license.](https://opensource.org/licenses/MIT) 42 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | >= 2.x | :white_check_mark: | 8 | | <= 1.x | :x: | 9 | 10 | ## Reporting a Vulnerability 11 | 12 | Please report security vulnerabilities responsibility by emailing `security@simplesoftware.io.` 13 | 14 | We will fix the vulnerability privately, push a new release, and then go public with the notification. 15 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "simplesoftwareio/simple-qrcode", 3 | "description": "Simple QrCode is a QR code generator made for Laravel.", 4 | "keywords": ["qrcode", "laravel", "simple", "generator", "wrapper"], 5 | "homepage": "https://www.simplesoftware.io/#/docs/simple-qrcode", 6 | "license" : "MIT", 7 | "authors": [ 8 | { 9 | "name": "Simple Software LLC", 10 | "email": "support@simplesoftware.io" 11 | } 12 | ], 13 | "require": { 14 | "php": ">=7.2|^8.0", 15 | "ext-gd": "*", 16 | "bacon/bacon-qr-code": "^2.0" 17 | }, 18 | "require-dev": { 19 | "mockery/mockery": "~1", 20 | "phpunit/phpunit": "~9" 21 | }, 22 | "suggest": { 23 | "ext-imagick": "Allows the generation of PNG QrCodes.", 24 | "illuminate/support": "Allows for use within Laravel." 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "SimpleSoftwareIO\\QrCode\\": "src" 29 | } 30 | }, 31 | "scripts": { 32 | "test": "phpunit" 33 | }, 34 | "extra": { 35 | "laravel": { 36 | "providers": [ 37 | "SimpleSoftwareIO\\QrCode\\QrCodeServiceProvider" 38 | ], 39 | "aliases": { 40 | "QrCode": "SimpleSoftwareIO\\QrCode\\Facades\\QrCode" 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /docs/es/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode.svg?branch=master)](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode) [![Latest Stable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/stable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Latest Unstable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/unstable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![License](https://poser.pugx.org/simplesoftwareio/simple-qrcode/license.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Total Downloads](https://poser.pugx.org/simplesoftwareio/simple-qrcode/downloads.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 2 | 3 | 4 | - [Introducción](#docs-introduction) 5 | - [Traducciones](#docs-translations) 6 | - [Configuración](#docs-configuration) 7 | - [Ideas Simples](#docs-ideas) 8 | - [Uso](#docs-usage) 9 | - [Helpers](#docs-helpers) 10 | - [Uso Común de QrCode](#docs-common-usage) 11 | - [Uso fuera de Laravel](#docs-outside-laravel) 12 | 13 | 14 | ## Introducción 15 | Simple QrCode es un empaquetador de fácil uso para el popular framework Laravel basado en el gran trabajo proporcionado por [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode). Hemos creado una interfaz que es familiar y fácil de usar para los usuarios de Laravel. 16 | 17 | 18 | ## Traducciones 19 | Estamos buscando usuarios que hablen Árabe, Francés, Coreano o Japonés para traducir este documento. Porfavor cread una pull request si podeis ayudar con una traducción! 20 | 21 | 22 | ## Configuración 23 | 24 | #### Composer 25 | 26 | Primero, añadir el paquete Simple QrCode en su `require` en su archivo `composer.json`: 27 | 28 | "require": { 29 | "simplesoftwareio/simple-qrcode": "~2" 30 | } 31 | 32 | Luego, ejecutar el comando `composer update`. 33 | 34 | #### Service Provider 35 | 36 | ###### Laravel <= 5.4 37 | Registrar `SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class` en su `config/app.php` dentro del array `providers`. 38 | 39 | #### Aliases 40 | 41 | ###### Laravel <= 5.4 42 | Finalmente, registrar `'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class` en su archivo de configuración `config/app.php` dentro del array `aliases`. 43 | 44 | 45 | ## Ideas Simples 46 | 47 | #### Print View 48 | 49 | Uno de los principales usos de este paquete es la posibilidad de disponer QrCodes en todas nuestras print views. Esto permite a nuestros usuarios volver a la página original después de imprimir simplemente escaneando el código. Todo esto es posible añadiendo lo siguiente en nuestro archivo `footer.blade.php´. 50 | 51 |
52 | {!! QrCode::size(100)->generate(Request::url()); !!} 53 |

Escanéame para volver a la página principal.

54 |
55 | 56 | #### Incorporar un QrCode 57 | 58 | Puedes incorporar un código Qr en un e-mail para permitir a los usuarios un ágil escaneo. El ejemplo siguiente muestra como hacer esto con Laravel. 59 | 60 | //Inside of a blade template. 61 | 62 | 63 | 64 | ## Uso 65 | 66 | #### Uso Básico 67 | 68 | Usar el QrCode Generator es muy simple. La sintaxis más básica es: 69 | 70 | QrCode::generate('Transfórmame en un QrCode!'); 71 | 72 | Esto creara un código que diga "Transfórmame en un QrCode!" 73 | 74 | #### Generate 75 | 76 | `Generate` se usa para crear el QrCode. 77 | 78 | QrCode::generate('Transfórmame en un QrCode!'); 79 | 80 | >Atención! Este método debe de ser usado el último si se usa dentro de una cadena de comandos (chain). 81 | 82 | `Generate` por defecto devolverá un string de una imagen SVG. Puedes imprimirla directamente en un navegador moderno con el sistema Blade de Laravel con el siguiente código: 83 | 84 | {!! QrCode::generate('Transfórmame en un QrCode!'); !!} 85 | 86 | El método `generate` tiene un segundo parámetro que aceptará un nombre de archivo y un directorio para guardar el QrCode. 87 | 88 | QrCode::generate('Transfórmame en un QrCode!', '../public/qrcodes/qrcode.svg'); 89 | 90 | #### Cambio de Formato 91 | 92 | >QrCode Generator por defecto devolverá una imagen SVG. 93 | 94 | >Atención! El método `format` tiene que ser usado antes que cualquier opción de formato como `size`, `color`, `backgroundColor`, o `margin`. 95 | 96 | Actualmente hay 3 formatos compatibles; PNG, EPS, and SVG. Para cambiar el formato usa el siguiente código: 97 | 98 | QrCode::format('png'); //Devolvera una imagen PNG 99 | QrCode::format('eps'); //Devolvera una imagen EPS 100 | QrCode::format('svg'); //Devolvera una imagen SVG 101 | 102 | #### Cambio de Tamaño 103 | 104 | >QrCode Generator devolverá por defecto el tamaño de píxels mínimo para crear el QrCode. 105 | 106 | Puedes cambiar el tamaño de un QrCode usando el método `size`. Simplemente especifica el tamaño deseado en píxels usando el siguiente código: 107 | 108 | QrCode::size(100); 109 | 110 | #### Cambio de Color 111 | 112 | >Presta atención al cambiar el color de un QrCode. Algunos lectores tienen dificultades al leer QrCodes en color. 113 | 114 | Todos los colores deben ser expresados en RGB (Red Green Blue). Puedes cambiar el color del QrCode usando el siguiente código: 115 | 116 | QrCode::color(255,0,255); 117 | 118 | Para cambiar el color del fondo usamos: 119 | 120 | QrCode::backgroundColor(255,255,0); 121 | 122 | #### Cambio de Márgenes 123 | 124 | Es posible cambiar el márgen alrededor del QrCode. Simplemente especificamos el márgen deseado usando el siguiente código: 125 | 126 | QrCode::margin(100); 127 | 128 | #### Corrección de Errores 129 | 130 | Cambiar el nivel de corrección de errores es fácil. Unicamente usa el siguiente código: 131 | 132 | QrCode::errorCorrection('H'); 133 | 134 | Las siguientes opciónes son compatibles con el método de `errorCorrection`. 135 | 136 | | Error Correction | Assurance Provided | 137 | | --- | --- | 138 | | L | 7% of codewords can be restored. | 139 | | M | 15% of codewords can be restored. | 140 | | Q | 25% of codewords can be restored. | 141 | | H | 30% of codewords can be restored. | 142 | 143 | >Cuanto más corrección de error se usa; el QrCode aumenta y puede almacenar menos datos. Para saber más sobre [corrección de error](http://en.wikipedia.org/wiki/QR_code#Error_correction). 144 | 145 | #### Encoding 146 | 147 | Para cambiar la codificación de carácteres que se usa para crear un QrCode. Por defecto `ISO-8859-1` está seleccionado. Para saber más sobre [codificación de carácteres](http://en.wikipedia.org/wiki/Character_encoding) You can change this to any of the following: 148 | 149 | QrCode::encoding('UTF-8')->generate('Transfórmame en un QrCode con símbolos especiales ♠♥!!'); 150 | 151 | | Codificador de carácteres | 152 | | --- | 153 | | ISO-8859-1 | 154 | | ISO-8859-2 | 155 | | ISO-8859-3 | 156 | | ISO-8859-4 | 157 | | ISO-8859-5 | 158 | | ISO-8859-6 | 159 | | ISO-8859-7 | 160 | | ISO-8859-8 | 161 | | ISO-8859-9 | 162 | | ISO-8859-10 | 163 | | ISO-8859-11 | 164 | | ISO-8859-12 | 165 | | ISO-8859-13 | 166 | | ISO-8859-14 | 167 | | ISO-8859-15 | 168 | | ISO-8859-16 | 169 | | SHIFT-JIS | 170 | | WINDOWS-1250 | 171 | | WINDOWS-1251 | 172 | | WINDOWS-1252 | 173 | | WINDOWS-1256 | 174 | | UTF-16BE | 175 | | UTF-8 | 176 | | ASCII | 177 | | GBK | 178 | | EUC-KR | 179 | 180 | >Un error de `Could not encode content to ISO-8859-1` significa que se esta usando una codificación de carácteres incorrecta. Recomendamos `UTF-8` si no está seguro. 181 | 182 | #### Merge 183 | 184 | El método `merge` une una imagen con un QrCode. Normalmente se usa para añadir logos en un QrCode. 185 | 186 | QrCode::merge($filename, $percentage, $absolute); 187 | 188 | //Genera un QrCode con una imagen en el centro. 189 | QrCode::format('png')->merge('path-to-image.png')->generate(); 190 | 191 | //Genera un QrCode con una imagen en el centro. La imagen ocupa un 30% del QrCode. 192 | QrCode::format('png')->merge('path-to-image.png', .3)->generate(); 193 | 194 | //Genera un QrCode con una imagen en el centro. La imagen ocupa un 30% del QrCode. 195 | QrCode::format('png')->merge('http://www.google.com/someimage.png', .3, true)->generate(); 196 | 197 | >El método `merge` sólo es compatible con PNG de momento. 198 | >El path del archivo es relativo al path de la app si `$absolute` equivale a `false`. Cambia esta variable a `true` para usar paths absolutos. 199 | 200 | >Se debería usar un nivel alto de corrección de error al usar `merge` para asegurarse que el QrCode se sigue podiendo leer. Recomendamos usar `errorCorrection('H')`. 201 | 202 | ![Merged Logo](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/merged-qrcode.png?raw=true) 203 | 204 | #### Merge Binary String 205 | 206 | El método `mergeString` se puede usar para conseguir el mismo resultado que con `merge`, con la diferencia que permite proveer una representación en string del archivo en vez de el filepath. Ésto es útil al trabajar con el `Storage` facade. Su interfaz es muy similar a la de `merge`. 207 | 208 | QrCode::mergeString(Storage::get('path/to/image.png'), $percentage); 209 | 210 | //Genera un QrCode con una imagen en el centro. 211 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'))->generate(); 212 | 213 | //Genera un QrCode con una imagen en el centro. La imagen ocupa un 30% del QrCode. 214 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'), .3)->generate(); 215 | 216 | >Igual que con `merge`, sólo PNG de momento. Lo mismo que con el nivel de corrección de error, alto nivel está recomendado. 217 | 218 | #### Uso Avanzado 219 | 220 | Todos los métodos soportan chaining. El método `generate` tiene que ser el último y cualquier cambio de `format` tiene que ser llamado primero. Por ejemplo: 221 | 222 | QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate('Transfórmame en un QrCode!'); 223 | QrCode::format('png')->size(399)->color(40,40,40)->generate('Transfórmame en un QrCode!'); 224 | 225 | Puedes mostrar una imagen PNG sin guardar el archivo usando una string y eligiendo la codificación `base64_encode`. 226 | 227 | 228 | 229 | 230 | ## Helpers 231 | 232 | #### Qué son los helpers? 233 | 234 | Los helpers son una manera fácil de crear QrCodes que causan que causan una acción en el lector al escanear. 235 | 236 | #### E-Mail 237 | 238 | Este helper genera un QrCode de e-mail que es capaz de rellenar dirección e-mail, asunto, y el cuerpo del e-mail. 239 | 240 | QrCode::email($to, $subject, $body); 241 | 242 | //Rellena la dirección 243 | QrCode::email('foo@bar.com'); 244 | 245 | //Rellena la dirección, el asunto y el cuerpo. 246 | QrCode::email('foo@bar.com', 'This is the subject.', 'This is the message body.'); 247 | 248 | //Solo rellena el asunto y el cuerpo del e-mail. 249 | QrCode::email(null, 'This is the subject.', 'This is the message body.'); 250 | 251 | #### Geo 252 | 253 | Este helper genera una latitude y una longitude que un teléfono puede leer y abrir la localización en Google Maps o alguna app similar. 254 | 255 | QrCode::geo($latitude, $longitude); 256 | 257 | QrCode::geo(37.822214, -122.481769); 258 | 259 | #### Phone Number 260 | 261 | Este helper genera un QrCode que puede ser escaneado y llama a un número de teléfono. 262 | 263 | QrCode::phoneNumber($phoneNumber); 264 | 265 | QrCode::phoneNumber('555-555-5555'); 266 | QrCode::phoneNumber('1-800-Laravel'); 267 | 268 | #### SMS (Mensajes de texto) 269 | 270 | Este helper crea SMS que pueden ser previamente rellenados con la dirección y el mensaje. 271 | 272 | QrCode::SMS($phoneNumber, $message); 273 | 274 | //Crea un mensaje de texto con el número rellenado. 275 | QrCode::SMS('555-555-5555'); 276 | 277 | //Crea un mensaje de texto con el número y el mensaje rellenados. 278 | QrCode::SMS('555-555-5555', 'Mensaje'); 279 | 280 | #### WiFi 281 | 282 | Este helpers crea QrCodes que conectan un teléfono a una red WiFI. 283 | 284 | QrCode::wiFi([ 285 | 'encryption' => 'WPA/WEP', 286 | 'ssid' => 'SSID de la red', 287 | 'password' => 'Password de la red', 288 | 'hidden' => 'Si la red tiene SSID oculta o no.' 289 | ]); 290 | 291 | //Conecta a una red abierta. 292 | QrCode::wiFi([ 293 | 'ssid' => 'Network Name', 294 | ]); 295 | 296 | //Conecta a una red abierta y oculta. 297 | QrCode::wiFi([ 298 | 'ssid' => 'Network Name', 299 | 'hidden' => 'true' 300 | ]); 301 | 302 | //Conecta a una red segura. 303 | QrCode::wiFi([ 304 | 'ssid' => 'Network Name', 305 | 'encryption' => 'WPA', 306 | 'password' => 'myPassword' 307 | ]); 308 | 309 | >WiFi scanning no es compatible con productos Apple. 310 | 311 | 312 | ##Uso común de QrCode 313 | 314 | Puedes usar un prefijo de la tabla dentro de la sección `generate` para crear un QrCode que almacene informacion avanzada: 315 | 316 | QrCode::generate('http://www.simplesoftware.io'); 317 | 318 | 319 | | Usage | Prefix | Example | 320 | | --- | --- | --- | 321 | | Website URL | http:// | http://www.simplesoftware.io | 322 | | Secured URL | https:// | https://www.simplesoftware.io | 323 | | E-mail Address | mailto: | mailto:support@simplesoftware.io | 324 | | Phone Number | tel: | tel:555-555-5555 | 325 | | Text (SMS) | sms: | sms:555-555-5555 | 326 | | Text (SMS) With Pretyped Message | sms: | sms::I am a pretyped message | 327 | | Text (SMS) With Pretyped Message and Number | sms: | sms:555-555-5555:I am a pretyped message | 328 | | Geo Address | geo: | geo:-78.400364,-85.916993 | 329 | | MeCard | mecard: | MECARD:Simple, Software;Some Address, Somewhere, 20430;TEL:555-555-5555;EMAIL:support@simplesoftware.io; | 330 | | VCard | BEGIN:VCARD | [See Examples](https://en.wikipedia.org/wiki/VCard) | 331 | | Wifi | wifi: | wifi:WEP/WPA;SSID;PSK;Hidden(True/False) | 332 | 333 | 334 | ##Uso fuera de Laravel 335 | 336 | Puedes usar este paquete fuera de Laravel instanciando una nueva clase `BaconQrCodeGenerator`. 337 | 338 | use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator; 339 | 340 | $qrcode = new BaconQrCodeGenerator; 341 | $qrcode->size(500)->generate('Crea un QrCode sin Laravel!'); 342 | -------------------------------------------------------------------------------- /docs/fr/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode.svg?branch=master)](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode) [![Latest Stable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/stable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Latest Unstable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/unstable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![License](https://poser.pugx.org/simplesoftwareio/simple-qrcode/license.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Total Downloads](https://poser.pugx.org/simplesoftwareio/simple-qrcode/downloads.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 2 | 3 | - [Introduction](#docs-introduction) 4 | - [Traductions](#docs-translations) 5 | - [Configuration](#docs-configuration) 6 | - [Utilisations Simples](#docs-ideas) 7 | - [Usage](#docs-usage) 8 | - [Helpers](#docs-helpers) 9 | - [Usage Courant De QrCode](#docs-common-usage) 10 | - [Usage Hors De Laravel](#docs-outside-laravel) 11 | 12 | 13 | ## Introduction 14 | Simple QrCode est un adaptateur facile d'utilisation pour le framework Laravel et qui s'appuie sur le magnifique travail fourni par [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode). Nous avons conçu une interface intuitive, facile d'installation et familière aux utilisateurs de Laravel. 15 | 16 | 17 | ## Traductions 18 | Nous recherchons des utilisateurs parlant arabe, espagnol, français, coréen ou japonnais pour nous aider à traduire cette documentation. Si vous vous en sentez capable, créez une pull request ! 19 | 20 | 21 | ## Configuration 22 | 23 | #### Composer 24 | 25 | Commencez par ajouter le paquet QrCode à la section `require` de votre fichier `composer.json`: 26 | 27 | "require": { 28 | "simplesoftwareio/simple-qrcode": "~2" 29 | } 30 | 31 | Lancez ensuite la commande `composer update`. 32 | 33 | #### Service Provider 34 | 35 | ###### Laravel <= 5.4 36 | Ajouter l'entrée `SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class` au tableau `providers` du fichier de configuration `config/app.php`. 37 | 38 | #### Alias 39 | 40 | ###### Laravel <= 5.4 41 | Enfin, ajoutez l'entrée `'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class` au tableau `aliases` du fichier de configuration `config/app.php`. 42 | 43 | 44 | ## Utilisations Simples 45 | 46 | #### Print View 47 | 48 | L'un des pricipaux usages que nous faisons de ce paquet et d'avoir des QrCodes dans toutes nos vues d'impression. Cela donne la possibilité à nos clients qui le flashent de revenir à la page d'origine du document après que celui-ci a été imprimé. Nous obtenons cette fonctionnalité en ajoutant le code suivant au fichier footer.blade.php. 49 | 50 |
51 | {!! QrCode::size(100)->generate(Request::url()); !!} 52 |

Flashez-moi pour revenir à la page d'origine.

53 |
54 | 55 | #### Embarquer Un QrCode 56 | 57 | Vous pouvez embarquer un qrcode dans un courriel pour permettre à vos utilisateurs de le flasher. Voici un exemple pour mettre ceci en œuvre dans Laravel : 58 | 59 | // Dans un template blade. 60 | 61 | 62 | 63 | ## Usage 64 | 65 | #### Usage De Base 66 | 67 | L'utilisation du Générateur de QrCode est très simple. La syntaxe minimale est : 68 | 69 | QrCode::generate('Transformez-moi en QrCode !'); 70 | 71 | Cela créera un QrCode qui dit "Transformez-moi en QrCode !" 72 | 73 | #### Generate 74 | 75 | `Generate` sert à fabriquer un QrCode. 76 | 77 | QrCode::generate('Transformez-moi en QrCode !'); 78 | 79 | >Attention! Cette méthode doit être appelée en dernier si vous l'utilisez dans un appel chaîné. 80 | 81 | Par défaut, `Generate` retournera le contenu d'une image SVG sous forme de chaîne. Vous pouvez afficher cette image directement avec un navigateur moderne dans un template Blade de Laravel de cette façon : 82 | 83 | {!! QrCode::generate('Transformez-moi en QrCode !'); !!} 84 | 85 | La méthode `generate` accepte un second paramètre pour définir un nom de fichier où enregistrer le QrCode. 86 | 87 | QrCode::generate('Transformez-moi en QrCode !', '../public/qrcodes/qrcode.svg'); 88 | 89 | #### Changement De Format 90 | 91 | >Le générateur de QrCode est prévu pour retourner une image SVG par défaut. 92 | 93 | >Attention! La méthode `format` doit être appelée avant toute autre option de formatage, telles que `size`, `color`, `backgroundColor` et `margin`. 94 | 95 | Trois formats sont actuellement supportés : PNG, EPS et SVG. Pour changer de format, utilisez le code suivant : 96 | 97 | QrCode::format('png'); // retourne une image PNG 98 | QrCode::format('eps'); // retourne une image EPS 99 | QrCode::format('svg'); // retourne une image SVG 100 | 101 | #### Changement De Taille 102 | 103 | >Le générateur de QrCode retournera par défaut le QrCode dans la plus petite taille possible en pixels. 104 | 105 | Vous pouvez changer la taille du QrCode par la méthode `size` qui prend comme paramètre la taille désirée en pixels : 106 | 107 | QrCode::size(100); 108 | 109 | #### Changement De Couleur 110 | 111 | >Changez les couleurs de vos QrCode avec précaution car certains lecteurs rencontrent des difficultés avec les QrCodes en couleur. 112 | 113 | Toutes les couleurs doivent être exprimées en RGB (rouge, vert, bleu). Vous pouvez changer la couleur de trait du QrCode par la méthode `color` : 114 | 115 | QrCode::color(255,0,255); 116 | 117 | La couleur de fond peut être définie de la même façon par la méthode `backgroundColor` : 118 | 119 | QrCode::backgroundColor(255,255,0); 120 | 121 | #### Changement Des Marges 122 | 123 | Vous pouvez définir une marge autour du QrCode par la méthode `margin` : 124 | 125 | QrCode::margin(100); 126 | 127 | #### Correction D'Erreur 128 | 129 | Il est très aisé de changer le niveau de correction d'erreur. Utilisez la syntaxe suivante : 130 | 131 | QrCode::errorCorrection('H'); 132 | 133 | Voici la liste des options supportées pour la méthode `errorCorrection`. 134 | 135 | | Correction d'Erreur | Capacité De Correction | 136 | | --- | --- | 137 | | L | 7% de redondance. | 138 | | M | 15% de redondance. | 139 | | Q | 25% de redondance. | 140 | | H | 30% de redondance. | 141 | 142 | >L'élévation du niveau de correction d'erreur se fait au détriment de la taille du QrCode et de la quantité de données qu'il peut stocker. Pour en savoir plus, consultez [error correction](http://en.wikipedia.org/wiki/QR_code#Error_correction) (en anglais). 143 | 144 | #### Encodage 145 | 146 | La norme de codage par défaut des caractères contenus dans le QrCode est l'`ISO-8859-1`. Pour en savoir plus sur le codage, voyez [codage des caractères](http://fr.wikipedia.org/wiki/Codage_des_caractères). Vous pouvez changer le codage par le code suivant : 147 | 148 | QrCode::encoding('UTF-8')->generate('Transformez-moi en QrCode avec des symboles ♠♥!!'); 149 | 150 | | Codage Des Caractères | 151 | | --- | 152 | | ISO-8859-1 | 153 | | ISO-8859-2 | 154 | | ISO-8859-3 | 155 | | ISO-8859-4 | 156 | | ISO-8859-5 | 157 | | ISO-8859-6 | 158 | | ISO-8859-7 | 159 | | ISO-8859-8 | 160 | | ISO-8859-9 | 161 | | ISO-8859-10 | 162 | | ISO-8859-11 | 163 | | ISO-8859-12 | 164 | | ISO-8859-13 | 165 | | ISO-8859-14 | 166 | | ISO-8859-15 | 167 | | ISO-8859-16 | 168 | | SHIFT-JIS | 169 | | WINDOWS-1250 | 170 | | WINDOWS-1251 | 171 | | WINDOWS-1252 | 172 | | WINDOWS-1256 | 173 | | UTF-16BE | 174 | | UTF-8 | 175 | | ASCII | 176 | | GBK | 177 | | EUC-KR | 178 | 179 | >Une erreur du type `Could not encode content to ISO-8859-1` signifie qu'un mauvais codage est utilisé. Nous recommendons `UTF-8` si vous n'êtes pas sûr. 180 | 181 | #### Merge 182 | 183 | La méthode `merge` fusionne une image sur un QrCode. C'est une pratique courante pour placer un logo dans un QrCode. 184 | 185 | QrCode::merge($nom_de_fichier, $pourcentage, $absolu); 186 | 187 | // Génère un QrCode avec une image centrée. 188 | QrCode::format('png')->merge('chemin-vers-l-image.png')->generate(); 189 | 190 | // Génère un QrCode avec une image centrée. L'image recouvre jusque 30% du QrCode. 191 | QrCode::format('png')->merge('chemin-vers-l-image.png', .3)->generate(); 192 | 193 | // Génère un QrCode avec une image centrée. L'image recouvre jusque 30% du QrCode. 194 | QrCode::format('png')->merge('http://www.google.com/someimage.png', .3, true)->generate(); 195 | 196 | >La méthode `merge` ne supporte que les images PNG. 197 | >Le chemin vers l'image est relatif au chemin de base de l'application si $absolu est à `false`. Changez cette variable à `true` pour utiliser des chemins absolus. 198 | 199 | > Vous devriez utiliser un haut niveau de correction d'erreur avec la méthode `merge` pour assurer la bonne lecture du QrCode. Nous recommandons l'utilisation de `errorCorrection('H')`. 200 | 201 | ![Fusion de Logo](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/merged-qrcode.png?raw=true) 202 | 203 | #### Fusion De Chaîne Binaire 204 | 205 | La méthode `mergeString` est semblable à la méthode `merge` si ce n'est qu'elle prend comme paramètre le contenu du fichier sous forme de chaîne au lieu du nom du fichier. C'est particulièrement utile lorsque vous travaillez avec une façade `Storage`. L'interface de `mergeString` est très similaire à celle de `merge`. 206 | 207 | QrCode::mergeString(Storage::get('chemin/vers/image.png'), $percentage); 208 | 209 | // Génère un QrCode avec une image centrée. 210 | QrCode::format('png')->mergeString(Storage::get('chemin/vers/image.png'))->generate(); 211 | 212 | // Génère un QrCode avec une image centrée. L'image recouvre jusque 30% du QrCode. 213 | QrCode::format('png')->mergeString(Storage::get('chemin/vers/image.png'), .3)->generate(); 214 | 215 | >A l'instar de la méthode `merge`, seul le format d'image PNG est supporté. Les même recommandations relatives à la correction d'erreur s'appliquent. 216 | 217 | #### Utilisation Avancée 218 | 219 | Toutes les méthodes supportent le chaînage. La méthode `generate` doit être appelée en dernier et toute modification du `format` en premier. Vous pourriez par exemple écrire : 220 | 221 | QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate('Transformez-moi en QrCode!'); 222 | QrCode::format('png')->size(399)->color(40,40,40)->generate('Transformez-moi en QrCode!'); 223 | 224 | Vous pouvez afficher une image PNG sans enregistrer de fichier en spécifiant une chaîne brute encodée avec `base64_encode`. 225 | 226 | 227 | 228 | 229 | ## Helpers 230 | 231 | #### Que sont les helpers? 232 | 233 | Les helpers facilitent la création de QrCodes qui déclenchent une action du lecteur lorsqu'ils sont flashés. 234 | 235 | #### E-Mail 236 | 237 | Cet helper génère un QrCode pour l'envoi de courriel dont les destinataire, sujet et contenu peuvent être prédéfinis. 238 | 239 | QrCode::email($destinataire, $sujet, $contenu); 240 | 241 | // Renseigne l'adresse du destinataire 242 | QrCode::email('foo@bar.com'); 243 | 244 | // Renseigne le destinataire, le sujet et le contenu du courriel 245 | QrCode::email('foo@bar.com', 'Ceci est le sujet.', 'Ceci est le contenu.'); 246 | 247 | // Ne renseigne que le sujet et le contenu du courriel 248 | QrCode::email(null, 'Ceci est le sujet.', 'Ceci est le contenu.'); 249 | 250 | #### Geo 251 | 252 | Cet helper génère un QrCode avec des coordonnées géographiques (latitude et longitude) qui pourront être ouvertes par une application Google Maps ou similaire. 253 | 254 | QrCode::geo($latitude, $longitude); 255 | 256 | QrCode::geo(37.822214, -122.481769); 257 | 258 | #### Numéro de Téléphone 259 | 260 | Cet helper génère un QrCode qui lorsqu'il est flashé compose un numéro de téléphone. 261 | 262 | QrCode::phoneNumber($numeroDeTelephone); 263 | 264 | QrCode::phoneNumber('555-555-5555'); 265 | QrCode::phoneNumber('1-800-Laravel'); 266 | 267 | #### SMS (Messages Texte) 268 | 269 | Cet helper génère un QrCode d'envoi de SMS dont le destinataire et le message peuvent être prédéfinis. 270 | 271 | QrCode::SMS($numeroDeTelephone, $message); 272 | 273 | // Crée un SMS pour un numéro de téléphone 274 | QrCode::SMS('555-555-5555'); 275 | 276 | // Crée un SMS pour un numéro de téléphone avec un message 277 | QrCode::SMS('555-555-5555', 'Corps du message'); 278 | 279 | #### WiFi 280 | 281 | Cet helper génère un QrCode qui permet la connexion à un réseau WiFi. 282 | 283 | QrCode::wiFi([ 284 | 'encryption' => 'WPA/WEP', 285 | 'ssid' => 'SSID du réseau', 286 | 'password' => 'Mot de passe de connexion', 287 | 'hidden' => 'Indique si le SSID du réseau est masqué ou non.' 288 | ]); 289 | 290 | // Connexion à un réseau WiFi ouvert 291 | QrCode::wiFi([ 292 | 'ssid' => 'Nom du réseau', 293 | ]); 294 | 295 | // Connexion à un réseau WiFi ouvert et masqué 296 | QrCode::wiFi([ 297 | 'ssid' => 'Nom du réseau', 298 | 'hidden' => 'true' 299 | ]); 300 | 301 | // Connexion à un réseau WiFi sécurisé 302 | QrCode::wiFi([ 303 | 'ssid' => 'Nom du réseau', 304 | 'encryption' => 'WPA', 305 | 'password' => 'Mot de passe' 306 | ]); 307 | 308 | >La recherche de réseaux WiFi n'est actuellement pas supportée par les produis Apple. 309 | 310 | 311 | ## Usage Courant des QrCodes 312 | 313 | Vous pouvez utiliser un des pseudos-protocoles du tableau suivant comme paramètre de la méthode `generate` pour créer un QrCode contenant des informations avancées : 314 | 315 | QrCode::generate('http://www.simplesoftware.io'); 316 | 317 | 318 | | Usage | Protocole | Exemple | 319 | | --- | --- | --- | 320 | | URL de site internet | http:// | http://www.simplesoftware.io | 321 | | URL de site internet sécurisé | https:// | https://www.simplesoftware.io | 322 | | Adresse de courriel | mailto: | mailto:support@simplesoftware.io | 323 | | Numéro de téléphone | tel: | tel:555-555-5555 | 324 | | SMS | sms: | sms:555-555-5555 | 325 | | SMS avec message pré-défini | sms: | sms::I am a pretyped message | 326 | | SMS avec message et numéro de téléphone pré-définis | sms: | sms:555-555-5555:I am a pretyped message | 327 | | Coordonnées géographiques | geo: | geo:-78.400364,-85.916993 | 328 | | MeCard | mecard: | MECARD:Simple, Software;Some Address, Somewhere, 20430;TEL:555-555-5555;EMAIL:support@simplesoftware.io; | 329 | | VCard | BEGIN:VCARD | [Voir les exemples](https://fr.wikipedia.org/wiki/Code_QR#Correction_d.27erreur) | 330 | | Wifi | wifi: | wifi:WEP/WPA;SSID;PSK;Hidden(True/False) | 331 | 332 | 333 | ##Usage Hors De Laravel 334 | 335 | Vous pouvez utiliser ce paquet en dehors de Laravel en instanciant un objet de classe `BaconQrCodeGenerator`. 336 | 337 | use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator; 338 | 339 | $qrcode = new BaconQrCodeGenerator; 340 | $qrcode->size(500)->generate('Créer un qrcode sans Laravel!'); 341 | -------------------------------------------------------------------------------- /docs/hi/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode.svg?branch=master)](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode) [![Latest Stable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/stable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Latest Unstable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/unstable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![License](https://poser.pugx.org/simplesoftwareio/simple-qrcode/license.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Total Downloads](https://poser.pugx.org/simplesoftwareio/simple-qrcode/downloads.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 2 | 3 | 4 | - [परिचय](#docs-introduction) 5 | - [अनुवाद](#docs-translations) 6 | - [विन्यास](#docs-configuration) 7 | - [साधारण विचार](#docs-ideas) 8 | - [उपयोग](#docs-usage) 9 | - [सहायक](#docs-helpers) 10 | - [साधारण QrCode उपयोग](#docs-common-usage) 11 | - [लरावेल(Laravel) के बाहर उपयोग](#docs-outside-laravel) 12 | 13 | 14 | ## परिचय 15 | सरल क्यूआरकोड [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode) द्वारा प्र्दान किए गये महान कार्य पर आधारित लोकप्रिय Laravel ढ़ाचा के लिए आसानी से प्रयोग करने योग्य आवरण है। हमने लरावेल उपयोगकर्ताओं के लिए परिचित व आसानी से स्थापित करने योग्य एक अंतरफलक बनाया है। 16 | 17 | 18 | ## अनुवाद 19 | हमे उनकी खोज है जो इस दस्तावेज़ का अरबी, स्पेनिश, फ्रेंच, कोरियाई या जापानी मे अनुवाद करने मे मदद कर सकते हैं। यदि आप एक अनुवाद करने में सक्षम हैं तो कृपया एक पुल अनुरोध बनाए! 20 | 21 | 22 | ## विन्यास 23 | 24 | #### Composer 25 | 26 | सर्वप्रथं composer.json मे qrcode पॅकेज को अपने require से जोड़ें: 27 | 28 | "require": { 29 | "simplesoftwareio/simple-qrcode": "~2" 30 | } 31 | 32 | फिर composer update कमॅंड चलाएँ। 33 | 34 | #### Service Provider 35 | 36 | ###### Laravel <= 5.4 37 | config/app.php में providers array में SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class को रजिस्टर करें। 38 | 39 | #### Aliases (उपनाम) 40 | 41 | ###### Laravel <= 5.4 42 | आखिर में 'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class को config/app.php विन्यास फ़ाइल में aliases array में रजिस्टर करें। 43 | 44 | 45 | ## साधारण विचार 46 | 47 | #### Print View (प्रिंट देखें) 48 | 49 | इस पैकेज का मुख्य रूप से उपयोग हम सभी print views मे QrCode डालने के लिए करते हैं। यह हमारे ग्राहकों को स्कैन करके के बाद मूल पृष्ठ पर लौटने के लिए अनुमित करता है। हमने अपने footer.blade.php फ़ाइल में निम्न जोड़कर इसे हासिल किया है। 50 | 51 |
52 | {!! QrCode::size(100)->generate(Request::url()); !!} 53 |

Scan me to return to the original page.

54 |
55 | 56 | #### Embed A QrCode 57 | 58 | अपने उपयोगकर्ताओं को जल्दी से स्कैन करने के लिए आप एक ई-मेल के अंदर एक qrcode एम्बेड कर सकते हैं। निम्नलिखित लरावेल के साथ ऐसा करने का एक उदाहरण है। 59 | 60 | //Inside of a blade template. 61 | 62 | 63 | 64 | ## उपयोग 65 | 66 | #### Basic Usage (साधारण उपयोग) 67 | 68 | QrCode Generator का उपयोग बेहद आसान है: 69 | 70 | QrCode::generate('Make me into a QrCode!'); 71 | 72 | इससे qrcode कहेगा है कि "मुझे एक qrcode में बनाओ!" 73 | 74 | #### Generate 75 | 76 | Generate QrCode बनाने के काम आता है। 77 | 78 | QrCode::generate('Make me into a QrCode!'); 79 | 80 | >सचेत! यह विधि श्रृंखला में अंतिम में पुकारी जानी चाहिए। 81 | `जेनरेट` डिफ़ॉल्ट रूप से SVG छवि की स्ट्रिंग लौटता है। आप इसे सीधे ही Laravel's Blade system से निम्न प्रकार से किसी भी आधुनिक ब्राउज़र मे प्रिंट ले सकते हैं: 82 | 83 | {!! QrCode::generate('Make me into a QrCode!'); !!} 84 | 85 | उत्पन्न विधि का एक दूसरे पैरामीटर है जो एक फ़ाइल का नाम और पथ QrCode को बचाने के लिए स्वीकार करता है। 86 | 87 | QrCode::generate('Make me into a QrCode!', '../public/qrcodes/qrcode.svg'); 88 | 89 | #### Format Change(प्रारूप बदलें) 90 | 91 | >QrCode Generator डिफ़ॉल्ट रूप से SVG चित्र लौटाता है. 92 | 93 | >ध्यान रहे! `format` की विधि को किसी भी अन्य स्वरूपण विकल्प जैसे कि `size`, `color`, `backgroundColor`, व `margin` से पहले ही कॉल करें. 94 | 95 | निम्न तीन स्वरूप वर्तमान मे समर्थित हैं; PNG, EPS, और SVG. निम्न कोड का उपयोग करें: 96 | 97 | QrCode::format('png'); //Will return a PNG image 98 | QrCode::format('eps'); //Will return a EPS image 99 | QrCode::format('svg'); //Will return a SVG image 100 | 101 | #### Size Change (आकार बदल) 102 | 103 | >QrCode Generator डिफ़ॉल्ट रूप से सबसे छोटी संभव आकार से QrCode बनाएग। 104 | 105 | आप `आकार` विधि का उपयोग कर एक QRCode का आकार बदल सकते हैं। बस निम्न वाक्य-विन्यास का उपयोग करके पिक्सल मे वांछित आकर निर्दिष्ट करें: 106 | 107 | QrCode::size(100); 108 | 109 | #### Color Change (रंग का बदलना) 110 | 111 | >QrCode का रंग बदलते समय सतर्क रहें। कई उपयोगकर्ताओं को भिन्न रंगों मे QrCode पढ़ने मे कठिनाई होती है। 112 | 113 | सभी रंगों को RGB(लाल हरा नीला) मे व्यक्त करना आवश्यक है। आप निम्न का उपयोग करने QrCode का रंग बदल सकते हैं: 114 | 115 | QrCode::color(255,0,255); 116 | 117 | पृष्ठभूमि रंग परिवर्तन भी इस ही तरीके से व्यक्त किया जा सकता है। 118 | 119 | QrCode::backgroundColor(255,255,0); 120 | 121 | #### Size Change (हाशिया परिवर्तन) 122 | 123 | एक QrCode के आसपास हाशिया बदलने की क्षमता भी प्रदान की गयी है। इच्छित हाशिया निम्न वाक्य-विन्यास के अनुसार व्यक्त करें: 124 | 125 | QrCode::margin(100); 126 | 127 | #### Error Correction (त्रुटि सुधार) 128 | 129 | त्रुटि सुधार के स्तर को बदलना भी आसान है। निम्न वाक्य - विन्यास के अनुसार चलें: 130 | 131 | QrCode::errorCorrection('H'); 132 | 133 | `errorCorrection` की विधि के लिए निम्न विकल्प समर्थित हैं: 134 | 135 | | गलतीयों का सुधार | प्रस्तावित आश्वासन | 136 | | --- | --- | 137 | | L | 7% codewords में से बहाल किए जा सकते हैं। | 138 | | M | 15% codewords में से बहाल किए जा सकते हैं। | 139 | | Q | 25% codewords में से बहाल किए जा सकते हैं। | 140 | | H | 30% codewords में से बहाल किए जा सकते हैं। | 141 | 142 | >अधिक त्रुटि सुधार के उपयोग से QrCode बड़ा हो जाता है और कम सूचना जमा कर सकता है। [त्रुटि सुधार](http://en.wikipedia.org/wiki/QR_code#Error_correction) के बारे मे अधिक पढ़ें। 143 | 144 | #### Encoding(एन्कोडिंग) 145 | 146 | वर्ण एन्कोडिंग को बदलें जिसका प्रयोग QrCode का निर्माण करने के लिए किया जाता है। डिफ़ॉल्ट रूप से `ISO-8859-1` एनकोडर के रूप में चयनित है।[वर्ण एनकोडिंग](http://en.wikipedia.org/wiki/Character_encoding) के बारे में अधिक पढ़ें। आप निम्न में से किसी के लिए इसे बदल सकते हैं: 147 | 148 | QrCode::encoding('UTF-8')->generate('Make me a QrCode with special symbols ♠♥!!'); 149 | 150 | | वर्ण एनकोडर | 151 | | --- | 152 | | ISO-8859-1 | 153 | | ISO-8859-2 | 154 | | ISO-8859-3 | 155 | | ISO-8859-4 | 156 | | ISO-8859-5 | 157 | | ISO-8859-6 | 158 | | ISO-8859-7 | 159 | | ISO-8859-8 | 160 | | ISO-8859-9 | 161 | | ISO-8859-10 | 162 | | ISO-8859-11 | 163 | | ISO-8859-12 | 164 | | ISO-8859-13 | 165 | | ISO-8859-14 | 166 | | ISO-8859-15 | 167 | | ISO-8859-16 | 168 | | SHIFT-JIS | 169 | | WINDOWS-1250 | 170 | | WINDOWS-1251 | 171 | | WINDOWS-1252 | 172 | | WINDOWS-1256 | 173 | | UTF-16BE | 174 | | UTF-8 | 175 | | ASCII | 176 | | GBK | 177 | | EUC-KR | 178 | 179 | >`Could not encode content to ISO-8859-1` त्रुटि का अर्थ है कि ग़लत वर्ण एनकोड का प्रकार उपयोग किया गया है। यदि आप अनिश्चित हैं तो हमारा सुझाव है कि `UTF-8` का उपयोग करें। 180 | 181 | #### Merge(विलय) 182 | 183 | `मर्ज` विधि एक QrCode पर एक छवि विलीन करता है। यह आमतौर पर एक QrCode के भीतर लोगो रखने के लिए प्रयोग किया जाता है। 184 | 185 | QrCode::merge($filename, $percentage, $absolute); 186 | 187 | //Generates a QrCode with an image centered in the middle. 188 | QrCode::format('png')->merge('path-to-image.png')->generate(); 189 | 190 | //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. 191 | QrCode::format('png')->merge('path-to-image.png', .3)->generate(); 192 | 193 | //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. 194 | QrCode::format('png')->merge('http://www.google.com/someimage.png', .3, true)->generate(); 195 | 196 | >`मर्`ज विधि में अभी केवल PNG ही समर्थित है। 197 | >filepath app, base path से सापेक्षित है यदि `$absolute` सेट है `false` पर। इसे `true` से बदलें absolute paths पाने के लिए। 198 | 199 | >आपको `merge` विधि का इस्तेमाल करते समय उच्च स्तर के त्रुटि सुधार का उपयोग करना चाहिए। सुझाव है कि `errorCorrection('H')` का उपयोग करें। 200 | 201 | ![Merged Logo](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/merged-qrcode.png?raw=true) 202 | 203 | #### Merge Binary String(द्विआधारी स्ट्रिंग का विलय) 204 | 205 | `mergeString` विधि `मर्ज कॉल` वाले ही परिणाम पाने के लिए प्रयोग किया जा सकता है, सिवाय इसके कि इसमे आपको फ़ाइल पथ की बजाय फाइल की एक प्रतिनिधित्व स्ट्रिंग प्रदान करनी होती है। यह तब उपयोगी है जब `स्टोरेज` मुखौटे के साथ काम किया जाता है। इसका इंटरफेस मर्ज कॉल की तरह ही है। 206 | 207 | QrCode::mergeString(Storage::get('path/to/image.png'), $percentage); 208 | 209 | //Generates a QrCode with an image centered in the middle. 210 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'))->generate(); 211 | 212 | //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. 213 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'), .3)->generate(); 214 | 215 | >As with the normal `merge` call, only PNG is supported at this time. The same applies for error correction, high levels are recommened. 216 | 217 | #### Advance Usage(अग्रिम उपयोग) 218 | 219 | सभी तरीके श्रृंखलन का समर्थन करते हैं। `generate` तरीका अंत मे कॉल करना तथा तरीका कोई `format` का बदलाव सबसे पहले कॉल करना आवश्यक है। जैसे की आप निम्न मे से कोई भी रन कर सकते हैं: 220 | 221 | QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate('Make me a QrCode!'); 222 | QrCode::format('png')->size(399)->color(40,40,40)->generate('Make me a QrCode!'); 223 | 224 | आप बिना फ़ाइल सुरक्षित करे, कच्चे स्ट्रिंग व `base64_encode` की एन्कोडेंग देकर भी PNG प्रदर्शित कर सकते हैं। 225 | 226 | 227 | 228 | 229 | ## सहायक 230 | 231 | #### सहायक क्या है ? 232 | 233 | सहायक QrCode का निर्माण करने का साधारण तरीका है जो स्कैन करने पर पाठक से निश्चित कार्रवाई करवाते हैं। 234 | 235 | #### E-Mail (ई-मेल) 236 | 237 | यह सहायक ई-मेल qrcode का निर्माण करता है जो ई-मेल का पता, विषय तथा शरीर भरने मे सक्षम होता है। 238 | 239 | QrCode::email($to, $subject, $body); 240 | 241 | //Fills in the to address 242 | QrCode::email('foo@bar.com'); 243 | 244 | //Fills in the to address, subject, and body of an e-mail. 245 | QrCode::email('foo@bar.com', 'This is the subject.', 'This is the message body.'); 246 | 247 | //Fills in just the subject and body of an e-mail. 248 | QrCode::email(null, 'This is the subject.', 'This is the message body.'); 249 | 250 | #### Geo (जियो) 251 | 252 | यह सहायक अक्षांश व देशान्तर का निर्माण करता है जिसे फोन पढ़ व Google Maps (गूगल मांचित्र) या अन्य app मे खोल सकता है। 253 | 254 | QrCode::geo($latitude, $longitude); 255 | 256 | QrCode::geo(37.822214, -122.481769); 257 | 258 | #### Phone Number (फ़ोन नंबर) 259 | 260 | इस सहायक द्वारा उत्तपन्‍न qrCode स्कैन करने पर नंबर डायल किया जा सकता है। 261 | 262 | QrCode::phoneNumber($phoneNumber); 263 | 264 | QrCode::phoneNumber('555-555-5555'); 265 | QrCode::phoneNumber('1-800-Laravel'); 266 | 267 | #### SMS (पाठ संदेश) 268 | 269 | इस सहायक द्वारा उत्तपन्‍न QrCode स्कैन करने पर SMS संदेश का भेजने का पता तथा संदेश का शरीर पहले से भरा जा सकता है। 270 | 271 | QrCode::SMS($phoneNumber, $message); 272 | 273 | //Creates a text message with the number filled in. 274 | QrCode::SMS('555-555-5555'); 275 | 276 | //Creates a text message with the number and message filled in. 277 | QrCode::SMS('555-555-5555', 'Body of the message'); 278 | 279 | #### Wi-Fi (वाई-फाई) 280 | 281 | इस सहायक द्वारा उत्तपन्‍न qrCode स्कैन करने पर वाईफाई नेटवर्क से जुड़ा जा सकता है। 282 | 283 | QrCode::wiFi([ 284 | 'encryption' => 'WPA/WEP', 285 | 'ssid' => 'SSID of the network', 286 | 'password' => 'Password of the network', 287 | 'hidden' => 'Whether the network is a hidden SSID or not.' 288 | ]); 289 | 290 | //Connects to an open WiFi network. 291 | QrCode::wiFi([ 292 | 'ssid' => 'Network Name', 293 | ]); 294 | 295 | //Connects to an open, hidden WiFi network. 296 | QrCode::wiFi([ 297 | 'ssid' => 'Network Name', 298 | 'hidden' => 'true' 299 | ]); 300 | 301 | //Connects to an secured, WiFi network. 302 | QrCode::wiFi([ 303 | 'ssid' => 'Network Name', 304 | 'encryption' => 'WPA', 305 | 'password' => 'myPassword' 306 | ]); 307 | 308 | >वाई-फाई स्कैनिंग Apple उत्पादों में अभी समर्थित नही है। 309 | 310 | 311 | ## साधारण QrCode उपयोग 312 | 313 | आप निम्न तालिका मे से `generate` अनुभाग मे पाए गये उपसर्ग का उपयोग करके और अधिक उन्नत जानकारी स्टोर करने के लिए QrCode का निर्माण कर सकते हैं: 314 | 315 | QrCode::generate('http://www.simplesoftware.io'); 316 | 317 | 318 | | प्रयोग | उपसर्ग | उदाहरण | 319 | | --- | --- | --- | 320 | | Website URL | http:// | http://www.simplesoftware.io | 321 | | Secured URL | https:// | https://www.simplesoftware.io | 322 | | E-mail Address | mailto: | mailto:support@simplesoftware.io | 323 | | Phone Number | tel: | tel:555-555-5555 | 324 | | Text (SMS) | sms: | sms:555-555-5555 | 325 | | Text (SMS) With Pretyped Message | sms: | sms::I am a pretyped message | 326 | | Text (SMS) With Pretyped Message and Number | sms: | sms:555-555-5555:I am a pretyped message | 327 | | Geo Address | geo: | geo:-78.400364,-85.916993 | 328 | | MeCard | mecard: | MECARD:Simple, Software;Some Address, Somewhere, 20430;TEL:555-555-5555;EMAIL:support@simplesoftware.io; | 329 | | VCard | BEGIN:VCARD | [See Examples](https://en.wikipedia.org/wiki/VCard) | 330 | | Wifi | wifi: | wifi:WEP/WPA;SSID;PSK;Hidden(True/False) | 331 | 332 | 333 | ## लरावेल(Laravel) के बाहर उपयोग 334 | 335 | आप `BaconQrCodeGenerator` नमक नयी कक्षा स्थापित करके इस पैकेज का लरावेल के बाहर भी उपयोग कर सकते हैं। 336 | 337 | use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator; 338 | 339 | $qrcode = new BaconQrCodeGenerator; 340 | $qrcode->size(500)->generate('Make a qrcode without Laravel!'); 341 | -------------------------------------------------------------------------------- /docs/imgs/200-pixels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/200-pixels.png -------------------------------------------------------------------------------- /docs/imgs/250-pixels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/250-pixels.png -------------------------------------------------------------------------------- /docs/imgs/circle-eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/circle-eye.png -------------------------------------------------------------------------------- /docs/imgs/diagonal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/diagonal.png -------------------------------------------------------------------------------- /docs/imgs/dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/dot.png -------------------------------------------------------------------------------- /docs/imgs/example-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/example-1.png -------------------------------------------------------------------------------- /docs/imgs/example-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/example-2.png -------------------------------------------------------------------------------- /docs/imgs/eye-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/eye-0.png -------------------------------------------------------------------------------- /docs/imgs/eye-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/eye-1.png -------------------------------------------------------------------------------- /docs/imgs/eye-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/eye-2.png -------------------------------------------------------------------------------- /docs/imgs/horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/horizontal.png -------------------------------------------------------------------------------- /docs/imgs/inverse_diagonal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/inverse_diagonal.png -------------------------------------------------------------------------------- /docs/imgs/make-me-into-a-qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/make-me-into-a-qrcode.png -------------------------------------------------------------------------------- /docs/imgs/merged-qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/merged-qrcode.png -------------------------------------------------------------------------------- /docs/imgs/radial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/radial.png -------------------------------------------------------------------------------- /docs/imgs/red-25-transparent-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/red-25-transparent-background.png -------------------------------------------------------------------------------- /docs/imgs/red-25-transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/red-25-transparent.png -------------------------------------------------------------------------------- /docs/imgs/red-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/red-background.png -------------------------------------------------------------------------------- /docs/imgs/red-qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/red-qrcode.png -------------------------------------------------------------------------------- /docs/imgs/round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/round.png -------------------------------------------------------------------------------- /docs/imgs/vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/docs/imgs/vertical.png -------------------------------------------------------------------------------- /docs/it/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode.svg?branch=master)](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode) [![Latest Stable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/stable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Latest Unstable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/unstable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![License](https://poser.pugx.org/simplesoftwareio/simple-qrcode/license.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Total Downloads](https://poser.pugx.org/simplesoftwareio/simple-qrcode/downloads.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 2 | 3 | 4 | - [Introduzione](#docs-introduction) 5 | - [Traduzioni](#docs-translations) 6 | - [Configurazione](#docs-configuration) 7 | - [Semplici Utilizzi](#docs-ideas) 8 | - [Utilizzo](#docs-usage) 9 | - [Helpers](#docs-helpers) 10 | - [Uso generico dei QrCode](#docs-common-usage) 11 | - [Uso al di fuori di Laravel](#docs-outside-laravel) 12 | 13 | 14 | ## Introduzione 15 | Simple QrCode è un semplice wrapper per il popolare framework Laravel basato sul bellissimo lavoro [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode). Abbiamo creato un'interfaccia familiare e semplice da installare per gli utenti Laravel. 16 | 17 | 18 | ## Traduzioni 19 | Siamo alla ricerca di utenti che ci aiutino a tradurre la documentazione in Arabo, Spagnolo, Francese, Coreano o Giapponese. Se pensate di potercela fare non esitate a fare una pull request! 20 | 21 | 22 | ## Configurazione 23 | 24 | #### Composer 25 | 26 | Per prima cosa, aggiungete il pacchetto di Simple QrCode al file `require` in `composer.json`: 27 | 28 | "require": { 29 | "simplesoftwareio/simple-qrcode": "~2" 30 | } 31 | 32 | Ora lanciate il comando `composer update`. 33 | 34 | #### Service Provider 35 | 36 | ###### Laravel <= 5.4 37 | Registrate `SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class` nel vostro `config/app.php` all'interno dell'array `providers`. 38 | 39 | #### Alias 40 | 41 | ###### Laravel <= 5.4 42 | Infine, registrate `'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class` nel vostro file di configurazione `config/app.php` all'interno dell'array `aliases`. 43 | 44 | 45 | ## Semplici Utilizzi 46 | 47 | #### Print View 48 | 49 | Uno degli usi principali di questo pacchetto è la possibilità di avere codici Qr in tutte le nostre print views. Questo permette all'utente di tornare alla pagina originale semplicemente facendo lo scan del codice. Tutto ciò è possibile aggiungendo le seguenti linee nel nostro footer.blade.php. 50 | 51 |
52 | {!! QrCode::size(100)->generate(Request::url()); !!} 53 |

Scansionami per tornare alla pagina principale.

54 |
55 | 56 | #### Incorporare un QrCode 57 | 58 | Potreste incorporare un codice Qr in una e-mail per permettere agli utenti uno scan immediato. Il seguente è un esempio di come potresti fare tutto ciò con Laravel. 59 | 60 | //Inside of a blade template. 61 | 62 | 63 | 64 | ## Utilizzo 65 | 66 | #### Utilizzo Base 67 | 68 | Usare il generatori di codici Qr è molto semplice. La sintassi più semplice è: 69 | 70 | QrCode::generate('Trasformami in un QrCode!'); 71 | 72 | Questo comando produrrà un codice Qr che dice "Trasformami in un QrCode!" 73 | 74 | #### Generate 75 | 76 | `Generate` è usato per creare codici Qr: 77 | 78 | QrCode::generate('Trasformami in un QrCode!'); 79 | 80 | >Attenzione! Questo metodo deve essere chiamato per ultimo se lo si usa all'interno di una catena (chain). 81 | 82 | `Generate` restituirà, di default, una stringa di immagini SVG. Puoi stamparla direttamente in un browser recente dal sistema Blade di Laravel con il seguente codice: 83 | 84 | {!! QrCode::generate('Make me into a QrCode!'); !!} 85 | 86 | Il metodo `generate` accetta un secondo parametro che indica la directory nella quale verrà salvato il codice Qr. 87 | 88 | QrCode::generate('Make me into a QrCode!', '../public/qrcodes/qrcode.svg'); 89 | 90 | #### Variazione del formato 91 | 92 | >QrCode Generator è impostato di default per generare immagini SVG. 93 | 94 | >Attenzione! Il metodo `format` deve essere chiamato prima di qualunque altra opzione di formato come `size`, `color`, `backgroundColor`, o `margin`. 95 | 96 | Momentaneamente, sono supportati tre formati: PNG, EPS e SVG. Per cambiare il formato usare uno dei seguenti comandi: 97 | 98 | QrCode::format('png'); //Genererà un'immagine PNG 99 | QrCode::format('eps'); //Genererà un'immagine EPS 100 | QrCode::format('svg'); //Genererà un'immagine SVG 101 | 102 | #### Variazione della grandezza 103 | 104 | >QrCode Generator restituirà, di default, la più piccola grandezza possibile per creare il QrCode. 105 | 106 | Puoi cambiare la grandezza del codice Qr usando il metodo `size`. Basta specificare la grandezza desiderata, in pixel, usando la seguente sintassi: 107 | 108 | QrCode::size(100); 109 | 110 | #### Variazione del colore 111 | 112 | >Fai attenzione quando cambi il colore di un QrCode! Alcuni lettori potrebbero avere dei problemi a leggere dei codici Qr colorati diversamente. 113 | 114 | Tutti i colori dovranno essere espressi in RGB (Rosso Verde Blu). Puoi cambiare il colore di un QrCode usando questa sintassi: 115 | 116 | QrCode::color(255,0,255); 117 | 118 | Puoi anche cambiare il colore di sfondo con la seguente istruzione: 119 | 120 | QrCode::backgroundColor(255,255,0); 121 | 122 | #### Variazione del margine 123 | 124 | E' anche possibile variare il margine attorno al codice Qr. Basta infatti specificare la grandezza del margine nella seguente sintassi: 125 | 126 | QrCode::margin(100); 127 | 128 | #### Correzione dell'errore 129 | 130 | Cambiare il livello di correzione dell'errore è facile. Per farlo, usare questa sintassi: 131 | 132 | QrCode::errorCorrection('H'); 133 | 134 | Seguono le opzioni supportate dal metodo `errorCorrection`. 135 | 136 | | Error Correction | Assurance Provided | 137 | | --- | --- | 138 | | L | 7% of codewords can be restored. | 139 | | M | 15% of codewords can be restored. | 140 | | Q | 25% of codewords can be restored. | 141 | | H | 30% of codewords can be restored. | 142 | 143 | >Più error correction viene usata, più sarà grande il QrCode e meno dati sarà in grando di contenere. Leggi di più a riguardo [error correction](http://en.wikipedia.org/wiki/QR_code#Error_correction). 144 | 145 | #### Encoding 146 | 147 | Puoi cambiare l'encoding dei caratteri utilizzato per creare il codice Qr. Di default è selezionato `ISO-8859-1`. Leggi di più a riguardo [character encoding](http://en.wikipedia.org/wiki/Character_encoding) 148 | Puoi cambiare l'encoding utilizzando: 149 | 150 | QrCode::encoding('UTF-8')->generate('Trasformami in un QrCode con simboli speciali ??!!'); 151 | 152 | | Encoder dei caratteri | 153 | | --- | 154 | | ISO-8859-1 | 155 | | ISO-8859-2 | 156 | | ISO-8859-3 | 157 | | ISO-8859-4 | 158 | | ISO-8859-5 | 159 | | ISO-8859-6 | 160 | | ISO-8859-7 | 161 | | ISO-8859-8 | 162 | | ISO-8859-9 | 163 | | ISO-8859-10 | 164 | | ISO-8859-11 | 165 | | ISO-8859-12 | 166 | | ISO-8859-13 | 167 | | ISO-8859-14 | 168 | | ISO-8859-15 | 169 | | ISO-8859-16 | 170 | | SHIFT-JIS | 171 | | WINDOWS-1250 | 172 | | WINDOWS-1251 | 173 | | WINDOWS-1252 | 174 | | WINDOWS-1256 | 175 | | UTF-16BE | 176 | | UTF-8 | 177 | | ASCII | 178 | | GBK | 179 | | EUC-KR | 180 | 181 | >L'errore `Could not encode content to ISO-8859-1` significa che si sta usando l'encoding erraro. E' raccomandato usare `UTF-8` se non si è sicuri. 182 | 183 | #### Merge 184 | 185 | Il metodo `merge` unisce un immagine con un QrCode. Il merge è molto usato per inserire loghi in un codice Qr. 186 | 187 | QrCode::merge($filename, $percentage, $absolute); 188 | 189 | //Genera un QrCode con una immagine al centro. 190 | QrCode::format('png')->merge('path-to-image.png')->generate(); 191 | 192 | //Genera un QrCode con una immagine al centro. L'immagine inserita occupa il 30% del codice Qr. 193 | QrCode::format('png')->merge('path-to-image.png', .3)->generate(); 194 | 195 | //Genera un QrCode con una immagine al centro. L'immagine inserita occupa il 30% del codice Qr. 196 | QrCode::format('png')->merge('http://www.google.com/someimage.png', .3, true)->generate(); 197 | 198 | >Il metodo `merge` supporta solamente il formato PNG. 199 | >Il percorso specificato è relativo alla base path se `$absolute` è impostata su `false`. Cambiare questa variabile in `true` per utilizzare percorsi assoluti. 200 | 201 | >Dovresti usare un alto livello di error correction quando usi il metodo `merge` per assicurarti che il Qr sia ancora leggibile. Raccomandiamo di usare `errorCorrection('H')`. 202 | 203 | ![Merged Logo](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/merged-qrcode.png?raw=true) 204 | 205 | #### Merge Binary String 206 | 207 | Il metodo `mergeString` può essere usato per ottenere quasi lo stesso risultato di `merge`, con la differenza che permette di inserire una rappresentazione testuale del file al posto del percorso. Questo è utile quando si lavora con la facade `Storage`. La sua interfaccia è molto simile a quella di `merge`. 208 | 209 | QrCode::mergeString(Storage::get('path/to/image.png'), $percentage); 210 | 211 | //Genera un QrCode con una immagine al centro. 212 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'))->generate(); 213 | 214 | //Genera un QrCode con una immagine al centro. L'immagine inserita occupa il 30% del codice Qr. 215 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'), .3)->generate(); 216 | 217 | >Come la chiamata a `merge`, anche questa volta è supportato solamente il formato PNG. Lo stesso vale per gli error correction, H è il valore raccomandato. 218 | 219 | #### Utilizzo Avanzato 220 | 221 | Tutti i metodi supportano il chaining. Il metodo `generate` deve essere chiamato per ultimo e tutti gli eventuali metodi `format` devono essere chiamati per primi. Per esempio sono validi i seguenti: 222 | 223 | QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate('Make me a QrCode!'); 224 | QrCode::format('png')->size(399)->color(40,40,40)->generate('Trasformami in un QrCode!'); 225 | 226 | Puoi mostrare un'immagine PNG senza salvare il file relativo impostando una stringa e scegliendo l'encoding `base64_encode`. 227 | 228 | 229 | 230 | 231 | ## Helpers 232 | 233 | #### Cosa sono gli helpers? 234 | 235 | Gli Helpers sono un metodo molto semplice per creare codici Qr che permettono al lettore di eseguire una certa azione quando scansionati. 236 | 237 | #### E-Mail 238 | 239 | Questo helper genera un QrCode in grado di riempire i campi di una e-mail quali indirizzo, oggetto e corpo. 240 | 241 | QrCode::email($to, $subject, $body); 242 | 243 | //Fills in the to address 244 | QrCode::email('foo@bar.com'); 245 | 246 | //Fills in the to address, subject, and body of an e-mail. 247 | QrCode::email('foo@bar.com', 'Questo è l'oggetto.', 'Questo è il corpo del messaggio.'); 248 | 249 | //Fills in just the subject and body of an e-mail. 250 | QrCode::email(null, 'Questo è l'oggetto.', 'Questo è il corpo del messaggio.'); 251 | 252 | #### Geo 253 | 254 | Questo helper genera una latitudine e una longitudine che un telefono può leggere ed aprire con Google Maps o applicazioni simili. 255 | 256 | QrCode::geo($latitude, $longitude); 257 | 258 | QrCode::geo(37.822214, -122.481769); 259 | 260 | #### Numeri di Telefono 261 | 262 | Questo helper genera un QrCode che, una volta scansionato, digita un numero di telefono. 263 | 264 | QrCode::phoneNumber($phoneNumber); 265 | 266 | QrCode::phoneNumber('555-555-5555'); 267 | QrCode::phoneNumber('1-800-Laravel'); 268 | 269 | #### SMS (Messaggi) 270 | 271 | Questo helper crea messaggi SMS che possono essere precompilati con il destinatario e il corpo del messaggio. 272 | 273 | QrCode::SMS($phoneNumber, $message); 274 | 275 | //Creates a text message with the number filled in. 276 | QrCode::SMS('555-555-5555'); 277 | 278 | //Creates a text message with the number and message filled in. 279 | QrCode::SMS('555-555-5555', 'Corpo del messaggio.'); 280 | 281 | #### WiFi 282 | 283 | Questo helper crea codici Qr scansionabili che permettono la connessione del telefono ad una determinata rete WiFi. 284 | 285 | QrCode::wiFi([ 286 | 'encryption' => 'WPA/WEP', 287 | 'ssid' => 'SSID della rete', 288 | 'password' => 'Password della rete', 289 | 'hidden' => 'Whether the network is a hidden SSID or not.' 290 | ]); 291 | 292 | //Connects to an open WiFi network. 293 | QrCode::wiFi([ 294 | 'ssid' => 'Nome Rete', 295 | ]); 296 | 297 | //Connects to an open, hidden WiFi network. 298 | QrCode::wiFi([ 299 | 'ssid' => 'Nome Rete', 300 | 'hidden' => 'true' 301 | ]); 302 | 303 | //Connects to an secured, WiFi network. 304 | QrCode::wiFi([ 305 | 'ssid' => 'Nome Rete', 306 | 'encryption' => 'WPA', 307 | 'password' => 'miaPassword' 308 | ]); 309 | 310 | >La scansione WiFi non è al momento supportata sui dispositivi Apple. 311 | 312 | 313 | ##Uso generico dei QrCode 314 | 315 | Puoi utilizzare un prefisso della tabella sottostante per generare dei codici Qr in grado di contenere maggiori informazioni: 316 | 317 | QrCode::generate('http://www.simplesoftware.io'); 318 | 319 | 320 | | Usage | Prefix | Example | 321 | | --- | --- | --- | 322 | | Website URL | http:// | http://www.simplesoftware.io | 323 | | Secured URL | https:// | https://www.simplesoftware.io | 324 | | E-mail Address | mailto: | mailto:support@simplesoftware.io | 325 | | Phone Number | tel: | tel:555-555-5555 | 326 | | Text (SMS) | sms: | sms:555-555-5555 | 327 | | Text (SMS) With Pretyped Message | sms: | sms::I am a pretyped message | 328 | | Text (SMS) With Pretyped Message and Number | sms: | sms:555-555-5555:I am a pretyped message | 329 | | Geo Address | geo: | geo:-78.400364,-85.916993 | 330 | | MeCard | mecard: | MECARD:Simple, Software;Some Address, Somewhere, 20430;TEL:555-555-5555;EMAIL:support@simplesoftware.io; | 331 | | VCard | BEGIN:VCARD | [See Examples](https://en.wikipedia.org/wiki/VCard) | 332 | | Wifi | wifi: | wifi:WEP/WPA;SSID;PSK;Hidden(True/False) | 333 | 334 | 335 | ##Uso al di fuori di Laravel 336 | 337 | Puoi usare questo package al di fuori di Laravel istanziando una nuova classe `BaconQrCodeGenerator`. 338 | 339 | use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator; 340 | 341 | $qrcode = new BaconQrCodeGenerator; 342 | $qrcode->size(500)->generate('Crea un QrCode senza Laravel!'); 343 | -------------------------------------------------------------------------------- /docs/ja/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode.svg?branch=master)](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode) [![Latest Stable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/stable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Latest Unstable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/unstable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![License](https://poser.pugx.org/simplesoftwareio/simple-qrcode/license.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Total Downloads](https://poser.pugx.org/simplesoftwareio/simple-qrcode/downloads.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 2 | 3 | #### [Deutsch](http://www.simplesoftware.io/#/docs/simple-qrcode/de) | [Español](http://www.simplesoftware.io/#/docs/simple-qrcode/es) | [Français](http://www.simplesoftware.io/#/docs/simple-qrcode/fr) | [Italiano](http://www.simplesoftware.io/#/docs/simple-qrcode/it) | [Português](http://www.simplesoftware.io/#/docs/simple-qrcode/pt-br) | [Русский](http://www.simplesoftware.io/#/docs/simple-qrcode/ru) | [日本語](http://www.simplesoftware.io/#/docs/simple-qrcode/ja) | [한국어](http://www.simplesoftware.io/#/docs/simple-qrcode/kr) | [हिंदी](http://www.simplesoftware.io/#/docs/simple-qrcode/hi) | [简体中文](http://www.simplesoftware.io/#/docs/simple-qrcode/zh-cn) | [العربية](https://www.simplesoftware.io/#/docs/simple-qrcode/ar) 4 | 5 | - [イントロダクション](#docs-introduction) 6 | - [アップグレードガイド](#docs-upgrade) 7 | - [翻訳](#docs-translations) 8 | - [設定](#docs-configuration) 9 | - [簡単な使い方](#docs-ideas) 10 | - [使い方](#docs-usage) 11 | - [ヘルパー](#docs-helpers) 12 | - [よくあるQRコードの利用方法](#docs-common-usage) 13 | - [Laravel外での使い方](#docs-outside-laravel) 14 | 15 | 16 | ## イントロダクション 17 | Simple QrCode は [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode) を元に作られた 人気のあるLaravelフレームワークで簡単に使う事のできるラッパーです。Laravelユーザーになじみのある使い方ができるように開発されました。 18 | 19 | ![Example 1](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/example-1.png?raw=true) ![Example 2](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/example-2.png?raw=true) 20 | 21 | 22 | ## 翻訳 23 | この文書の翻訳を手伝ってくれるアラビア語、スペイン語、フランス語、韓国語、日本語を話すユーザーを探しています。 翻訳が可能な場合はプルリクエストを作成してください。 24 | 25 | 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! 26 | 27 | 28 | ## アップグレード 29 | 30 | v2とv3からのアップデートは、`composer.json`ファイル内のバージョン指定を`~4`に変更してください。 31 | 32 | PNG形式の画像を生成する場合は、**必ず**`imagick` PHP拡張をインストールしてください。 33 | 34 | #### v4 35 | 36 | > 4.1.0を作成するときのミスで、後方互換性が失われる変更がmasterブランチに入りました。 37 | > `generate`メソッドは現在は `Illuminate\Support\HtmlString` のインスタンスを返します。 38 | > 詳細は https://github.com/SimpleSoftwareIO/simple-qrcode/issues/205 を参照してください。 39 | 40 | v3での読み込みに関する問題を引き起こすLaravelファサードの問題がありました。 41 | この問題を解決するためには、後方互換性が失われる変更を加える必要があり、v4がリリースされるに至った経緯があります。 42 | v2からのアップグレードの場合は既存コードの変更は必要ありません。 43 | 以下の説明はv3ユーザー向けです。 44 | 45 | 全ての`QrCode`ファサードへの参照は以下のように変更する必要があります: 46 | 47 | ``` 48 | use SimpleSoftwareIO\QrCode\Facades\QrCode; 49 | ``` 50 | 51 | 52 | ## 設定 53 | 54 | #### Composer 55 | 56 | `composer require simplesoftwareio/simple-qrcode "~4"` を実行してパッケージを追加します。 57 | 58 | Laravelが自動的に必要なパッケージをインストールします。 59 | 60 | 61 | ## 簡単な使い方 62 | 63 | #### 画面に表示する 64 | 65 | このパッケージの主なアイテムは 画面に表示する機能です。 66 | カスタマーはコードをスキャンするだけで 画面に戻ることが出来ます。以下の内容を footer.blade.php に追加しました。 67 | 68 |
69 | {!! QrCode::size(100)->generate(Request::url()); !!} 70 |

スキャンして元のページに戻ります

71 |
72 | 73 | #### QRコードを埋め込む 74 | 75 | ユーザーがすばやくスキャンできるように、電子メールの中にQRコードを埋め込むことができます。 以下はLaravelでこれを行う方法の例です。 76 | 77 | // Bladeテンプレート内で以下のように書きます 78 | 79 | 80 | 81 | ## 使い方 82 | 83 | #### 基本的な使い方 84 | 85 | 使い方はとても簡単です。 最も基本的な構文は次のとおりです。 86 | 87 | QrCode::generate('Make me into a QrCode!'); 88 | 89 | これで「Make me into a QrCode!」というQRコードが作成されます。 90 | 91 | ![QRコード生成例](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/make-me-into-a-qrcode.png?raw=true) 92 | 93 | #### 生成する 94 | 95 | `generate`はQRコードを生成するのに使われます。 96 | 97 | QrCode::generate('Make me into a QrCode!'); 98 | 99 | >要注意: チェーン内で使用する場合は、このメソッドを最後に呼び出す必要があります。 100 | 101 | `generate`はデフォルトで SVG イメージ文字列を返します。 102 | Laravel Blade に以下の様に書くことで モダンなブラウザに表示することができます。 103 | 104 | {!! QrCode::generate('Make me into a QrCode!'); !!} 105 | 106 | `generate`メソッドの第二引数はQrCodeを保存するパスとファイルネームです。 107 | 108 | QrCode::generate('Make me into a QrCode!', '../public/qrcodes/qrcode.svg'); 109 | 110 | #### フォーマットを変える `(string$ format)` 111 | 112 | >QrCode Generator のデフォルトフォーマットはSVGイメージです。 113 | 114 | >要注意: `format`メソッドは` size`、 `color`、` backgroundColor`、 `margin`のような他のフォーマットオプションの前に呼ばれなければなりません。 115 | 116 | 現在PNG、EPS、およびSVGの 3つのフォーマットがサポートされています。 117 | フォーマットを変更するには、次のコードを使用します。 118 | 119 | QrCode::format('png'); //Will return a PNG image 120 | QrCode::format('eps'); //Will return a EPS image 121 | QrCode::format('svg'); //Will return a SVG image 122 | 123 | #### サイズの変更 `(int $size)` 124 | 125 | >QrCode GeneratorはデフォルトでQRコードを作成するためにピクセルで可能な最小サイズを返します。 126 | 127 | `size`メソッドを使うことでQrCodeのサイズを変えることができます。 次の構文を使用して、必要なサイズをピクセル単位で指定します。 128 | 129 | QrCode::size(100); 130 | 131 | #### 色の変更 `(int $red, int $green, int $blue, int $alpha = null)` 132 | 133 | >要注意 色を変えるときには注意してください。QrCodeの読み込みが難しくなる 色が有ります。 134 | 135 | すべての色はRGB (Red Green Blue)で表現する必要があります。 次のようにしてQrCodeの色を変更できます: 136 | 137 | QrCode::color(255,0,255); 138 | 139 | 背景色の変更もサポートされており、同じ方法で表現できます。 140 | 141 | QrCode::backgroundColor(255,255,0); 142 | 143 | #### 背景色の変更 `(int $red, int $green, int $blue, int $alpha = null)` 144 | 145 | `backgroudColor`メソッドを呼び出すことでQRコードの背景色を変更できます。 146 | 147 | QrCode::backgroundColor(255, 0, 0); // 赤が背景色のQRコード 148 | QrCode::backgroundColor(255, 0, 0, 25); // 透明度25%で赤が背景色のQRコード 149 | 150 | ![赤が背景色のQRコード](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/red-background.png?raw=true) ![赤が背景色で透過なQRコード](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/red-25-transparent-background.png?raw=true) 151 | 152 | #### グラデーション `(int $startRed, int $startGreen, int $startBlue, int $endRed, int $endGreen, int $endBlue, string $type)` 153 | 154 | `gradient`メソッドを呼び出すことでQRコードにグラデーションを適用することができます。 155 | 156 | 以下のグラデーションタイプがサポートされています: 157 | 158 | | タイプ | 例 | 159 | |--------------------|--------------------------------------------------------------------------------------------------------------------------------------| 160 | | `vertical` | ![Vertical](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/vertical.png?raw=true) | 161 | | `horizontal` | ![Horizontal](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/horizontal.png?raw=true) | 162 | | `diagonal` | ![Diagonal](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/diagonal.png?raw=true) | 163 | | `inverse_diagonal` | ![Inverse Diagonal](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/inverse_diagonal.png?raw=true) | 164 | | `radial` | ![Radial](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/radial.png?raw=true) | 165 | 166 | #### 切り出しシンボル色 `(int $eyeNumber, int $innerRed, int $innerGreen, int $innerBlue, int $outterRed = 0, int $outterGreen = 0, int $outterBlue = 0)` 167 | 168 | `eyeColor`メソッドを呼び出すことで切り出しシンボルの色を変更することもできます。 169 | 170 | QrCode::eyeColor(0, 255, 255, 255, 0, 0, 0); // シンボル番号`0`の色を変更します 171 | 172 | | シンボル番号 | 例 | 173 | |--------|-----------------------------------------------------------------------------------------------------------------| 174 | | `0` | ![Eye 0](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/eye-0.png?raw=true) | 175 | | `1` | ![Eye 1](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/eye-1.png?raw=true) | 176 | | `2` | ![Eye 2](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/eye-2.png?raw=true) | 177 | 178 | 179 | #### スタイル `(string $style, float $size = 0.5)` 180 | 181 | ブロックのスタイルは`style`メソッドを使用して`square`、`dot`、`round`に変更できます。 182 | これはQRコードの内部のブロックを変更します。 183 | 2つめのパラメーターは`dot`と`round`の大きさを指定します。 184 | 185 | QrCode::style('dot'); // `dot`スタイルに変更 186 | 187 | | スタイル | 例 | 188 | |----------|----------------------------------------------------------------------------------------------------------------------| 189 | | `square` | ![Square](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/200-pixels.png?raw=true) | 190 | | `dot` | ![Dot](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/dot.png) | 191 | | `round` | ![Round](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/round.png?raw=true) | 192 | 193 | #### 切り出しシンボルのスタイル `(string $style)` 194 | 195 | 切り出しシンボルのスタイルは`eye`メソッドを使用して`square`、`circle`に変更できます。 196 | 197 | QrCode::eye('circle'); // `circle`スタイルの切り出しシンボルに変更 198 | 199 | | スタイル | 例 | 200 | |----------|----------------------------------------------------------------------------------------------------------------------| 201 | | `square` | ![Square](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/200-pixels.png?raw=true) | 202 | | `circle` | ![Circle](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/circle-eye.png?raw=true) | 203 | 204 | #### マージンの変更 `(int $margin)` 205 | 206 | QRコード周辺のマージンを変更する機能もサポートされています。 次の構文を使用してマージンを指定します: 207 | 208 | QrCode::margin(100); 209 | 210 | #### エラー訂正 `(string $errorCorrection)` 211 | 212 | エラー訂正レベルの変更は簡単です。次のようにします: 213 | 214 | QrCode::errorCorrection('H'); 215 | 216 | `errorCorrection` メソッドによってサポートされているオプション値は以下の通りです: 217 | 218 | | エラー訂正レベル | 補償できる誤りの割合 | 219 | |----------|------------------| 220 | | L | 7% までの誤りが復元できます | 221 | | M | 15% までの誤りが復元できます | 222 | | Q | 25% までの誤りが復元できます | 223 | | H | 30% までの誤りが復元できます | 224 | 225 | > より高いエラー訂正レベルを使用すると、QRコードの大きさはより大きくなり、格納できるデータ量は少なくなります。詳しくは [エラー訂正(リンク先は英語です)](http://en.wikipedia.org/wiki/QR_code#Error_correction) をご覧ください。 226 | 227 | #### 文字コード `(string $encoding)` 228 | 229 | QRコードの生成に使われる文字コードを変更します。デフォルトでは`ISO-8859-1`が指定されています。 230 | 詳細は [文字コード](https://ja.wikipedia.org/wiki/%E6%96%87%E5%AD%97%E3%82%B3%E3%83%BC%E3%83%89) をお読みください。 231 | 232 | 以下のようにして文字コードを変更できます: 233 | 234 | QrCode::encoding('UTF-8')->generate('日本語や特殊な文字を含むQRコードも作れます♠♥!!'); 235 | 236 | | 文字コード | 237 | |--------------| 238 | | ISO-8859-1 | 239 | | ISO-8859-2 | 240 | | ISO-8859-3 | 241 | | ISO-8859-4 | 242 | | ISO-8859-5 | 243 | | ISO-8859-6 | 244 | | ISO-8859-7 | 245 | | ISO-8859-8 | 246 | | ISO-8859-9 | 247 | | ISO-8859-10 | 248 | | ISO-8859-11 | 249 | | ISO-8859-12 | 250 | | ISO-8859-13 | 251 | | ISO-8859-14 | 252 | | ISO-8859-15 | 253 | | ISO-8859-16 | 254 | | SHIFT-JIS | 255 | | WINDOWS-1250 | 256 | | WINDOWS-1251 | 257 | | WINDOWS-1252 | 258 | | WINDOWS-1256 | 259 | | UTF-16BE | 260 | | UTF-8 | 261 | | ASCII | 262 | | GBK | 263 | | EUC-KR | 264 | 265 | #### 重ね合わせ `(string $filepath, float $percentage = .2, bool $absolute = false)` 266 | 267 | `merge`メソッドはQRコードの上に画像を重ね合わせます。この機能は主にQRコードの中にロゴなどを配置する目的で使われます。 268 | 269 | //中央に画像を配置したQRコードを生成します 270 | QrCode::format('png')->merge('path-to-image.png')->generate(); 271 | 272 | //中央に画像を配置したQRコードを生成します。配置された画像は最大でQRコードの大きさの30%になります。 273 | QrCode::format('png')->merge('path-to-image.png', .3)->generate(); 274 | 275 | //中央に画像を配置したQRコードを生成します。配置された画像は最大でQRコードの大きさの30%になります。 276 | QrCode::format('png')->merge('http://www.google.com/someimage.png', .3, true)->generate(); 277 | 278 | > `merge`メソッドは現在のところPNGファイルのみをサポートしています。 279 | > 引数`$absolute`が`false`の場合はファイルパスはプロジェクトルートからの相対パスとして認識されます。絶対パスで指定する場合は`true`を指定してください。 280 | 281 | > `merge`メソッドを使用して画像を重ねているときでもQRコードを読み取れるようにするために、エラー訂正レベルも高くするべきです。`errorCorrection('H')`の使用を推奨します。 282 | 283 | ![ロゴを重ねた状態のサンプル](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/merged-qrcode.png?raw=true) 284 | 285 | #### バイナリ文字列による重ね合わせ `(string $content, float $percentage = .2)` 286 | 287 | `mergeString`メソッドは、ファイルを指定する代わりにバイナリ文字列を受け取る点を除いては`merge`メソッドと同様の挙動になります。 288 | 289 | // 中央に画像を配置したQRコードを生成します 290 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'))->generate(); 291 | 292 | // 中央に画像を配置したQRコードを生成します。配置された画像は最大でQRコードの大きさの30%になります。 293 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'), .3)->generate(); 294 | 295 | > `merge`メソッドと同様に、現時点ではPNG形式のみサポートしています。エラー訂正についても同様にHレベルを推奨します。 296 | 297 | #### 一歩進んだ使い方 298 | 299 | 全てのメソッドはチェーン呼び出しをサポートしています。`generate`メソッドは必ず最後に呼び出されなければいけません。例えば以下のようになります: 300 | 301 | QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate('Make me a QrCode!'); 302 | QrCode::format('png')->size(399)->color(40,40,40)->generate('Make me a QrCode!'); 303 | 304 | そのままのバイナリ文字列と`base64_encode`によるエンコーディングを組み合わせて、PNG画像をファイルとして保存することなく直接表示することもできます。 305 | 306 | 307 | 308 | 309 | ## ヘルパー 310 | 311 | #### ヘルパーとは 312 | 313 | ヘルパーは読み込み時に特定のアクションを実行するQRコードを簡単に生成するための機能です。 314 | 315 | #### ビットコイン 316 | 317 | このヘルパーはビットコインの支払用QRコードを生成します。[詳細情報(リンク先は英語です)](https://bitco.in/en/developer-guide#plain-text) 318 | 319 | QrCode::BTC($address, $amount); 320 | 321 | // 0.334BTCを指定したアドレスに送金 322 | QrCode::BTC('bitcoin address', 0.334); 323 | 324 | // いくつかのオプションを付けて0.334BTCを指定したアドレスに送金 325 | QrCode::size(500)->BTC('address', 0.0034, [ 326 | 'label' => 'my label', 327 | 'message' => 'my message', 328 | 'returnAddress' => 'https://www.returnaddress.com' 329 | ]); 330 | 331 | #### Eメール 332 | 333 | このヘルパーはEメールアドレス、件名、本文を指定してメールを送信するQRコードを生成します。 334 | 335 | QrCode::email($to, $subject, $body); 336 | 337 | // アドレスを指定します 338 | QrCode::email('foo@bar.com'); 339 | 340 | // アドレス、件名、本文を指定します 341 | QrCode::email('foo@bar.com', 'This is the subject.', 'This is the message body.'); 342 | 343 | // メールの件名と本文のみを指定します 344 | QrCode::email(null, 'This is the subject.', 'This is the message body.'); 345 | 346 | #### 位置情報 347 | 348 | このヘルパーは緯度と経度を指定してGoogleマップなどの地図アプリを開くQRコードを生成します。 349 | 350 | QrCode::geo($latitude, $longitude); 351 | 352 | QrCode::geo(37.822214, -122.481769); 353 | 354 | #### 電話番号 355 | 356 | このヘルパーは読み取ったときに電話をかけるQRコードを生成します。 357 | 358 | QrCode::phoneNumber($phoneNumber); 359 | 360 | QrCode::phoneNumber('555-555-5555'); 361 | QrCode::phoneNumber('1-800-Laravel'); 362 | 363 | #### SMS 364 | 365 | このヘルパーは送信先と本文を指定してSMSメッセージを作成するQRコードを生成します。 366 | 367 | QrCode::SMS($phoneNumber, $message); 368 | 369 | // 電話番号が入力済みの状態でSMSメッセージを作成します 370 | QrCode::SMS('555-555-5555'); 371 | 372 | // 電話番号と本文が入力済みの状態でSMSメッセージを作成します 373 | QrCode::SMS('555-555-5555', 'Body of the message'); 374 | 375 | #### Wi-Fi 376 | 377 | このヘルパーはWi-Fiの接続情報を自動入力するQRコードを生成します。 378 | 379 | QrCode::wiFi([ 380 | 'encryption' => 'WPA/WEP', 381 | 'ssid' => 'SSID of the network', 382 | 'password' => 'Password of the network', 383 | 'hidden' => 'Whether the network is a hidden SSID or not.' 384 | ]); 385 | 386 | // Wi-Fiのオープンネットワークに接続します 387 | QrCode::wiFi([ 388 | 'ssid' => 'Network Name', 389 | ]); 390 | 391 | // SSIDの公開されていないオープンネットワークに接続します 392 | QrCode::wiFi([ 393 | 'ssid' => 'Network Name', 394 | 'hidden' => 'true' 395 | ]); 396 | 397 | // 暗号化されたWi-Fiネットワーク接続します 398 | QrCode::wiFi([ 399 | 'ssid' => 'Network Name', 400 | 'encryption' => 'WPA', 401 | 'password' => 'myPassword' 402 | ]); 403 | 404 | > Wi-Fi接続情報のQRコードは現在のところApple社の製品ではサポートされていません。 405 | 406 | 407 | ## よくあるQRコードの利用方法 408 | 409 | `generate`メソッドに渡す文字列にプレフィックスを付けることで、様々なQRコードを生成できます。 410 | 411 | QrCode::generate('http://www.simplesoftware.io'); 412 | 413 | 414 | | 利用方法 | プレフィックス | 例 | 415 | |-----------------|-------------|----------------------------------------------------------------------------------------------------------| 416 | | ウェブサイトURL | http:// | http://www.simplesoftware.io | 417 | | 暗号化されたウェブサイトURL | https:// | https://www.simplesoftware.io | 418 | | Eメールアドレス | mailto: | mailto:support@simplesoftware.io | 419 | | 電話番号 | tel: | tel:555-555-5555 | 420 | | SMS | sms: | sms:555-555-5555 | 421 | | 本文入力済みSMS | sms: | sms::入力済みメッセージ | 422 | | 本文・宛先入力済みSMS | sms: | sms:555-555-5555:入力済みメッセージ | 423 | | 位置情報 | geo: | geo:-78.400364,-85.916993 | 424 | | MeCard | mecard: | MECARD:Simple, Software;Some Address, Somewhere, 20430;TEL:555-555-5555;EMAIL:support@simplesoftware.io; | 425 | | VCard | BEGIN:VCARD | [例(リンク先は英語です)](https://en.wikipedia.org/wiki/VCard) | 426 | | Wi-Fi | wifi: | wifi:WEP/WPA;SSID;PSK;Hidden(True/False) | 427 | 428 | 429 | ## Laravel外での使い方 430 | 431 | このパッケージは`Generater`クラスをインスタンス化することで、Laravelの外でも使えます。 432 | 433 | use SimpleSoftwareIO\QrCode\Generator; 434 | 435 | $qrcode = new Generator; 436 | $qrcode->size(500)->generate('Make a qrcode without Laravel!'); 437 | -------------------------------------------------------------------------------- /docs/kr/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode.svg?branch=master)](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode) [![Latest Stable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/stable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Latest Unstable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/unstable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![License](https://poser.pugx.org/simplesoftwareio/simple-qrcode/license.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Total Downloads](https://poser.pugx.org/simplesoftwareio/simple-qrcode/downloads.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 2 | 3 | - [소개(Introduction)](#docs-introduction) 4 | - [번역(Translations)](#docs-translations) 5 | - [설정(Configuration)](#docs-configuration) 6 | - [간단한 아이디어(Simple Ideas)](#docs-ideas) 7 | - [사용법(Usage)](#docs-usage) 8 | - [헬퍼(Helpers)](#docs-helpers) 9 | - [사용 예시(Common QrCode Usage)](#docs-common-usage) 10 | - [라라벨을 사용하지 않는 곳에서 사용하기(Usage Outside of Laravel)](#docs-outside-laravel) 11 | 12 | 13 | ## 소개(Introduction) 14 | Simple QrCode는 인기가 많은 라라벨 프레임워크 상에서 쉽게 사용할 수 있는 Qr코드 생성 패키지로, 정말 잘 만들어진 [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode)를 기반으로 만들어졌습니다. 우리는 라라벨을 이용하는 사람들에게 친숙하고 쉬운 인터페이스를 만들었습니다. 15 | 16 | 17 | ## 번역(Translations) 18 | 우리는 현재 이 문서의 번역을 도와줄 아랍어, 스페인어, 불어, 혹은 일본어를 할 줄 아는 사람을 찾고 있습니다. 만약 번역을 해주실 수 있다면, 풀리퀘스트(Pull request)를 보내주세요! 19 | 20 | 21 | ## 설정(Configuration) 22 | 23 | #### Composer 24 | 25 | 우선, Simple QrCode 패키지를 `composer.json` 파일의 `require`에 추가해주세요: 26 | 27 | "require": { 28 | "simplesoftwareio/simple-qrcode": "~2" 29 | } 30 | 31 | 그 다음으로, `composer update` 명령을 실행해주세요. 32 | 33 | #### Service Provider 34 | 35 | ###### Laravel <= 5.4 36 | `config/app.php`의 `providers` 배열 안에, `SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class`를 등록해주세요. 37 | 38 | #### Aliases 39 | 40 | ###### Laravel <= 5.4 41 | 마지막으로, `config/app.php` 설정 파일의 `aliases` 배열 안에, `'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class`를 등록해주세요. 42 | 43 | 44 | ## 간단한 아이디어(Simple Ideas) 45 | 46 | #### 화면에 출력하기 47 | 48 | 이 패키지를 사용하는 핵심적인 이유 중 하나는 Qr코드를 화면에 출력하기 위함입니다. 이 패키지는 우리의 고객들이 Qr코드를 스캔하는 것만으로 원래의 페이지로 돌아가게 할 수 있습니다. 우리는 이를 footer.blade.php 파일에 아래의 코드를 추가함으로서 해냈습니다. 49 | 50 |
51 | {!! QrCode::size(100)->generate(Request::url()); !!} 52 |

Scan me to return to the original page.

53 |
54 | 55 | #### Qr코드 Embed하기 56 | 57 | Qr코드를 이메일에 embed함으로서 유저가 쉽고 빠르게 스캔할 수 있게 할 수도 있습니다. 아래의 코드는 라라벨에서의 예시입니다. 58 | 59 | //Inside of a blade template. 60 | 61 | 62 | 63 | ## 사용법(Usage) 64 | 65 | #### 간단한(Basic) 사용법 66 | 67 | Qr코드를 생성하는 방법은 정말 쉽습니다. 가장 간단한 구문은: 68 | 69 | QrCode::generate('Make me into a QrCode!'); 70 | 71 | 위 코드는 "Make me into a QrCode!"라는 문장을 Qr코드로 만들어줍니다. 72 | 73 | #### 생성(Generate) 74 | 75 | `Generate`는 Qr코드를 만들기 위해 사용됩니다. 76 | 77 | QrCode::generate('Make me into a QrCode!'); 78 | 79 | >주의하세요! 만약 메소드 체이닝을 사용하신다면, 이 메소드는 마지막에 호출되어야 합니다. 80 | 81 | 기본적인 `Generate`는 SVG 이미지 문자열을 반환합니다. 라라벨의 Blade를 사용하시면, 현대의 브라우저에는 직접적으로 출력하실 수 있습니다. 아래의 코드를 참고하세요: 82 | 83 | {!! QrCode::generate('Make me into a QrCode!'); !!} 84 | 85 | `generate` 메소드의 두 번째 인자는 Qr코드를 저장할 파일명과 경로입니다. 86 | 87 | QrCode::generate('Make me into a QrCode!', '../public/qrcodes/qrcode.svg'); 88 | 89 | #### 포맷(Format) 변경 90 | 91 | >Qr코드를 생성하면 기본적으로 SVG 이미지가 반환됩니다. 92 | 93 | >주의하세요! `format` 메소드는 `size`, `color`, `backgroundColor`, 그리고 `margin`과 같은 다른 포맷팅 옵션들보다 먼저 호출되어야 합니다. 94 | 95 | 현재는 PNG, EPS, 그리고 SVG 이 세 가지 포맷을 지원하고 있습니다. 포맷을 변경하려면 아래의 코드를 참고하세요: 96 | 97 | QrCode::format('png'); //Will return a PNG image 98 | QrCode::format('eps'); //Will return a EPS image 99 | QrCode::format('svg'); //Will return a SVG image 100 | 101 | #### 크기 변경 102 | 103 | >Qr코드를 생성하면 기본적으로 Qr코드를 만들기 위한 최소 픽셀 사이즈로 반환됩니다. 104 | 105 | `size` 메소드를 사용하면 Qr코드의 크기를 변경할 수 있습니다. 아래의 코드처럼, 단순히 원하는 픽셀 사이즈를 입력하세요: 106 | 107 | QrCode::size(100); 108 | 109 | #### 색 변경 110 | 111 | >Qr코드의 색을 변경할 때는 주의하세요. 어떤 Qr리더들은 색이 입혀진 Qr코드를 잘 읽지 못합니다. 112 | 113 | 모든 색은 RGB (Red Green Blue)로 표현되어야 합니다. 아래의 코드와 같이 Qr코드의 색을 변경할 수 있습니다: 114 | 115 | QrCode::color(255,0,255); 116 | 117 | 배경색도 변경할 수 있고, 같은 표현 방법을 사용합니다. 118 | 119 | QrCode::backgroundColor(255,255,0); 120 | 121 | #### 여백(Margin) 변경 122 | 123 | Qr코드 주위의 여백을 변경하는 것 또한 가능합니다. 아래의 코드처럼, 단순히 원하는 여백을 입력하세요: 124 | 125 | QrCode::margin(100); 126 | 127 | #### 오류 복원(Error Correction) 128 | 129 | 오류 복원 레벨을 변경하는 것은 쉽습니다. 아래의 코드를 참고하세요: 130 | 131 | QrCode::errorCorrection('H'); 132 | 133 | 아래는 `errorCorrection` 메소드에서 지원하는 옵션들입니다. 134 | 135 | | 오류 복원 레벨 | 복원률 | 136 | | --- | --- | 137 | | L | 약 7%의 codewords | 138 | | M | 약 15%의 codewords | 139 | | Q | 약 25%의 codewords | 140 | | H | 약 30%의 codewords | 141 | 142 | >codewords는 데이터를 구성하는 단위로 Qr코드에는 8bit/codewords를 의미합니다. 143 | 144 | >복원율이 커질 수록 Qr코드가 커지고 저장할 수 있는 데이터가 적어집니다. [error correction](http://en.wikipedia.org/wiki/QR_code#Error_correction)를 참고하세요. 145 | 146 | #### 인코딩(Encoding) 147 | 148 | Qr코드를 만들기 위한 문자 인코딩을 변경할 수 있습니다. 기본값은 `ISO-8859-1`입니다. [character encoding](http://en.wikipedia.org/wiki/Character_encoding)를 참고하세요. 아래의 코드처럼, 다른 인코딩으로 변경할 수 있습니다: 149 | 150 | QrCode::encoding('UTF-8')->generate('Make me a QrCode with special symbols ♠♥!!'); 151 | 152 | | 문자 인코더(Character Encoder) | 153 | | --- | 154 | | ISO-8859-1 | 155 | | ISO-8859-2 | 156 | | ISO-8859-3 | 157 | | ISO-8859-4 | 158 | | ISO-8859-5 | 159 | | ISO-8859-6 | 160 | | ISO-8859-7 | 161 | | ISO-8859-8 | 162 | | ISO-8859-9 | 163 | | ISO-8859-10 | 164 | | ISO-8859-11 | 165 | | ISO-8859-12 | 166 | | ISO-8859-13 | 167 | | ISO-8859-14 | 168 | | ISO-8859-15 | 169 | | ISO-8859-16 | 170 | | SHIFT-JIS | 171 | | WINDOWS-1250 | 172 | | WINDOWS-1251 | 173 | | WINDOWS-1252 | 174 | | WINDOWS-1256 | 175 | | UTF-16BE | 176 | | UTF-8 | 177 | | ASCII | 178 | | GBK | 179 | | EUC-KR | 180 | 181 | >`Could not encode content to ISO-8859-1` 오류는 잘못된 문자 인코딩이 사용되고 있다는 것을 의미합니다. 만약 확신이 없다면 `UTF-8` 사용을 권장합니다. 182 | 183 | #### 병합(Merge) 184 | 185 | `merge` 메소드는 이미지를 Qr코드 위에 합쳐줍니다. 주로 로고 이미지를 Qr코드 안에 넣기 위해 사용합니다. 186 | 187 | QrCode::merge($filename, $percentage, $absolute); 188 | 189 | //Generates a QrCode with an image centered in the middle. 190 | QrCode::format('png')->merge('path-to-image.png')->generate(); 191 | 192 | //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. 193 | QrCode::format('png')->merge('path-to-image.png', .3)->generate(); 194 | 195 | //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. 196 | QrCode::format('png')->merge('http://www.google.com/someimage.png', .3, true)->generate(); 197 | 198 | >`merge` 메소드는 현재 PNG 포맷만 지원합니다. 199 | >`$absolute`가 `false`로 되어 있으면, 파일 경로는 상대 경로입니다. 절대 경로를 사용하고 싶으시면, 이 변수 값을 `true`로 변경해주세요. 200 | 201 | >`merge`를 사용하면서 Qr리더가 잘 스캔하게 하기 위해서는 높은 오류 복원율을 사용해야합니다. `errorCorrection('H')`를 사용하기를 권장합니다. 202 | 203 | ![Merged Logo](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/merged-qrcode.png?raw=true) 204 | 205 | #### 이진 문자열 병합(Merge Binary String) 206 | 207 | `mergeString` 메소드는 `merge`와 동일한 동작을 합니다. 단, `mergeString` 메소드를 사용하면 파일을 파일의 경로가 아닌 문자열로 표현할 수 있도록 해줍니다. 이는 `Storage` 파사드를 같이 사용할 때, 유용하게 쓰입니다. `mergeString`의 인터페이스는 `merge`와 거의 동일합니다. 208 | 209 | QrCode::mergeString(Storage::get('path/to/image.png'), $percentage); 210 | 211 | //Generates a QrCode with an image centered in the middle. 212 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'))->generate(); 213 | 214 | //Generates a QrCode with an image centered in the middle. The inserted image takes up 30% of the QrCode. 215 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'), .3)->generate(); 216 | 217 | >일반적인 `merge` 메소드 호출처럼, 현재 PNG 포맷만 지원합니다. 오류 복원율도 동일하게 높은 레벨의 오류 복원율을 권장합니다. 218 | 219 | #### 고급(Advanced) 사용법 220 | 221 | 모든 메소드는 메소드 체이닝을 지원합니다. `generate` 메소드는 반드시 마지막에 호출되어야 하고, `format` 변경은 반드시 첫 부분에 호출되어야 합니다. 아래의 예시 코드를 참고해주세요: 222 | 223 | QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate('Make me a QrCode!'); 224 | QrCode::format('png')->size(399)->color(40,40,40)->generate('Make me a QrCode!'); 225 | 226 | PNG 이미지를 `base64_encode`를 사용하여 인코딩된 raw string을 사용하면, 파일로 저장하지 않아도 출력할 수 있습니다. 227 | 228 | 229 | 230 | 231 | ## 헬퍼(Helpers) 232 | 233 | #### 헬퍼가 무엇인가요? 234 | 235 | 헬퍼는 Qr리더로 스캔했을 때, 특정한 동작을 할 수 있는 Qr코드를 만들어줍니다. 236 | 237 | #### 비트코인(BitCoin) 238 | 239 | 이 헬퍼는 스캔했을 때 비트코인을 송금할 수 있는 Qr코드를 만들어줍니다. [더 알아보기](https://bitco.in/en/developer-guide#plain-text) 240 | 241 | QrCode::BTC($address, $amount); 242 | 243 | //Sends a 0.334BTC payment to the address 244 | QrCode::BTC('bitcoin address', 0.334); 245 | 246 | //Sends a 0.334BTC payment to the address with some optional arguments 247 | QrCode::size(500)->BTC('address', 0.0034, [ 248 | 'label' => 'my label', 249 | 'message' => 'my message', 250 | 'returnAddress' => 'https://www.returnaddress.com' 251 | ]); 252 | 253 | #### 이메일(E-mail) 254 | 255 | 이 헬퍼는 이메일 주소, 제목, 그리고 내용이 미리 입력되어 있는 채로 이메일을 보낼 수 있는 Qr코드를 만들어줍니다. 256 | 257 | QrCode::email($to, $subject, $body); 258 | 259 | //Fills in the to address 260 | QrCode::email('foo@bar.com'); 261 | 262 | //Fills in the to address, subject, and body of an e-mail. 263 | QrCode::email('foo@bar.com', 'This is the subject.', 'This is the message body.'); 264 | 265 | //Fills in just the subject and body of an e-mail. 266 | QrCode::email(null, 'This is the subject.', 'This is the message body.'); 267 | 268 | #### 지리위치(Geo) 269 | 270 | 이 헬퍼는 스마트폰으로 스캔해서 구글 지도 같은 지도 앱들에 위치를 표현할 수 있도록 위도와 경도 값을 포함하고 있는 Qr코드를 만들어줍니다. 271 | 272 | QrCode::geo($latitude, $longitude); 273 | 274 | QrCode::geo(37.822214, -122.481769); 275 | 276 | #### 전화번호(Phone Number) 277 | 278 | 이 헬퍼는 스캔해서 통화 연결을 할 수 있는 Qr코드를 만들어줍니다. 279 | 280 | QrCode::phoneNumber($phoneNumber); 281 | 282 | QrCode::phoneNumber('555-555-5555'); 283 | QrCode::phoneNumber('1-800-Laravel'); 284 | 285 | #### 문자 메세지(SMS) 286 | 287 | 이 헬퍼는 받는 사람 번호와 문자 메세지 내용이 미리 입력되어 있는 채로 문자 메세지를 보낼 수 있는 Qr코드를 만들어줍니다. 288 | 289 | QrCode::SMS($phoneNumber, $message); 290 | 291 | //Creates a text message with the number filled in. 292 | QrCode::SMS('555-555-5555'); 293 | 294 | //Creates a text message with the number and message filled in. 295 | QrCode::SMS('555-555-5555', 'Body of the message'); 296 | 297 | #### 와이파이(WiFi) 298 | 299 | 이 헬퍼는 스마트폰으로 스캔해서 와이파이에 연결할 수 있도록 하는 Qr코드를 만들어줍니다. 300 | 301 | QrCode::wiFi([ 302 | 'encryption' => 'WPA/WEP', 303 | 'ssid' => 'SSID of the network', 304 | 'password' => 'Password of the network', 305 | 'hidden' => 'Whether the network is a hidden SSID or not.' 306 | ]); 307 | 308 | //Connects to an open WiFi network. 309 | QrCode::wiFi([ 310 | 'ssid' => 'Network Name', 311 | ]); 312 | 313 | //Connects to an open, hidden WiFi network. 314 | QrCode::wiFi([ 315 | 'ssid' => 'Network Name', 316 | 'hidden' => 'true' 317 | ]); 318 | 319 | //Connects to an secured, WiFi network. 320 | QrCode::wiFi([ 321 | 'ssid' => 'Network Name', 322 | 'encryption' => 'WPA', 323 | 'password' => 'myPassword' 324 | ]); 325 | 326 | >현재 애플 제품(예. 아이폰 등)은 와이파이 스캔을 지원하지 않습니다. 327 | 328 | 329 | ## 사용 예시(Common QrCode Usage) 330 | 331 | 아래 표에 있는 접두사(prefix)를 `generate` 섹션에 사용하면, 더 고급스러운 정보가 저장된 Qr코드를 만들 수 있습니다: 332 | 333 | QrCode::generate('http://www.simplesoftware.io'); 334 | 335 | 336 | | 사용처 | Prefix | 예시 | 337 | | --- | --- | --- | 338 | | 웹사이트(http) URL | http:// | http://www.simplesoftware.io | 339 | | 웹사이트(https) URL | https:// | https://www.simplesoftware.io | 340 | | 이메일 주소 | mailto: | mailto:support@simplesoftware.io | 341 | | 전화번호 | tel: | tel:555-555-5555 | 342 | | 문자 메세지(SMS) | sms: | sms:555-555-5555 | 343 | | 내용이 미리 입력된 문자 메세지(SMS) | sms: | sms::I am a pretyped message | 344 | | 번호와 내용이 미리 입력된 문자 메세지(SMS) | sms: | sms:555-555-5555:I am a pretyped message | 345 | | 지리위치 정보(Geo Address) | geo: | geo:-78.400364,-85.916993 | 346 | | MeCard | mecard: | MECARD:Simple, Software;Some Address, Somewhere, 20430;TEL:555-555-5555;EMAIL:support@simplesoftware.io; | 347 | | VCard | BEGIN:VCARD | [See Examples](https://en.wikipedia.org/wiki/VCard) | 348 | | 와이파이(Wifi) | wifi: | wifi:WEP/WPA;SSID;PSK;Hidden(True/False) | 349 | 350 | 351 | ## 라라벨을 사용하지 않는 곳에서 사용하기(Usage Outside of Laravel) 352 | 353 | `BaconQrCodeGenerator` 클래스를 인스턴스화하면, 라라벨을 사용하지 않는 곳에서 이 패키지를 사용할 수 있습니다. 354 | 355 | use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator; 356 | 357 | $qrcode = new BaconQrCodeGenerator; 358 | $qrcode->size(500)->generate('Make a qrcode without Laravel!'); 359 | -------------------------------------------------------------------------------- /docs/pt-br/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode.svg?branch=master)](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode) [![Latest Stable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/stable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Latest Unstable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/unstable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![License](https://poser.pugx.org/simplesoftwareio/simple-qrcode/license.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Total Downloads](https://poser.pugx.org/simplesoftwareio/simple-qrcode/downloads.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 2 | 3 | 4 | - [Introdução](#docs-introduction) 5 | - [Traduções](#docs-translations) 6 | - [Configuração](#docs-configuration) 7 | - [Simples ideias](#docs-ideas) 8 | - [Uso](#docs-usage) 9 | - [Ajuda](#docs-ajudantes) 10 | - [Uso comum do QrCode](#docs-common-usage) 11 | - [Uso sem Laravel](#docs-outside-laravel) 12 | 13 | 14 | ## Introdução 15 | Simple QrCode é um pacote de fácil uso do Framework Laravel, baseado no grande trabalho do [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode). Criamos uma interface que é fácil e familiar de instalar para usuários Laravel. 16 | 17 | 18 | ## Traduções 19 | Estamos procurando por usuários que falem Árabe, Espanhol, Francês, Coreano ou Japonês, para nos ajudar a traduzir este documento. Por favor, crie um pull request se você é capar de fazer uma tradução! 20 | 21 | 22 | ## Configuração 23 | 24 | #### Composer 25 | 26 | Primeiramente, adicione o pacote Simple QrCode ao seu `require` no arquivo `composer.json`: 27 | 28 | "require": { 29 | "simplesoftwareio/simple-qrcode": "~2" 30 | } 31 | 32 | Em seguida, execute o comando `composer update`. 33 | 34 | #### Provedor de Serviço 35 | 36 | ###### Laravel <= 5.4 37 | Registre a `SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class` em seu `config/app.php` dentro do array `providers`. 38 | 39 | #### Aliases 40 | 41 | ###### Laravel <= 5.4 42 | Finalmente, adicione `'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class` em seu arquivo de configuração `config/app.php` dentro do array `aliases`. 43 | 44 | 45 | ## Ideias simples 46 | 47 | #### Print View 48 | 49 | Um dos principais pontos pelo qual nós utilizamos este pacote para é ter QRCodes em todos os nossos pontos de vista de impressão. Isto permite que nossos clientes possam retornar para a página original depois da impressão, basta digitalizar o código. Conseguimos isso adicionando o seguinte em nosso arquivo footer.blade.php. 50 | 51 |
52 | {!! QrCode::size(100)->generate(Request::url()); !!} 53 |

Me escaneie para retornar à página principal

54 |
55 | 56 | #### Embarcando um QrCode 57 | 58 | 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. 59 | 60 | //Inside of a blade template. 61 | 62 | 63 | 64 | ## Uso 65 | 66 | #### Uso Básico 67 | 68 | É muito fácil utilizar o gerador de Qrcode. A sintaxe mais básica é: 69 | 70 | QrCode::generate('Me transforme em um QrCode!'); 71 | 72 | Isso criará um Qr que diz "Me transforme em um QrCode!" 73 | 74 | #### Generate 75 | 76 | `Generate` é usado para criar o QrCode. 77 | 78 | QrCode::generate('Me transforme em um QrCode!'); 79 | 80 | >Atenção! Esse método deve ser chamado por último dentro da cadeia. 81 | 82 | `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: 83 | 84 | {!! QrCode::generate('Me transforme em um QrCode!'); !!} 85 | 86 | O método `generate` tem um segundo parametro que aceita um arquivo e um path para salvar o Qrcode. 87 | 88 | QrCode::generate('Me transforme em um QrCode!', '../public/qrcodes/qrcode.svg'); 89 | 90 | #### Alteração de Formato 91 | 92 | >Por padrão o gerador de QrCode está configurado para retornar uma imagem SVG. 93 | 94 | >Cuidao! O método `format` deve ser chamado antes de qualquer outra opção de formatação como `size`, `color`, `backgroundColor` e `margin`. 95 | 96 | Atualmente são suportados três tipos de formatos; PNG, EPS, and SVG. Para alterar o formato, use o seguinte código: 97 | 98 | QrCode::format('png'); // Retornará uma imagem no formato PNG 99 | QrCode::format('eps'); // Retornará uma imagem no formato EPS 100 | QrCode::format('svg'); // Retornará uma imagem no formato SVG 101 | 102 | #### Alteração de Tamanho 103 | 104 | >Por padrão, o gerador QrCode retornará o menos tamanho possível em pixels para criar o QrCode. 105 | 106 | Você pode alterar o tamanho do QrCode usando o método `size`. Simplesmente especifique o tamanho desejado em pixels usando a seguinte sintaze: 107 | 108 | QrCode::size(100); 109 | 110 | #### Alteração de cor 111 | 112 | >Cuidado quando estiver alterando a cor de um QRCode. Alguns leitores tem uma grande dificuldade em ler QrCodes coloridos. 113 | 114 | Todas as cores devem ser definidas em RGB(Red Green Blue). Você pode alterar a cor de um qrCode usando o código abaixo: 115 | 116 | QrCode::color(255,0,255); 117 | 118 | Alterações do plano de fundo também são suportadas e definidas da mesma maneira. 119 | 120 | QrCode::backgroundColor(255,255,0); 121 | 122 | #### Alteração de Margem 123 | 124 | A capacidade de alterar a margem ao redor do QrCode também é suportada. Simplesmente especifique o tamanho desejado da margem, utilizando a sintaxe abaixo: 125 | 126 | QrCode::margin(100); 127 | 128 | #### Correção de erros 129 | 130 | Alterar o nível de correção de erros é simples. Utilize a seguinte sintaxe: 131 | 132 | QrCode::errorCorrection('H'); 133 | 134 | As seguintes opções são suportadas para o método `errorCorrection`. 135 | 136 | | Correção de erros | Garantia fornecida | 137 | | --- | --- | 138 | | L | 7% das palavras-código podem ser restauradas. | 139 | | M | 15% das palavras-código podem ser restauradas. | 140 | | Q | 25% das palavras-código podem ser restauradas. | 141 | | H | 30% das palavras-código podem ser restauradas. | 142 | 143 | >Quanto maior a correção de erros utilizada, maior o QrCode fica e menos informação ele pode armazenar. Leia mais sobre [correção de erros](http://en.wikipedia.org/wiki/QR_code#Error_correction). 144 | 145 | #### Codificação 146 | 147 | Alterar a codificação que é usada para criar um QrCode. Por padrão, a encodificação padrão é a `ISO-8859-1`. Leia mais sobre [codificação de caracteres](https://pt.wikipedia.org/wiki/Codifica%C3%A7%C3%A3o_de_caracteres). Você pode alterar a codificação usando o seguinte código: 148 | 149 | QrCode::encoding('UTF-8')->generate('Faça-me um QrCode com símbolos especiais ♠♥!!'); 150 | 151 | | Codificador de caracteres | 152 | | --- | 153 | | ISO-8859-1 | 154 | | ISO-8859-2 | 155 | | ISO-8859-3 | 156 | | ISO-8859-4 | 157 | | ISO-8859-5 | 158 | | ISO-8859-6 | 159 | | ISO-8859-7 | 160 | | ISO-8859-8 | 161 | | ISO-8859-9 | 162 | | ISO-8859-10 | 163 | | ISO-8859-11 | 164 | | ISO-8859-12 | 165 | | ISO-8859-13 | 166 | | ISO-8859-14 | 167 | | ISO-8859-15 | 168 | | ISO-8859-16 | 169 | | SHIFT-JIS | 170 | | WINDOWS-1250 | 171 | | WINDOWS-1251 | 172 | | WINDOWS-1252 | 173 | | WINDOWS-1256 | 174 | | UTF-16BE | 175 | | UTF-8 | 176 | | ASCII | 177 | | GBK | 178 | | EUC-KR | 179 | 180 | >Um erro de `Could not encode content to ISO-8859-1` significa que foi inserido algum caractere inválido. Recomendamos o `UTF-8` se você não tiver certeza. 181 | 182 | #### Mesclar 183 | 184 | O método `merge` mescla uma imagem sobre um Qrcode. É comumente usado para se colocar logos dentro de um QrCode. 185 | 186 | QrCode::merge($filename, $percentage, $absolute); 187 | 188 | // Gera um QrCode com uma imagem centralizada. 189 | QrCode::format('png')->merge('diretório/da/imagem.png')->generate(); 190 | 191 | // Gera um QrCode com uma imagem centralizada. A imagem inserida ocupará 30% do QrCode. 192 | QrCode::format('png')->merge('diretório/da/imagem.png', .3)->generate(); 193 | 194 | // Gera um QrCode com uma imagem centralizada. A imagem inserida ocupará 30% do QrCode. 195 | QrCode::format('png')->merge('http://www.google.com/algumaImagem.png', .3, true)->generate(); 196 | 197 | >O método `merge` suporta somente arquivos do tipo PNG. 198 | >O diretório da imagem é relativo ao caminho base da aplicação, se o `$absolute` estiver setada para `false`. Altere essa variável para `true` para usar caminhos absolutos. 199 | 200 | >Você deve usar um alto nível de correção de erros quando usado o método `merge`, para garantir que o QrCode será legível. Recomendamos usar `errorCorrection('H')`. 201 | 202 | ![Merged Logo](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/merged-qrcode.png?raw=true) 203 | 204 | #### Funda string binária 205 | 206 | O método `mergeString` pode ser usado para alcançar a mesma chamada do método `merge`, exceto que ele permite que você represente uma string de um arquivo ao invés do diretório. Isso é útil quando é utilizado o padrão `Storage`. A chamada a essa interface é bastante similar ao método `merge`. 207 | 208 | QrCode::mergeString(Storage::get('diretório/da/imagem.png'), $percentage); 209 | 210 | // Gera um QrCode com uma imagem centralizada. 211 | QrCode::format('png')->mergeString(Storage::get('diretório/da/imagem.png'))->generate(); 212 | 213 | // Gera um QrCode com uma imagem centralizada. A imagem inserida ocupará 30% do QrCode. 214 | QrCode::format('png')->mergeString(Storage::get('diretório/da/imagem.png'), .3)->generate(); 215 | 216 | >Assim como o método `merge`, somente arquivos do tipo PNG são suportados. O mesmo aplica-se para correção de erros, altos níveis são recomendados. 217 | 218 | #### Uso Avançado 219 | 220 | Todos os métodos suportam encadeamento. O método `generate` deve ser chamado por último e o método `format` deve ser chamado primeiro. Por exemplo, vocẽ pode executar o código seguinte: 221 | 222 | QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate('Faça-me um QrCode!'); 223 | QrCode::format('png')->size(399)->color(40,40,40)->generate('Faça-me um QrCode!'); 224 | 225 | Você pode exibir uma imagem PNG, sem salvar o arquivo e prover uma string encodificada pelo método `base64_encode`. 226 | 227 | 228 | 229 | 230 | ## Ajudantes 231 | 232 | #### O que são ajudantes? 233 | 234 | Ajudantes são uma maneira fácil de criar QrCodes que executam uma ação quando escaneados. 235 | 236 | #### E-Mail 237 | 238 | Esse ajudante, gera um qrcode de e-mail que é capaz de ser preenchido no endereço de e-mail, assunto e corpo. 239 | 240 | QrCode::email($to, $subject, $body); 241 | 242 | // Preenche o endereço de email 243 | QrCode::email('foo@bar.com'); 244 | 245 | // Preenche o endereço, título e corpo de um email 246 | QrCode::email('foo@bar.com', 'This is the subject.', 'This is the message body.'); 247 | 248 | // Preenche apenas o título e corpo de um email 249 | QrCode::email(null, 'This is the subject.', 'This is the message body.'); 250 | 251 | #### Geo 252 | 253 | Esse ajudante gera uma latitude e longitude que pode ser lido por um aparelho celular e abrir a localização no Google maps ou outro aplicativo similar. 254 | 255 | QrCode::geo($latitude, $longitude); 256 | 257 | QrCode::geo(37.822214, -122.481769); 258 | 259 | #### Phone Number 260 | 261 | Esse ajudante, gera uma QrCode que pode ser escaneado e exibir um número de telefone. 262 | 263 | QrCode::phoneNumber($phoneNumber); 264 | 265 | QrCode::phoneNumber('555-555-5555'); 266 | QrCode::phoneNumber('1-800-Laravel'); 267 | 268 | #### SMS (Mensagens de Texto) 269 | 270 | Esse ajudante, cria uma mensagem SMS que pode ser preenchida com o número de telefone e o corpo da mensagem. 271 | 272 | QrCode::SMS($phoneNumber, $message); 273 | 274 | // Cria uma mensagem de texto com o telefone preenchido. 275 | QrCode::SMS('555-555-5555'); 276 | 277 | // Cria uma mensagem de texto com o número telefônico e a mensagem preenchida. 278 | QrCode::SMS('555-555-5555', 'Body of the message'); 279 | 280 | #### WiFi 281 | 282 | Esse ajudante, faz com que QrCodes escaneáveis permitam o aparelho celular se conectar a uma rede WI-FI. 283 | 284 | QrCode::wiFi([ 285 | 'encryption' => 'WPA/WEP', 286 | 'ssid' => 'SSID da rede', 287 | 'password' => 'Senha da rede', 288 | 'hidden' => 'Se a rede é um SSID oculto ou não.' 289 | ]); 290 | 291 | // Conectar a uma rede wifi 292 | QrCode::wiFi([ 293 | 'ssid' => 'Nome da rede', 294 | ]); 295 | 296 | // Conectar a uma refe wifi oculta 297 | QrCode::wiFi([ 298 | 'ssid' => 'Nome da rede', 299 | 'hidden' => 'true' 300 | ]); 301 | 302 | // Conectar a uma rede wifi segura 303 | QrCode::wiFi([ 304 | 'ssid' => 'Nome da rede', 305 | 'encryption' => 'WPA', 306 | 'password' => 'minhaSenha' 307 | ]); 308 | 309 | >Escaneamento WIFI atualmente não são suportados nos produtos Apple. 310 | 311 | 312 | ##Uso Comum do QRCode 313 | 314 | Você pode usar um prefixo listado na tabela abaixo dentro da seção `generate` para criar um QrCode para armazenar informações mais avançadas: 315 | 316 | QrCode::generate('http://www.simplesoftware.io'); 317 | 318 | 319 | | Uso | Prefixo | Exemplo | 320 | | --- | --- | --- | 321 | | URL do site | http:// | http://www.simplesoftware.io | 322 | | URL segura | https:// | https://www.simplesoftware.io | 323 | | Endereço de e-mail | mailto: | mailto:support@simplesoftware.io | 324 | | Número de telefone | tel: | tel:555-555-5555 | 325 | | Texto (SMS) | sms: | sms:555-555-5555 | 326 | | Texto (SMS) With Pretyped Message | sms: | sms::I am a pretyped message | 327 | | Texto (SMS) With Pretyped Message and Number | sms: | sms:555-555-5555:I am a pretyped message | 328 | | Coordenadas | geo: | geo:-78.400364,-85.916993 | 329 | | MeCard | mecard: | MECARD:Simple, Software;Some Address, Somewhere, 20430;TEL:555-555-5555;EMAIL:support@simplesoftware.io; | 330 | | VCard | BEGIN:VCARD | [Veja Exemplos](https://en.wikipedia.org/wiki/VCard) | 331 | | Wifi | wifi: | wifi:WEP/WPA;SSID;PSK;Hidden(True/False) | 332 | 333 | 334 | ##Uso fora do Laravel 335 | 336 | Você pode usar o pacote fora do Laravel instanciando a classe `BaconQrCodeGenerator`. 337 | 338 | use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator; 339 | 340 | $qrcode = new BaconQrCodeGenerator; 341 | $qrcode->size(500)->generate('Crie um QrCode sem Laravel!'); 342 | -------------------------------------------------------------------------------- /docs/ru/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode.svg?branch=master)](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode) [![Latest Stable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/stable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Latest Unstable Version](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/unstable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![License](https://poser.pugx.org/simplesoftwareio/simple-qrcode/license.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![Total Downloads](https://poser.pugx.org/simplesoftwareio/simple-qrcode/downloads.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 2 | 3 | 4 | - [Введение](#docs-introduction) 5 | - [Переводы](#docs-translations) 6 | - [Конфигурация](#docs-configuration) 7 | - [Простые Идеи](#docs-ideas) 8 | - [Использование](#docs-usage) 9 | - [Хелперы](#docs-helpers) 10 | - [Префиксы](#docs-common-usage) 11 | - [Использование без Laravel](#docs-outside-laravel) 12 | 13 | 14 | ## Введение 15 | 16 | Simple QrCode - простая в использовании обёртка для популярного фреймворка Laravel на основе превосходного проекта [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode). 17 | Мы создали интерфейс, который привычен и прост в установке для пользователей Laravel. 18 | 19 | 20 | ## Переводы 21 | 22 | Мы ищем пользователей, говорящих на китайском, корейском или японском языках, которые могут помочь перевести этот документ. 23 | Пожалуйста, создайте пул реквест, если вы можете сделать перевод! 24 | 25 | 26 | ## Конфигурация 27 | 28 | ### Composer 29 | 30 | Находясь в директории вашего проекта laravel, выполните команду: 31 | 32 | ```bash 33 | composer require simplesoftwareio/simple-qrcode 34 | ``` 35 | 36 | Либо добавьте пакет `simplesoftwareio/simple-qrcode` в раздел `require` файла `composer.json`: 37 | 38 | ```json 39 | "require": { 40 | "simplesoftwareio/simple-qrcode": "~2" 41 | } 42 | ``` 43 | 44 | Затем запустите команду `composer update`. 45 | 46 | ### Поставщик услуг (Laravel <= 5.4) 47 | 48 | Добавьте строчку 49 | ``` 50 | SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class 51 | ``` 52 | в конец массива `providers` в файле `config/app.php`. 53 | 54 | ### Алиас (Laravel <= 5.4) 55 | 56 | Добавьте строчку 57 | ``` 58 | 'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class 59 | ``` 60 | в конец массива `aliases` в файле `config/app.php`. 61 | 62 | 63 | ## Простые Идеи 64 | 65 | ### Печать страниц 66 | 67 | Мы используем QR-коды на страница для печати. 68 | Это позволяет нашим клиентам открыть исходную страницу на устройстве после печати, просто отсканировав этот код. 69 | Для этого в файл `footer.blade.php` мы добавили следующий код: 70 | 71 | ```blade 72 |
73 | {!! QrCode::size(100)->generate(Request::url()); !!} 74 |

Отсканируйте QR-код, чтобы открыть исходную страницу

75 |
76 | ``` 77 | 78 | ### Вставка QR-кода в email 79 | 80 | Вы можете вставить QR-код в email, чтобы позволить пользователям быстро его отсканировать. 81 | Ниже приведен пример того, как сделать это с помощью Laravel: 82 | 83 | ```blade 84 | // внутри шаблона blade 85 | 86 | ``` 87 | 88 | 89 | ## Использование 90 | 91 | ### Общий случай использования 92 | 93 | Использовать генератор для QR-код очень легко. 94 | Достаточно вызвать один метод: 95 | 96 | ```php 97 | QrCode::generate('Lorem ipsum!'); 98 | ``` 99 | 100 | Этот код создаст QR-код с текстом "Lorem ipsum!". 101 | 102 | ### Генерация изображений 103 | 104 | Используйте метод `generate()`, чтобы создать изображение QR-кода: 105 | 106 | ```php 107 | QrCode::generate('Lorem ipsum!'); 108 | ``` 109 | 110 | > Внимание! При вызове в цепочке методов этот метод должен вызываться в конце. 111 | 112 | Метод `generate()` по умолчанию возвращает строку, содержащую SVG-представление изображения. 113 | Поэтому её можно вывести как есть прямо в браузер внутри Blade-шаблона: 114 | 115 | ```blade 116 | {!! QrCode::generate('Lorem ipsum!'); !!} 117 | ``` 118 | 119 | Чтобы сохранить изображение QR-кода в файл, передайте методу `generate()` путь к файлу вторым аргументом: 120 | 121 | ```blade 122 | QrCode::generate('Lorem ipsum!', '../public/qrcodes/qrcode.svg'); 123 | ``` 124 | 125 | ### Изменение формата 126 | 127 | > По умолчанию QR-код создаётся в формате SVG. 128 | 129 | > **Обратите внимание!** Метод `format()` должен вызываться **перед** всеми остальными методами форматирования, такими как `size()`, `color()`, `backgroundColor()` и `margin()`. 130 | 131 | На данный момент поддерживаются три формата: PNG, EPS и SVG. 132 | Для изменения формата используйте следующий код: 133 | 134 | ```php 135 | QrCode::format('png'); 136 | QrCode::format('eps'); 137 | QrCode::format('svg'); 138 | ``` 139 | 140 | ### Изменение размера 141 | 142 | > По умолчанию QR-код создаётся наименьшего размера. 143 | 144 | Вы можете изменить размер QR-код с помощью метода `size()`. 145 | Просто укажите размер желаемого в пикселях, используя следующий синтаксис: 146 | 147 | ```php 148 | QrCode::size(100); 149 | ``` 150 | 151 | ### Изменение цветов 152 | 153 | > Будьте осторожны при изменении цветов QR-кода. 154 | > Это может затруднить его сканирование. 155 | 156 | Вы можете изменить цвет клеток на изображении. 157 | Для этого следует использовать метод `color()`. 158 | Три аргумента этого метода - значения RGB-палитры соответственно. 159 | 160 | Например, так можно сделать клетки розовыми: 161 | 162 | ```php 163 | QrCode::color(255, 0, 255); 164 | ``` 165 | 166 | Также поддерживается изменение цвета фона методом `backgroundColor()`. 167 | Например, следующий код сделает фон не белым, а жёлтым: 168 | 169 | ```php 170 | QrCode::backgroundColor(255, 255, 0); 171 | ``` 172 | 173 | ### Поля 174 | 175 | Вы можете изменить внутренние поля изображения. 176 | Это поможет повысить вероятность успешного сканирования. 177 | 178 | Просто укажите количество пикселей между краем изображения и матрицей: 179 | 180 | ```php 181 | QrCode::margin(100); 182 | ``` 183 | 184 | ### Уровень коррекции ошибок 185 | 186 | Для изменения уровня коррекции ошибок используйте следующий метод: 187 | 188 | ```php 189 | QrCode::errorCorrection('H'); 190 | ``` 191 | 192 | Метод `errorCorrection()` поддерживает следующие уровни: 193 | 194 | | Уровень | Допуск ошибок | 195 | | ------- | ------------- | 196 | | L | 7% | 197 | | M | 15% | 198 | | Q | 25% | 199 | | H | 30% | 200 | 201 | > Чем выше уровень коррекции, тем больше становится QR-код и тем меньше данных он может хранить. 202 | > [Подробнее](https://ru.wikipedia.org/wiki/QR-%D0%BA%D0%BE%D0%B4#.D0.9E.D0.B1.D1.89.D0.B0.D1.8F_.D1.82.D0.B5.D1.85.D0.BD.D0.B8.D1.87.D0.B5.D1.81.D0.BA.D0.B0.D1.8F_.D0.B8.D0.BD.D1.84.D0.BE.D1.80.D0.BC.D0.B0.D1.86.D0.B8.D1.8F). 203 | 204 | ### Кодировка символов 205 | 206 | По умолчанию используется кодировка `ISO-8859-1`. 207 | [Подробнее о кодировках символов](https://ru.wikipedia.org/wiki/%D0%9D%D0%B0%D0%B1%D0%BE%D1%80_%D1%81%D0%B8%D0%BC%D0%B2%D0%BE%D0%BB%D0%BE%D0%B2). 208 | 209 | Вы можете кодировку, используя метод `encoding()`: 210 | 211 | ```php 212 | QrCode::encoding('UTF-8')->generate('‘Lorem ipsum со специальными символами ♠♥!!'); 213 | ``` 214 | 215 | Полный список поддерживаемых кодировок: 216 | 217 | | Кодировка | 218 | | ------------ | 219 | | ISO-8859-1 | 220 | | ISO-8859-2 | 221 | | ISO-8859-3 | 222 | | ISO-8859-4 | 223 | | ISO-8859-5 | 224 | | ISO-8859-6 | 225 | | ISO-8859-7 | 226 | | ISO-8859-8 | 227 | | ISO-8859-9 | 228 | | ISO-8859-10 | 229 | | ISO-8859-11 | 230 | | ISO-8859-12 | 231 | | ISO-8859-13 | 232 | | ISO-8859-14 | 233 | | ISO-8859-15 | 234 | | ISO-8859-16 | 235 | | SHIFT-JIS | 236 | | WINDOWS-1250 | 237 | | WINDOWS-1251 | 238 | | WINDOWS-1252 | 239 | | WINDOWS-1256 | 240 | | UTF-16BE | 241 | | UTF-8 | 242 | | ASCII | 243 | | GBK | 244 | | EUC-KR | 245 | 246 | > Ошибка `Could not encode content to ISO-8859-1` означает, что вы передали в метод `generate()` строку, символы которой невозможно перевести в ISO-8859-1. 247 | > Если вы не уверены какую кодировку использовать в вашем случае, то перед вызовом `generate()` установите кодировку `UTF-8`. 248 | 249 | ### Наложение изображений на QR-код (из файла) 250 | 251 | Метод `merge()` накладывает указанное изображение на QR-код. 252 | Это обычно используется для логотипов, размащаемых в пределах QR-кода. 253 | 254 | ```php 255 | QrCode::merge($filename, $percentage, $absolute); 256 | 257 | // Создает QR-код с изображением в центре 258 | QrCode::format('png')->merge('path-to-image.png')->generate(); 259 | 260 | // Создает QR-код с изображением в центре 261 | // Вставленное изображение занимает 30% QR-кода 262 | QrCode::format('png')->merge('path-to-image.png', .3)->generate(); 263 | QrCode::format('png')->merge('http://www.google.com/someimage.png', .3, true)->generate(); 264 | ``` 265 | 266 | > На данный момент метод `merge()` поддерживает только PNG. 267 | 268 | > По умолчанию путь к файлу считается относительно `base_path()` вашего проекта. 269 | > Если вы указываете абсолютный путь к файлу, то передайте `true` третьим аргументом. 270 | 271 | > Вы должны использовать высокий уровень коррекции ошибок при использовании метода `merge()` чтобы QR-код остался читаемым. 272 | > Рекомендуется использовать `errorCorrection('H')`. 273 | 274 | ![Merged Logo](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/merged-qrcode.png?raw=true) 275 | 276 | ### Наложение изображений на QR-код (из двоичной строки) 277 | 278 | Метод `mergeString()` может быть использован для решения той же задачи, что и `merge()`. 279 | Отличие в том, что `mergeString()` принимает строковое представление файла вместо пути к файлу. 280 | Это полезно при работе с фасадом `Storage`. 281 | Этот интерфейс очень похож на вызов `merge()`. 282 | 283 | > Как и в случае с `merge()`, здесь поддерживается только PNG-формат. 284 | > То же самое относится к коррекции ошибок - рекомендуется использовать высокие уровни. 285 | 286 | ### Дополнительный функционал 287 | 288 | Все методы поддерживают последовательный вызов. 289 | 290 | Вызывайте метод `generate()` в последнюю очередь, после применения форматирования. 291 | 292 | Примеры последовательных вызовов: 293 | 294 | ```php 295 | QrCode::size(250) 296 | ->color(150, 90, 10) 297 | ->backgroundColor(10, 14, 244) 298 | ->generate('Lorem ipsum!'); 299 | QrCode::format('png') 300 | ->size(399) 301 | ->color(40, 40, 40) 302 | ->generate('Lorem ipsum!'); 303 | ``` 304 | 305 | Вы можете отобразить в браузере PNG-изображение без его сохранения в файл, выводя закодированную при помощи `base64_encode()` необработанную строку: 306 | 307 | ```blade 308 | 309 | ``` 310 | 311 | 312 | ## Хелперы 313 | 314 | ### Что такое хелперы? 315 | 316 | Хелперы предоставляют простой способ создания QR-кода, который заставляет сканер пользователя выполнить определенное действие. 317 | 318 | ### Электронная Почта 319 | 320 | Этот хелпер генерирует QR-код для создания email. 321 | Можно указать email адресата, тему и текст письма. 322 | 323 | ```php 324 | QrCode::email($to, $subject, $body); 325 | 326 | // Заполняет адресата 327 | QrCode::email('foo@bar.com'); 328 | 329 | // Заполняет адресата, тему и текст сообщения электронной почты. 330 | QrCode::email('foo@bar.com', 'Это тема', 'Это текст'); 331 | 332 | // Заполняет только тему и текст сообщения электронной почты. 333 | QrCode::email(null, 'Это тема', 'Это текст'); 334 | ``` 335 | 336 | ### Geo 337 | 338 | Этот хелпер генерирует QR-код с координатами точки на карте. 339 | Для этого нужно указать её широту и долготу. 340 | Смартфон пользователя может открыть указанное местоположение в Google Maps или другом приложении карт. 341 | 342 | ```php 343 | QrCode::geo($latitude, $longitude); 344 | QrCode::geo(37.822214, -122.481769); 345 | ``` 346 | 347 | ### Номер телефона 348 | 349 | Этот хелпер генерирует QR-код, при помощи которого можно быстро совершить звонок: 350 | 351 | ```php 352 | QrCode::phoneNumber($phoneNumber); 353 | QrCode::phoneNumber('555-555-5555'); 354 | QrCode::phoneNumber('1-800-Laravel'); 355 | ``` 356 | 357 | ### СМС 358 | 359 | Этот хелпер создаёт СМС-сообщение, в котором уже может быть указан номер телефона адресата и текст сообщения: 360 | 361 | ```php 362 | QrCode::SMS($phoneNumber, $message); 363 | 364 | // Создает СМС, где номер телефона уже заполнен. 365 | QrCode::SMS('555-555-5555'); 366 | 367 | // Создает СМС, где номер и текст уже заполнены. 368 | QrCode::SMS('555-555-5555', 'текст сообщения.'); 369 | ``` 370 | 371 | ### WiFi 372 | 373 | Эти хелперы создают QR-коды, которые помогут подключить смартфон к Wi-Fi: 374 | 375 | ```php 376 | QrCode::wiFi([ 377 | 'encryption' => 'WPA/WEP', 378 | 'ssid' => 'идентификатор сети (SSID)', 379 | 'password' => 'пароль сети', 380 | 'hidden' => 'является ли сеть скрытой (true/false)' 381 | ]); 382 | 383 | // Подключается к открытой сети WiFi. 384 | QrCode::wiFi([ 385 | 'ssid' => 'Имя сети', 386 | ]); 387 | 388 | // Подключается к открытой или скрытой сети WiFi. 389 | QrCode::wiFi([ 390 | 'ssid' => 'Имя сети', 391 | 'hidden' => 'true' 392 | ]); 393 | 394 | // Подключается к защищенной сети. 395 | QrCode::wiFi([ 396 | 'ssid' => 'Имя сети', 397 | 'encryption' => 'WPA', 398 | 'password' => 'Мой пароль' 399 | ]); 400 | ``` 401 | 402 | > Сканирование WiFi в настоящее время не поддерживается устройствами Apple. 403 | 404 | 405 | ## Префиксы 406 | 407 | Вы можете использовать префиксы вместо хелперов. 408 | Составьте строку по образцу, как в таблице ниже, и передайте её в метод `generate()`, чтобы добиться того же эффекта, как при использовании хелперов: 409 | 410 | ```php 411 | QrCode::generate('http://www.simplesoftware.io'); 412 | ``` 413 | 414 | | Применение | Префикс | Пример | 415 | | --- | --- | --- | 416 | | Ссылка на сайт | http:// | http://www.simplesoftware.io | 417 | | Безопасная ссылка | https:// | https://www.simplesoftware.io | 418 | | Email | mailto: | mailto:support@simplesoftware.io | 419 | | Телефон для звонка | tel: | tel:555-555-5555 | 420 | | СМС | sms: | sms:555-555-5555 | 421 | | СМС с текстом сообщения | sms: | sms::Какое-то сообщение | 422 | | СМС с текстом сообщения и номером адресата | sms: | sms:555-555-5555:Какое-то сообщение | 423 | | Местоположение на карте | geo: | geo:-78.400364,-85.916993 | 424 | | Визитка (MeCard) | mecard: | MECARD:Simple, Software;Some Address, Somewhere, 20430;TEL:555-555-5555;EMAIL:support@simplesoftware.io; | 425 | | Контакт (VCard) | BEGIN:VCARD | [Примеры](https://ru.wikipedia.org/wiki/VCard) | 426 | | Wifi | wifi: | wifi:WEP/WPA;SSID;PSK;Hidden(True/False) | 427 | 428 | 429 | ## Использование без Laravel 430 | 431 | Вы можете использовать этот пакет за пределами Laravel, просто создав новый объект класса `BaconQrCodeGenerator`. 432 | 433 | ```php 434 | use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator; 435 | 436 | $qrcode = new BaconQrCodeGenerator; 437 | $qrcode->size(500)->generate('Создайте QR-код без Laravel!'); 438 | ``` 439 | -------------------------------------------------------------------------------- /docs/zh-cn/README.md: -------------------------------------------------------------------------------- 1 | [![构建状态](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode.svg?branch=master)](https://travis-ci.org/SimpleSoftwareIO/simple-qrcode) [![最新稳定版本](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/stable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![最新版本](https://poser.pugx.org/simplesoftwareio/simple-qrcode/v/unstable.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![许可](https://poser.pugx.org/simplesoftwareio/simple-qrcode/license.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) [![下载量](https://poser.pugx.org/simplesoftwareio/simple-qrcode/downloads.svg)](https://packagist.org/packages/simplesoftwareio/simple-qrcode) 2 | 3 | 4 | - [介绍](#docs-introduction) 5 | - [升级指南](#docs-upgrade) 6 | - [配置](#docs-configuration) 7 | - [简例](#docs-ideas) 8 | - [使用说明](#docs-usage) 9 | - [助手模板](#docs-helpers) 10 | - [QrCode 常规用法](#docs-common-usage) 11 | - [在Laravel外的调用方式](#docs-outside-laravel) 12 | 13 | 14 | ## 介绍 15 | Simple QrCode 是基于[Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode) 开发,适用于Laravel框架的软件包. 我们的目的是让二维码能更加便捷的使用在Laravel框架的项目里. 16 | 17 | ![Example 1](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/example-1.png?raw=true) ![Example 2](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/example-2.png?raw=true) 18 | 19 | 20 | ## 升级指南 21 | 22 | 从v2版本升到v3需要将 `composer.json` 文件中版本改为 `~3` 23 | 24 | 如果你需要使用 `png` 文件格式,那么你**必须**安装 `imagick` PHP扩展. 25 | 26 | 27 | ## 配置 28 | 29 | #### Composer安装 30 | 31 | 使用 `composer require simplesoftwareio/simple-qrcode "~3"` 安装软件包, 32 | 33 | Laravel将会自动完成安装工作. 34 | 35 | #### 添加 Service Provider 36 | 37 | ###### Laravel <= 5.4 38 | 注册 `SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class` 至 `config/app.php` 的 `providers` 数组里. 39 | 40 | #### 添加 Aliases 41 | 42 | ###### Laravel <= 5.4 43 | 最后,注册 `'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class` 至 `config/app.php` 的 `aliases` 数组里. 44 | 45 | 46 | ## 简例 47 | 48 | #### 显示视图 49 | 50 | 一个重要的应用是在页面中添加来源二维码.这样我们的用户就可以通过扫码返回初始页.我们只需要在 footer.blade.php 文件里添加如下代码即可! 51 | 52 |
53 | {!! QrCode::size(100)->generate(Request::url()); !!} 54 |

扫我返回初始页

55 |
56 | 57 | #### 嵌入二维码 58 | 59 | 你也可以嵌入二维码在你的邮件中,让收信的用户可以快速扫描.以下是在Laravel中实现的例子: 60 | 61 | //Inside of a blade template. 62 | 63 | 64 | 65 | ## 使用说明 66 | 67 | #### 基本使用 68 | 使用QrCode的Generator非常方便. 多数情况下只要这样: 69 | 70 | QrCode::generate('Make me into a QrCode!'); 71 | 72 | 这就能创建一个内容是:"Make me into a QrCode!" 的二维码了. 73 | 74 | #### 生成 `generate(string $data, string $filename = null)` 75 | 76 | `Generate` 是用来创建二维码的方法. 77 | 78 | QrCode::generate('Make me into a QrCode!'); 79 | 80 | >注意:要创建二维码必须使用此方法 81 | 82 | `Generate` 默认返回一个 SVG 格式的图片文本. 你可以直接在Laravel 的 Blade页面 中使用,使用方式如下: 83 | 84 | {!! QrCode::generate('Make me into a QrCode!'); !!} 85 | 86 | `generate` 方法的第二个参数是指定要存储图片数据的文件地址及命名. 87 | 88 | QrCode::generate('Make me into a QrCode!', '../public/qrcodes/qrcode.svg'); 89 | 90 | #### 格式 `format(string $format)` 91 | 92 | 现支持 PNG,EPS,SVG 三种格式,设置方式如下: 93 | 94 | QrCode::format('png'); //放回PNG图片 95 | QrCode::format('eps'); //放回EPS图片 96 | QrCode::format('svg'); //放回SVG图片 97 | 98 | > 必须 `imagick` PHP扩展才能生成 `png` 图片. 99 | 100 | #### 尺寸 `size(int $size)` 101 | 102 | >QrCode 的 Generator 默认返回可能最小像素单位的二维码. 103 | 104 | 你可以使用 `size` 方法来设置二维码尺寸.下方是设置像素尺寸的方法: 105 | 106 | QrCode::size(100); 107 | 108 | ![200 像素](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/200-pixels.png?raw=true) ![250 像素](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/250-pixels.png?raw=true) 109 | 110 | #### 颜色 `color(int $red, int $green, int $blue, int $alpha = null)` 111 | 112 | >注意改变颜色后,可能会导致某些设备难以识别. 113 | 114 | 颜色设置的格式必须是RGBA格式. 设置方式如下: 115 | 116 | QrCode::color(255, 0, 0); // 红色二维码 117 | QrCode::color(255, 0, 0, 25); //红色二维码+25%透明度 118 | 119 | ![红色二维码](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/red-qrcode.png?raw=true) ![红色透明二维码](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/red-25-transparent.png?raw=true) 120 | 121 | 122 | #### 背景颜色 `backgroundColor(int $red, int $green, int $blue, int $alpha = null)` 123 | 124 | 你可以使用`backgroundColor` 方法来设置背景颜色. 125 | 126 | QrCode::backgroundColor(255, 0, 0); // 红色背景二维码 127 | QrCode::backgroundColor(255, 0, 0, 25); // 红色25%透明背景二维码 128 | 129 | ![红色背景二维码](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/red-background.png?raw=true) ![红色透明背景二维码](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/red-25-transparent-background.png?raw=true) 130 | 131 | #### 渐变 `gradient($startRed, $startGreen, $startBlue, $endRed, $endGreen, $endBlue, string $type)` 132 | 133 | 你可以使用 `gradient` 方法设置渐变. 134 | 135 | 支持以下渐变类型: 136 | 137 | | 类型 | 范例 | 138 | | --- | --- | 139 | | `vertical`垂直 | ![垂直](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/vertical.png?raw=true) | 140 | | `horizontal`水平 | ![水平](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/horizontal.png?raw=true) | 141 | | `diagonal`对角 | ![对角](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/diagonal.png?raw=true) | 142 | | `inverse_diagonal`反对角 | ![反对角](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/inverse_diagonal.png?raw=true) | 143 | | `radial`迳向 | ![迳向](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/radial.png?raw=true) | 144 | 145 | #### 定位颜色 `eyeColor(int $eyeNumber, int $innerRed, int $innerGreen, int $innerBlue, int $outterRed = 0, int $outterGreen = 0, int $outterBlue = 0)` 146 | 147 | 你可以使用 `eyeColor` 方法设置定位眼颜色. 148 | 149 | | 数量 | 范例 | 150 | | --- | --- | 151 | | `0` | ![Eye 0](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/eye-0.png?raw=true) | 152 | | `1` | ![Eye 1](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/eye-1.png?raw=true)| 153 | | `2` | ![Eye 2](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/eye-2.png?raw=true) | 154 | 155 | #### 风格 `style(string $style, float $size = 0.5)` 156 | 157 | 二维码风格可以轻易的使用 `square`, `dot` 或 `round`来调换. 这将改变二维码中的信息块风格. 第二个参数是设置dot'点'的大小和round的圆度. 158 | 159 | | 风格 | 范例 | 160 | | --- | --- | 161 | | `sqaure`方 | ![方](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/200-pixels.png?raw=true) | 162 | | `dot`点 | ![点](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/dot.png)| 163 | | `round`圆 | ![圆](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/round.png?raw=true) | 164 | 165 | #### 定位眼风格 `eyeStyle(string $style)` 166 | 167 | 二维码定位眼支持2个格式, `sqaure`方 和 `circle`圆. 168 | 169 | | 风格 | 范例 | 170 | | --- | --- | 171 | | `sqaure`方 | ![方](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/200-pixels.png?raw=true) | 172 | | `circle`圆 | ![圆](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/circle-eye.png?raw=true)| 173 | 174 | #### 边距 `margin(int $margin)` 175 | 176 | 也支持设置边距. 设置方式如下: 177 | 178 | QrCode::margin(100); 179 | 180 | #### 容错级别 181 | 182 | 改变二维码的容错级别也很方便. 只要这么设置: 183 | 184 | QrCode::errorCorrection('H'); 185 | 186 | 下方是 `errorCorrection` 方法支持的容错级别设置. 187 | 188 | | 容错级别 | 说明 | 189 | | --- | --- | 190 | | L | 7% 的字节码恢复率. | 191 | | M | 15% 的字节码恢复率. | 192 | | Q | 25% 的字节码恢复率. | 193 | | H | 30% 的字节码恢复率. | 194 | 195 | >容错级别越高,二维码越大且能存储的数据越少. 详情见: [error correction](http://en.wikipedia.org/wiki/QR_code#Error_correction). 196 | 197 | #### 编码 198 | 199 | QrCode 创建二维码时可以使用不同的编码. 默认使用 `ISO-8859-1`. 详情见 [character encoding](http://en.wikipedia.org/wiki/Character_encoding) 你可以使用以下的任一种编码: 200 | 201 | QrCode::encoding('UTF-8')->generate('Make me a QrCode with special symbols ♠♥!!'); 202 | 203 | | 编码 | 204 | | --- | 205 | | ISO-8859-1 | 206 | | ISO-8859-2 | 207 | | ISO-8859-3 | 208 | | ISO-8859-4 | 209 | | ISO-8859-5 | 210 | | ISO-8859-6 | 211 | | ISO-8859-7 | 212 | | ISO-8859-8 | 213 | | ISO-8859-9 | 214 | | ISO-8859-10 | 215 | | ISO-8859-11 | 216 | | ISO-8859-12 | 217 | | ISO-8859-13 | 218 | | ISO-8859-14 | 219 | | ISO-8859-15 | 220 | | ISO-8859-16 | 221 | | SHIFT-JIS | 222 | | WINDOWS-1250 | 223 | | WINDOWS-1251 | 224 | | WINDOWS-1252 | 225 | | WINDOWS-1256 | 226 | | UTF-16BE | 227 | | UTF-8 | 228 | | ASCII | 229 | | GBK | 230 | | EUC-KR | 231 | 232 | > 若抛出 `Could not encode content to ISO-8859-1` 意味着使用了错误的编码. 我们建议你使用 `UTF-8`. 233 | 234 | #### 合并 `(string $filepath, float $percentage = .2, bool $absolute = false)` 235 | 236 | `merge` 方法可以让QrCode为生成结果加上图片. 常见的用法是在二维码上加Logo. 237 | 238 | //生成中间有图片的二维码 239 | QrCode::format('png')->merge('path-to-image.png')->generate(); 240 | 241 | //生成中间有图片的二维码,且图片占整个二维码图片的30%. 242 | QrCode::format('png')->merge('path-to-image.png', .3)->generate(); 243 | 244 | //生成中间有图片的二维码,且图片占整个二维码图片的30%. 245 | QrCode::format('png')->merge('http://www.google.com/someimage.png', .3, true)->generate(); 246 | 247 | > `merge` 方法当前只支持PNG格式的图片 248 | > 默认使用相对于应用程序的根路径,把第三个参数设置为 `true` 就能切换到使用绝对路径 249 | 250 | > 为了让二维码保持高可识别度,建议在使用 `merge` 方法时把二维码的容错级别提高. 我们推荐使用: `errorCorrection('H')`. 251 | 252 | ![合并Logo](https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/master/docs/imgs/merged-qrcode.png?raw=true) 253 | 254 | #### 二进制合并 `(string $content, float $percentage = .2)` 255 | 256 | `mergeString` 方法与 `merge` 方法类似, 不同的是它允许你使用一个二进制的String代替图片文件. 这在使用 `Storage` 存储时,会显得很方便. 它的参数与 `merge` 类似. 257 | 258 | //生成中间有图片的二维码 259 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'))->generate(); 260 | 261 | //生成中间有图片的二维码,且图片占整个二维码图片的30%. 262 | QrCode::format('png')->mergeString(Storage::get('path/to/image.png'), .3)->generate(); 263 | 264 | > 和 `merge` 方法一样,当前只支持PNG格式. 同样建议将二维码的容错级别提高. 265 | 266 | #### 高级用法 267 | 268 | 所有的方法都支持链式调用. `generate` 方法必须在最后. 例如: 269 | 270 | QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate('Make me a QrCode!'); 271 | QrCode::format('png')->size(399)->color(40,40,40)->generate('Make me a QrCode!'); 272 | 273 | 你还能不存储图片,而使用 `base64_encode` 来将二进制数据直接显示成二维码图片. 274 | 275 | 276 | 277 | 278 | ## 助手模板 279 | 280 | #### 什么是助手模板? 281 | 282 | 助手模板生成一些简易二维码, 扫描二维码时会进行某些操作. 283 | 284 | #### BitCoin比特币 285 | 286 | 这个模板生成可扫描二维码的来接受比特币支付. [详情](https://bitco.in/en/developer-guide#plain-text) 287 | 288 | QrCode::BTC($address, $amount); 289 | 290 | //发送0.334BTC到该地址 291 | QrCode::BTC('bitcoin address', 0.334); 292 | 293 | //发送0.334BTC到该地址和一些可选设置 294 | QrCode::size(500)->BTC('address', 0.0034, [ 295 | 'label' => 'my label', 296 | 'message' => 'my message', 297 | 'returnAddress' => 'https://www.returnaddress.com' 298 | ]); 299 | 300 | #### E-Mail 301 | 302 | 这个模板可以生成一个直接发E-mail的二维码.包含了发邮件的地址,标题,和内容 303 | 304 | QrCode::email($to, $subject, $body); 305 | 306 | //加入一个邮件地址 307 | QrCode::email('foo@bar.com'); 308 | 309 | //加一个邮件地址、标题、内容至二维码. 310 | QrCode::email('foo@bar.com', 'This is the subject.', 'This is the message body.'); 311 | 312 | //只加标题和内容. 313 | QrCode::email(null, 'This is the subject.', 'This is the message body.'); 314 | 315 | #### 位置 316 | 317 | 这个模板能创建一个包含一个经纬度的位置二维码, 并在谷歌地图或类似应用中打开. 318 | 319 | QrCode::geo($latitude, $longitude); 320 | 321 | QrCode::geo(37.822214, -122.481769); 322 | 323 | #### 手机号 324 | 325 | 这个模板能创建一个包含手机号的二维码, 并拨号. 326 | 327 | QrCode::phoneNumber($phoneNumber); 328 | 329 | QrCode::phoneNumber('555-555-5555'); 330 | QrCode::phoneNumber('1-800-Laravel'); 331 | 332 | #### 短信 333 | 334 | 这个模板能创建能创建一个包含发送短信目标手机号和内容的二维码. 335 | 336 | QrCode::SMS($phoneNumber, $message); 337 | 338 | //创建一个只有手机号的短信二维码. 339 | QrCode::SMS('555-555-5555'); 340 | 341 | //创建一个包含手机号和文字内容的短信二维码. 342 | QrCode::SMS('555-555-5555', 'Body of the message'); 343 | 344 | #### WiFi 345 | 346 | 这个模板能创建扫一下能连接WIFI的二维码. 347 | 348 | QrCode::wiFi([ 349 | 'encryption' => 'WPA/WEP', 350 | 'ssid' => '网络的SSID', 351 | 'password' => '网络的密码', 352 | 'hidden' => '是否是一个隐藏SSID的网络' 353 | ]); 354 | 355 | //连接一个开放的网络 356 | QrCode::wiFi([ 357 | 'ssid' => '网络名称', 358 | ]); 359 | 360 | //连接一个开放并隐藏的网络. 361 | QrCode::wiFi([ 362 | 'ssid' => '网络名称', 363 | 'hidden' => 'true' 364 | ]); 365 | 366 | //连接一个加密的WIFI网络. 367 | QrCode::wiFi([ 368 | 'ssid' => '网络名称', 369 | 'encryption' => 'WPA', 370 | 'password' => '密码' 371 | ]); 372 | 373 | > WIFI扫描目前苹果产品不支持. 374 | 375 | 376 | ##QrCode 常规用法 377 | 378 | 你还能通过下面表中的前缀信息创建适合更多场合的二维码 379 | 380 | QrCode::generate('http://www.simplesoftware.io'); 381 | 382 | 383 | | 使用场景 | 前缀 | 例子 | 384 | | --- | --- | --- | 385 | | 网址 | http:// | http://www.simplesoftware.io | 386 | | 加密网址 | https:// | https://www.simplesoftware.io | 387 | | E-mail 地址 | mailto: | mailto:support@simplesoftware.io | 388 | | 电话号码 | tel: | tel:555-555-5555 | 389 | | 文字短信 | sms: | sms:555-555-5555 | 390 | | 文字短信内容 | sms: | sms::I am a pretyped message | 391 | | 文字短信同时附带手机号和短信内容 | sms: | sms:555-555-5555:I am a pretyped message | 392 | | 坐标 | geo: | geo:-78.400364,-85.916993 | 393 | | MeCard名片 | mecard: | MECARD:Simple, Software;Some Address, Somewhere, 20430;TEL:555-555-5555;EMAIL:support@simplesoftware.io; | 394 | | VCard名片 | BEGIN:VCARD | [更多范例](https://en.wikipedia.org/wiki/VCard) | 395 | | Wifi | wifi: | wifi:WEP/WPA;SSID;PSK;Hidden(True/False) | 396 | 397 | 398 | ##在Laravel外的调用方式 399 | 400 | 你还可以在Laravel框架之外调用,只需要实例化 `BaconQrCodeGenerator` 类. 401 | 402 | use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator; 403 | 404 | $qrcode = new BaconQrCodeGenerator; 405 | $qrcode->size(500)->generate('Make a qrcode without Laravel!'); 406 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | ./tests/ 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/DataTypes/BTC.php: -------------------------------------------------------------------------------- 1 | setProperties($arguments); 57 | } 58 | 59 | /** 60 | * Returns the correct QrCode format. 61 | * 62 | * @return string 63 | */ 64 | public function __toString() 65 | { 66 | return $this->buildBitCoinString(); 67 | } 68 | 69 | /** 70 | * Sets the BitCoin arguments. 71 | * 72 | * @param array $arguments 73 | */ 74 | protected function setProperties(array $arguments) 75 | { 76 | if (isset($arguments[0])) { 77 | $this->address = $arguments[0]; 78 | } 79 | 80 | if (isset($arguments[1])) { 81 | $this->amount = $arguments[1]; 82 | } 83 | 84 | if (isset($arguments[2])) { 85 | $this->setOptions($arguments[2]); 86 | } 87 | } 88 | 89 | /** 90 | * Sets the optional BitCoin options. 91 | * 92 | * @param array $options 93 | */ 94 | protected function setOptions(array $options) 95 | { 96 | if (isset($options['label'])) { 97 | $this->label = $options['label']; 98 | } 99 | 100 | if (isset($options['message'])) { 101 | $this->message = $options['message']; 102 | } 103 | 104 | if (isset($options['returnAddress'])) { 105 | $this->returnAddress = $options['returnAddress']; 106 | } 107 | } 108 | 109 | /** 110 | * Builds a BitCoin string. 111 | * 112 | * @return string 113 | */ 114 | protected function buildBitCoinString() 115 | { 116 | $query = http_build_query([ 117 | 'amount' => $this->amount, 118 | 'label' => $this->label, 119 | 'message' => $this->message, 120 | 'r' => $this->returnAddress, 121 | ]); 122 | 123 | $btc = $this->prefix.$this->address.'?'.$query; 124 | 125 | return $btc; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/DataTypes/DataTypeInterface.php: -------------------------------------------------------------------------------- 1 | setProperties($arguments); 45 | } 46 | 47 | /** 48 | * Returns the correct QrCode format. 49 | * 50 | * @return string 51 | */ 52 | public function __toString() 53 | { 54 | return $this->buildEmailString(); 55 | } 56 | 57 | /* 58 | * Builds the email string. 59 | * 60 | * @return string 61 | */ 62 | protected function buildEmailString() 63 | { 64 | $email = $this->prefix.$this->email; 65 | 66 | if (isset($this->subject) || isset($this->body)) { 67 | $data = [ 68 | 'subject' => $this->subject, 69 | 'body' => $this->body, 70 | ]; 71 | $email .= '?'.http_build_query($data); 72 | } 73 | 74 | return $email; 75 | } 76 | 77 | /** 78 | * Sets the objects properties. 79 | * 80 | * @param $arguments 81 | */ 82 | protected function setProperties(array $arguments) 83 | { 84 | if (isset($arguments[0])) { 85 | $this->setEmail($arguments[0]); 86 | } 87 | if (isset($arguments[1])) { 88 | $this->subject = $arguments[1]; 89 | } 90 | if (isset($arguments[2])) { 91 | $this->body = $arguments[2]; 92 | } 93 | } 94 | 95 | /** 96 | * Sets the email property. 97 | * 98 | * @param $email 99 | */ 100 | protected function setEmail($email) 101 | { 102 | if ($this->isValidEmail($email)) { 103 | $this->email = $email; 104 | } 105 | } 106 | 107 | /** 108 | * Ensures an email is valid. 109 | * 110 | * @param string $email 111 | * 112 | * @return bool 113 | */ 114 | protected function isValidEmail($email) 115 | { 116 | if (! filter_var($email, FILTER_VALIDATE_EMAIL)) { 117 | throw new InvalidArgumentException('Invalid email provided'); 118 | } 119 | 120 | return true; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/DataTypes/Geo.php: -------------------------------------------------------------------------------- 1 | latitude = $arguments[0]; 43 | $this->longitude = $arguments[1]; 44 | } 45 | 46 | /** 47 | * Returns the correct QrCode format. 48 | * 49 | * @return string 50 | */ 51 | public function __toString() 52 | { 53 | return $this->prefix.$this->latitude.$this->separator.$this->longitude; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/DataTypes/PhoneNumber.php: -------------------------------------------------------------------------------- 1 | phoneNumber = $arguments[0]; 29 | } 30 | 31 | /** 32 | * Returns the correct QrCode format. 33 | * 34 | * @return string 35 | */ 36 | public function __toString() 37 | { 38 | return $this->prefix.$this->phoneNumber; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/DataTypes/SMS.php: -------------------------------------------------------------------------------- 1 | setProperties($arguments); 43 | } 44 | 45 | /** 46 | * Returns the correct QrCode format. 47 | * 48 | * @return string 49 | */ 50 | public function __toString() 51 | { 52 | return $this->buildSMSString(); 53 | } 54 | 55 | /** 56 | * Sets the phone number and message for a sms message. 57 | * 58 | * @param array $arguments 59 | */ 60 | protected function setProperties(array $arguments) 61 | { 62 | if (isset($arguments[0])) { 63 | $this->phoneNumber = $arguments[0]; 64 | } 65 | if (isset($arguments[1])) { 66 | $this->message = $arguments[1]; 67 | } 68 | } 69 | 70 | /** 71 | * Builds a SMS string. 72 | * 73 | * @return string 74 | */ 75 | protected function buildSMSString() 76 | { 77 | $sms = $this->prefix.$this->phoneNumber; 78 | 79 | if (isset($this->message)) { 80 | $sms .= $this->separator.$this->message; 81 | } 82 | 83 | return $sms; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/DataTypes/WiFi.php: -------------------------------------------------------------------------------- 1 | setProperties($arguments); 57 | } 58 | 59 | /** 60 | * Returns the correct QrCode format. 61 | * 62 | * @return string 63 | */ 64 | public function __toString() 65 | { 66 | return $this->buildWifiString(); 67 | } 68 | 69 | /** 70 | * Builds the WiFi string. 71 | * 72 | * @return string 73 | */ 74 | protected function buildWifiString() 75 | { 76 | $wifi = $this->prefix; 77 | 78 | if (isset($this->encryption)) { 79 | $wifi .= 'T:'.$this->encryption.$this->separator; 80 | } 81 | if (isset($this->ssid)) { 82 | $wifi .= 'S:'.$this->ssid.$this->separator; 83 | } 84 | if (isset($this->password)) { 85 | $wifi .= 'P:'.$this->password.$this->separator; 86 | } 87 | if (isset($this->hidden)) { 88 | $wifi .= 'H:'.$this->hidden.$this->separator; 89 | } 90 | 91 | return $wifi; 92 | } 93 | 94 | /** 95 | * Sets the WiFi properties. 96 | * 97 | * @param $arguments 98 | */ 99 | protected function setProperties(array $arguments) 100 | { 101 | $arguments = $arguments[0]; 102 | if (isset($arguments['encryption'])) { 103 | $this->encryption = $arguments['encryption']; 104 | } 105 | if (isset($arguments['ssid'])) { 106 | $this->ssid = $arguments['ssid']; 107 | } 108 | if (isset($arguments['password'])) { 109 | $this->password = $arguments['password']; 110 | } 111 | if (isset($arguments['hidden'])) { 112 | $this->hidden = $arguments['hidden']; 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/Facades/QrCode.php: -------------------------------------------------------------------------------- 1 | createClass($method); 155 | $dataType->create($arguments); 156 | 157 | return $this->generate(strval($dataType)); 158 | } 159 | 160 | /** 161 | * Generates the QrCode. 162 | * 163 | * @param string $text 164 | * @param string|null $filename 165 | * @return void|\Illuminate\Support\HtmlString|string 166 | * @throws WriterException 167 | * @throws InvalidArgumentException 168 | */ 169 | public function generate(string $text, string $filename = null) 170 | { 171 | $qrCode = $this->getWriter($this->getRenderer())->writeString($text, $this->encoding, $this->errorCorrection); 172 | 173 | if ($this->imageMerge !== null && $this->format === 'png') { 174 | $merger = new ImageMerge(new Image($qrCode), new Image($this->imageMerge)); 175 | $qrCode = $merger->merge($this->imagePercentage); 176 | } 177 | 178 | if ($filename) { 179 | file_put_contents($filename, $qrCode); 180 | 181 | return; 182 | } 183 | 184 | if (class_exists(\Illuminate\Support\HtmlString::class)) { 185 | return new \Illuminate\Support\HtmlString($qrCode); 186 | } 187 | 188 | return $qrCode; 189 | } 190 | 191 | /** 192 | * Merges an image over the QrCode. 193 | * 194 | * @param string $filepath 195 | * @param float $percentage 196 | * @param SimpleSoftwareIO\QrCode\boolean|bool $absolute 197 | * @return Generator 198 | */ 199 | public function merge(string $filepath, float $percentage = .2, bool $absolute = false): self 200 | { 201 | if (function_exists('base_path') && ! $absolute) { 202 | $filepath = base_path().$filepath; 203 | } 204 | 205 | $this->imageMerge = file_get_contents($filepath); 206 | $this->imagePercentage = $percentage; 207 | 208 | return $this; 209 | } 210 | 211 | /** 212 | * Merges an image string with the center of the QrCode. 213 | * 214 | * @param string $content 215 | * @param float $percentage 216 | * @return Generator 217 | */ 218 | public function mergeString(string $content, float $percentage = .2): self 219 | { 220 | $this->imageMerge = $content; 221 | $this->imagePercentage = $percentage; 222 | 223 | return $this; 224 | } 225 | 226 | /** 227 | * Sets the size of the QrCode. 228 | * 229 | * @param int $pixels 230 | * @return Generator 231 | */ 232 | public function size(int $pixels): self 233 | { 234 | $this->pixels = $pixels; 235 | 236 | return $this; 237 | } 238 | 239 | /** 240 | * Sets the format of the QrCode. 241 | * 242 | * @param string $format 243 | * @return Generator 244 | * @throws InvalidArgumentException 245 | */ 246 | public function format(string $format): self 247 | { 248 | if (! in_array($format, ['svg', 'eps', 'png'])) { 249 | throw new InvalidArgumentException("\$format must be svg, eps, or png. {$format} is not a valid."); 250 | } 251 | 252 | $this->format = $format; 253 | 254 | return $this; 255 | } 256 | 257 | /** 258 | * Sets the foreground color of the QrCode. 259 | * 260 | * @param int $red 261 | * @param int $green 262 | * @param int $blue 263 | * @param null|int $alpha 264 | * @return Generator 265 | */ 266 | public function color(int $red, int $green, int $blue, ?int $alpha = null): self 267 | { 268 | $this->color = $this->createColor($red, $green, $blue, $alpha); 269 | 270 | return $this; 271 | } 272 | 273 | /** 274 | * Sets the background color of the QrCode. 275 | * 276 | * @param int $red 277 | * @param int $green 278 | * @param int $blue 279 | * @param null|int $alpha 280 | * @return Generator 281 | */ 282 | public function backgroundColor(int $red, int $green, int $blue, ?int $alpha = null): self 283 | { 284 | $this->backgroundColor = $this->createColor($red, $green, $blue, $alpha); 285 | 286 | return $this; 287 | } 288 | 289 | /** 290 | * Sets the eye color for the provided eye index. 291 | * 292 | * @param int $eyeNumber 293 | * @param int $innerRed 294 | * @param int $innerGreen 295 | * @param int $innerBlue 296 | * @param int $outterRed 297 | * @param int $outterGreen 298 | * @param int $outterBlue 299 | * @return Generator 300 | * @throws InvalidArgumentException 301 | */ 302 | public function eyeColor(int $eyeNumber, int $innerRed, int $innerGreen, int $innerBlue, int $outterRed = 0, int $outterGreen = 0, int $outterBlue = 0): self 303 | { 304 | if ($eyeNumber < 0 || $eyeNumber > 2) { 305 | throw new InvalidArgumentException("\$eyeNumber must be 0, 1, or 2. {$eyeNumber} is not valid."); 306 | } 307 | 308 | $this->eyeColors[$eyeNumber] = new EyeFill( 309 | $this->createColor($innerRed, $innerGreen, $innerBlue), 310 | $this->createColor($outterRed, $outterGreen, $outterBlue) 311 | ); 312 | 313 | return $this; 314 | } 315 | 316 | public function gradient($startRed, $startGreen, $startBlue, $endRed, $endGreen, $endBlue, string $type): self 317 | { 318 | $type = strtoupper($type); 319 | $this->gradient = new Gradient( 320 | $this->createColor($startRed, $startGreen, $startBlue), 321 | $this->createColor($endRed, $endGreen, $endBlue), 322 | GradientType::$type() 323 | ); 324 | 325 | return $this; 326 | } 327 | 328 | /** 329 | * Sets the eye style. 330 | * 331 | * @param string $style 332 | * @return Generator 333 | * @throws InvalidArgumentException 334 | */ 335 | public function eye(string $style): self 336 | { 337 | if (! in_array($style, ['square', 'circle'])) { 338 | throw new InvalidArgumentException("\$style must be square or circle. {$style} is not a valid eye style."); 339 | } 340 | 341 | $this->eyeStyle = $style; 342 | 343 | return $this; 344 | } 345 | 346 | /** 347 | * Sets the style of the blocks for the QrCode. 348 | * 349 | * @param string $style 350 | * @param float $size 351 | * @return Generator 352 | * @throws InvalidArgumentException 353 | */ 354 | public function style(string $style, float $size = 0.5): self 355 | { 356 | if (! in_array($style, ['square', 'dot', 'round'])) { 357 | throw new InvalidArgumentException("\$style must be square, dot, or round. {$style} is not a valid."); 358 | } 359 | 360 | if ($size < 0 || $size >= 1) { 361 | throw new InvalidArgumentException("\$size must be between 0 and 1. {$size} is not valid."); 362 | } 363 | 364 | $this->style = $style; 365 | $this->styleSize = $size; 366 | 367 | return $this; 368 | } 369 | 370 | /** 371 | * Sets the encoding for the QrCode. 372 | * Possible values are 373 | * ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, 374 | * ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10, ISO-8859-11, 375 | * ISO-8859-12, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16, 376 | * SHIFT-JIS, WINDOWS-1250, WINDOWS-1251, WINDOWS-1252, WINDOWS-1256, 377 | * UTF-16BE, UTF-8, ASCII, GBK, EUC-KR. 378 | * 379 | * @param string $encoding 380 | * @return Generator 381 | */ 382 | public function encoding(string $encoding): self 383 | { 384 | $this->encoding = strtoupper($encoding); 385 | 386 | return $this; 387 | } 388 | 389 | /** 390 | * Sets the error correction for the QrCode. 391 | * L: 7% loss. 392 | * M: 15% loss. 393 | * Q: 25% loss. 394 | * H: 30% loss. 395 | * 396 | * @param string $errorCorrection 397 | * @return Generator 398 | */ 399 | public function errorCorrection(string $errorCorrection): self 400 | { 401 | $errorCorrection = strtoupper($errorCorrection); 402 | $this->errorCorrection = ErrorCorrectionLevel::$errorCorrection(); 403 | 404 | return $this; 405 | } 406 | 407 | /** 408 | * Sets the margin of the QrCode. 409 | * 410 | * @param int $margin 411 | * @return Generator 412 | */ 413 | public function margin(int $margin): self 414 | { 415 | $this->margin = $margin; 416 | 417 | return $this; 418 | } 419 | 420 | /** 421 | * Fetches the Writer. 422 | * 423 | * @param ImageRenderer $renderer 424 | * @return Writer 425 | */ 426 | public function getWriter(ImageRenderer $renderer): Writer 427 | { 428 | return new Writer($renderer); 429 | } 430 | 431 | /** 432 | * Fetches the Image Renderer. 433 | * 434 | * @return ImageRenderer 435 | */ 436 | public function getRenderer(): ImageRenderer 437 | { 438 | $renderer = new ImageRenderer( 439 | $this->getRendererStyle(), 440 | $this->getFormatter() 441 | ); 442 | 443 | return $renderer; 444 | } 445 | 446 | /** 447 | * Returns the Renderer Style. 448 | * 449 | * @return RendererStyle 450 | */ 451 | public function getRendererStyle(): RendererStyle 452 | { 453 | return new RendererStyle($this->pixels, $this->margin, $this->getModule(), $this->getEye(), $this->getFill()); 454 | } 455 | 456 | /** 457 | * Fetches the formatter. 458 | * 459 | * @return ImageBackEndInterface 460 | */ 461 | public function getFormatter(): ImageBackEndInterface 462 | { 463 | if ($this->format === 'png') { 464 | return new ImagickImageBackEnd('png'); 465 | } 466 | 467 | if ($this->format === 'eps') { 468 | return new EpsImageBackEnd; 469 | } 470 | 471 | return new SvgImageBackEnd; 472 | } 473 | 474 | /** 475 | * Fetches the module. 476 | * 477 | * @return ModuleInterface 478 | */ 479 | public function getModule(): ModuleInterface 480 | { 481 | if ($this->style === 'dot') { 482 | return new DotsModule($this->styleSize); 483 | } 484 | 485 | if ($this->style === 'round') { 486 | return new RoundnessModule($this->styleSize); 487 | } 488 | 489 | return SquareModule::instance(); 490 | } 491 | 492 | /** 493 | * Fetches the eye style. 494 | * 495 | * @return EyeInterface 496 | */ 497 | public function getEye(): EyeInterface 498 | { 499 | if ($this->eyeStyle === 'square') { 500 | return SquareEye::instance(); 501 | } 502 | 503 | if ($this->eyeStyle === 'circle') { 504 | return SimpleCircleEye::instance(); 505 | } 506 | 507 | return new ModuleEye($this->getModule()); 508 | } 509 | 510 | /** 511 | * Fetches the color fill. 512 | * 513 | * @return Fill 514 | */ 515 | public function getFill(): Fill 516 | { 517 | $foregroundColor = $this->color ?? new Rgb(0, 0, 0); 518 | $backgroundColor = $this->backgroundColor ?? new Rgb(255, 255, 255); 519 | $eye0 = $this->eyeColors[0] ?? EyeFill::inherit(); 520 | $eye1 = $this->eyeColors[1] ?? EyeFill::inherit(); 521 | $eye2 = $this->eyeColors[2] ?? EyeFill::inherit(); 522 | 523 | if ($this->gradient) { 524 | return Fill::withForegroundGradient($backgroundColor, $this->gradient, $eye0, $eye1, $eye2); 525 | } 526 | 527 | return Fill::withForegroundColor($backgroundColor, $foregroundColor, $eye0, $eye1, $eye2); 528 | } 529 | 530 | /** 531 | * Creates a RGB or Alpha channel color. 532 | * @param int $red 533 | * @param int $green 534 | * @param int $blue 535 | * @param null|int $alpha 536 | * @return ColorInterface 537 | */ 538 | public function createColor(int $red, int $green, int $blue, ?int $alpha = null): ColorInterface 539 | { 540 | if (is_null($alpha)) { 541 | return new Rgb($red, $green, $blue); 542 | } 543 | 544 | return new Alpha($alpha, new Rgb($red, $green, $blue)); 545 | } 546 | 547 | /** 548 | * Creates a new DataType class dynamically. 549 | * 550 | * @param string $method 551 | * @return DataTypeInterface 552 | */ 553 | protected function createClass(string $method): DataTypeInterface 554 | { 555 | $class = $this->formatClass($method); 556 | 557 | if (! class_exists($class)) { 558 | throw new BadMethodCallException(); 559 | } 560 | 561 | return new $class(); 562 | } 563 | 564 | /** 565 | * Formats the method name correctly. 566 | * 567 | * @param $method 568 | * @return string 569 | */ 570 | protected function formatClass(string $method): string 571 | { 572 | $method = ucfirst($method); 573 | 574 | $class = "SimpleSoftwareIO\QrCode\DataTypes\\".$method; 575 | 576 | return $class; 577 | } 578 | } 579 | -------------------------------------------------------------------------------- /src/Image.php: -------------------------------------------------------------------------------- 1 | image = imagecreatefromstring($image); 22 | } 23 | 24 | /* 25 | * Returns the width of an image 26 | * 27 | * @return int 28 | */ 29 | public function getWidth() 30 | { 31 | return imagesx($this->image); 32 | } 33 | 34 | /* 35 | * Returns the height of an image 36 | * 37 | * @return int 38 | */ 39 | public function getHeight() 40 | { 41 | return imagesy($this->image); 42 | } 43 | 44 | /** 45 | * Returns the image string. 46 | * 47 | * @return string 48 | */ 49 | public function getImageResource() 50 | { 51 | return $this->image; 52 | } 53 | 54 | /** 55 | * Sets the image string. 56 | * 57 | * @param resource $image 58 | */ 59 | public function setImageResource($image) 60 | { 61 | $this->image = $image; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/ImageMerge.php: -------------------------------------------------------------------------------- 1 | sourceImage = $sourceImage; 95 | $this->mergeImage = $mergeImage; 96 | } 97 | 98 | /** 99 | * Returns an QrCode that has been merge with another image. 100 | * This is usually used with logos to imprint a logo into a QrCode. 101 | * 102 | * @param $percentage float The percentage of size relative to the entire QR of the merged image 103 | * 104 | * @return string 105 | */ 106 | public function merge($percentage) 107 | { 108 | $this->setProperties($percentage); 109 | 110 | $img = imagecreatetruecolor($this->sourceImage->getWidth(), $this->sourceImage->getHeight()); 111 | imagealphablending($img, true); 112 | $transparent = imagecolorallocatealpha($img, 0, 0, 0, 127); 113 | imagefill($img, 0, 0, $transparent); 114 | 115 | imagecopy( 116 | $img, 117 | $this->sourceImage->getImageResource(), 118 | 0, 119 | 0, 120 | 0, 121 | 0, 122 | $this->sourceImage->getWidth(), 123 | $this->sourceImage->getHeight() 124 | ); 125 | 126 | imagecopyresampled( 127 | $img, 128 | $this->mergeImage->getImageResource(), 129 | $this->centerX, 130 | $this->centerY, 131 | 0, 132 | 0, 133 | $this->postMergeImageWidth, 134 | $this->postMergeImageHeight, 135 | $this->mergeImageWidth, 136 | $this->mergeImageHeight 137 | ); 138 | 139 | $this->sourceImage->setImageResource($img); 140 | 141 | return $this->createImage(); 142 | } 143 | 144 | /** 145 | * Creates a PNG Image. 146 | * 147 | * @return string 148 | */ 149 | protected function createImage() 150 | { 151 | ob_start(); 152 | imagepng($this->sourceImage->getImageResource()); 153 | 154 | return ob_get_clean(); 155 | } 156 | 157 | /** 158 | * Sets the objects properties. 159 | * 160 | * @param $percentage float The percentage that the merge image should take up. 161 | * 162 | * @return void 163 | */ 164 | protected function setProperties($percentage) 165 | { 166 | if ($percentage > 1) { 167 | throw new InvalidArgumentException('$percentage must be less than 1'); 168 | } 169 | 170 | $this->sourceImageHeight = $this->sourceImage->getHeight(); 171 | $this->sourceImageWidth = $this->sourceImage->getWidth(); 172 | 173 | $this->mergeImageHeight = $this->mergeImage->getHeight(); 174 | $this->mergeImageWidth = $this->mergeImage->getWidth(); 175 | 176 | $this->calculateOverlap($percentage); 177 | $this->calculateCenter(); 178 | } 179 | 180 | /** 181 | * Calculates the center of the source Image using the Merge image. 182 | * 183 | * @return void 184 | */ 185 | protected function calculateCenter() 186 | { 187 | $this->centerX = intval(($this->sourceImageWidth / 2) - ($this->postMergeImageWidth / 2)); 188 | $this->centerY = intval(($this->sourceImageHeight / 2) - ($this->postMergeImageHeight / 2)); 189 | } 190 | 191 | /** 192 | * Calculates the width of the merge image being placed on the source image. 193 | * 194 | * @param float $percentage 195 | * 196 | * @return void 197 | */ 198 | protected function calculateOverlap($percentage) 199 | { 200 | $this->mergeRatio = round($this->mergeImageWidth / $this->mergeImageHeight, 2); 201 | $this->postMergeImageWidth = intval($this->sourceImageWidth * $percentage); 202 | $this->postMergeImageHeight = intval($this->postMergeImageWidth / $this->mergeRatio); 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /src/QrCodeServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->bind('qrcode', function () { 15 | return new Generator(); 16 | }); 17 | } 18 | 19 | /** 20 | * Get the services provided by the provider. 21 | * 22 | * @return array 23 | */ 24 | public function provides() 25 | { 26 | return [Generator::class]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/DataTypes/BTCTest.php: -------------------------------------------------------------------------------- 1 | btc = new BTC(); 11 | } 12 | 13 | public function test_it_generates_a_valid_btc_qrcode_with_an_address_and_amount() 14 | { 15 | $this->btc->create(['btcaddress', 0.0034]); 16 | 17 | $properFormat = 'bitcoin:btcaddress?amount=0.0034'; 18 | 19 | $this->assertEquals($properFormat, strval($this->btc)); 20 | } 21 | 22 | public function test_it_generates_a_valid_btc_qrcode_with_an_address_amount_and_label() 23 | { 24 | $this->btc->create(['btcaddress', 0.0034, ['label' => 'label']]); 25 | 26 | $properFormat = 'bitcoin:btcaddress?amount=0.0034&label=label'; 27 | 28 | $this->assertEquals($properFormat, strval($this->btc)); 29 | } 30 | 31 | public function test_it_generates_a_valid_btc_qrcode_with_an_address_amount_label_message_and_return_address() 32 | { 33 | $this->btc->create([ 34 | 'btcaddress', 35 | 0.0034, 36 | [ 37 | 'label' => 'label', 38 | 'message' => 'message', 39 | 'returnAddress' => 'https://www.returnaddress.com', 40 | ], 41 | ]); 42 | 43 | $properFormat = 'bitcoin:btcaddress?amount=0.0034&label=label&message=message&r='.urlencode('https://www.returnaddress.com'); 44 | 45 | $this->assertEquals($properFormat, strval($this->btc)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tests/DataTypes/EmailTest.php: -------------------------------------------------------------------------------- 1 | email = new Email(); 11 | } 12 | 13 | public function test_it_generates_the_proper_format_when_only_an_email_address_is_supplied() 14 | { 15 | $this->email->create(['foo@bar.com']); 16 | 17 | $properFormat = 'mailto:foo@bar.com'; 18 | 19 | $this->assertEquals($properFormat, strval($this->email)); 20 | } 21 | 22 | public function test_it_generates_the_proper_format_when_an_email_subject_and_body_are_supplied() 23 | { 24 | $this->email->create(['foo@bar.com', 'foo', 'bar']); 25 | 26 | $properFormat = 'mailto:foo@bar.com?subject=foo&body=bar'; 27 | 28 | $this->assertEquals($properFormat, strval($this->email)); 29 | } 30 | 31 | public function test_it_generates_the_proper_format_when_an_email_and_subject_are_supplied() 32 | { 33 | $this->email->create(['foo@bar.com', 'foo']); 34 | 35 | $properFormat = 'mailto:foo@bar.com?subject=foo'; 36 | 37 | $this->assertEquals($properFormat, strval($this->email)); 38 | } 39 | 40 | public function test_it_generates_the_proper_format_when_only_a_subject_is_provided() 41 | { 42 | $this->email->create([null, 'foo']); 43 | 44 | $properFormat = 'mailto:?subject=foo'; 45 | 46 | $this->assertEquals($properFormat, strval($this->email)); 47 | } 48 | 49 | public function test_it_throws_an_exception_when_an_invalid_email_is_given() 50 | { 51 | $this->expectException(InvalidArgumentException::class); 52 | 53 | $this->email->create(['foo']); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tests/DataTypes/GeoTest.php: -------------------------------------------------------------------------------- 1 | create([10.254, -30.254]); 12 | 13 | $properFormat = 'geo:10.254,-30.254'; 14 | 15 | $this->assertEquals($properFormat, strval($geo)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/DataTypes/PhoneNumberTest.php: -------------------------------------------------------------------------------- 1 | create(['555-555-5555']); 12 | 13 | $properFormat = 'tel:555-555-5555'; 14 | 15 | $this->assertEquals($properFormat, strval($phoneNumber)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/DataTypes/SMSTest.php: -------------------------------------------------------------------------------- 1 | sms = new SMS(); 11 | } 12 | 13 | public function test_it_generates_a_proper_format_with_a_phone_number() 14 | { 15 | $this->sms->create(['555-555-5555']); 16 | 17 | $properFormat = 'sms:555-555-5555'; 18 | 19 | $this->assertEquals($properFormat, strval($this->sms)); 20 | } 21 | 22 | public function test_it_generate_a_proper_format_with_a_message() 23 | { 24 | $this->sms->create([null, 'foo']); 25 | 26 | $properFormat = 'sms:&body=foo'; 27 | 28 | $this->assertEquals($properFormat, strval($this->sms)); 29 | } 30 | 31 | public function test_it_generates_a_proper_format_with_a_phone_number_and_message() 32 | { 33 | $this->sms->create(['555-555-5555', 'foo']); 34 | 35 | $properFormat = 'sms:555-555-5555&body=foo'; 36 | 37 | $this->assertEquals($properFormat, strval($this->sms)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/DataTypes/WiFiTest.php: -------------------------------------------------------------------------------- 1 | wifi = new Wifi(); 11 | } 12 | 13 | public function test_it_generates_a_proper_format_with_just_the_ssid() 14 | { 15 | $this->wifi->create([ 16 | 0 => [ 17 | 'ssid' => 'foo', 18 | ], 19 | ]); 20 | 21 | $properFormat = 'WIFI:S:foo;'; 22 | 23 | $this->assertEquals($properFormat, strval($this->wifi)); 24 | } 25 | 26 | public function test_it_generates_a_proper_format_for_a_ssid_that_is_hidden() 27 | { 28 | $this->wifi->create([ 29 | 0 => [ 30 | 'ssid' => 'foo', 31 | 'hidden' => 'true', 32 | ], 33 | ]); 34 | 35 | $properFormat = 'WIFI:S:foo;H:true;'; 36 | 37 | $this->assertEquals($properFormat, strval($this->wifi)); 38 | } 39 | 40 | public function test_it_generates_a_proper_format_for_a_ssid_encryption_and_password() 41 | { 42 | $this->wifi->create([ 43 | 0 => [ 44 | 'ssid' => 'foo', 45 | 'encryption' => 'WPA', 46 | 'password' => 'bar', 47 | ], 48 | ]); 49 | 50 | $properFormat = 'WIFI:T:WPA;S:foo;P:bar;'; 51 | 52 | $this->assertEquals($properFormat, strval($this->wifi)); 53 | } 54 | 55 | public function test_it_generates_a_proper_format_for_a_ssid_encryption_password_and_is_hidden() 56 | { 57 | $this->wifi->create([ 58 | 0 => [ 59 | 'ssid' => 'foo', 60 | 'encryption' => 'WPA', 61 | 'password' => 'bar', 62 | 'hidden' => 'true', 63 | ], 64 | ]); 65 | 66 | $properFormat = 'WIFI:T:WPA;S:foo;P:bar;H:true;'; 67 | 68 | $this->assertEquals($properFormat, strval($this->wifi)); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /tests/GeneratorTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(Generator::class, (new Generator)->size(100)); 21 | $this->assertInstanceOf(Generator::class, (new Generator)->format('eps')); 22 | $this->assertInstanceOf(Generator::class, (new Generator)->color(255, 255, 255)); 23 | $this->assertInstanceOf(Generator::class, (new Generator)->backgroundColor(255, 255, 255)); 24 | $this->assertInstanceOf(Generator::class, (new Generator)->eyeColor(0, 255, 255, 255, 0, 0, 0)); 25 | $this->assertInstanceOf(Generator::class, (new Generator)->gradient(255, 255, 255, 0, 0, 0, 'vertical')); 26 | $this->assertInstanceOf(Generator::class, (new Generator)->eye('circle')); 27 | $this->assertInstanceOf(Generator::class, (new Generator)->style('round')); 28 | $this->assertInstanceOf(Generator::class, (new Generator)->encoding('UTF-8')); 29 | $this->assertInstanceOf(Generator::class, (new Generator)->errorCorrection('H')); 30 | $this->assertInstanceOf(Generator::class, (new Generator)->margin(2)); 31 | } 32 | 33 | public function test_size_is_passed_to_the_renderer() 34 | { 35 | $generator = (new Generator)->size(100); 36 | 37 | $this->assertEquals(100, $generator->getRendererStyle()->getSize()); 38 | } 39 | 40 | public function test_format_sets_the_image_format() 41 | { 42 | // Disabled until GitHub actions config can be updated to pull in imagick 43 | // $generator = (new Generator)->format('png'); 44 | // $this->assertInstanceOf(ImagickImageBackEnd::class, $generator->getFormatter()); 45 | 46 | $generator = (new Generator)->format('svg'); 47 | $this->assertInstanceOf(SvgImageBackEnd::class, $generator->getFormatter()); 48 | 49 | $generator = (new Generator)->format('eps'); 50 | $this->assertInstanceOf(EpsImageBackEnd::class, $generator->getFormatter()); 51 | } 52 | 53 | public function test_an_exception_is_thrown_if_an_unsupported_format_is_used() 54 | { 55 | $this->expectException(InvalidArgumentException::class); 56 | 57 | (new Generator)->format('foo'); 58 | } 59 | 60 | public function test_color_is_set() 61 | { 62 | $generator = (new Generator)->color(50, 75, 100); 63 | $this->assertEquals(50, $generator->getFill()->getForegroundColor()->toRgb()->getRed()); 64 | $this->assertEquals(75, $generator->getFill()->getForegroundColor()->toRgb()->getGreen()); 65 | $this->assertEquals(100, $generator->getFill()->getForegroundColor()->toRgb()->getBlue()); 66 | 67 | $generator = (new Generator)->color(50, 75, 100, 25); 68 | $this->assertEquals(25, $generator->getFill()->getForegroundColor()->getAlpha()); 69 | $this->assertEquals(50, $generator->getFill()->getForegroundColor()->toRgb()->getRed()); 70 | $this->assertEquals(75, $generator->getFill()->getForegroundColor()->toRgb()->getGreen()); 71 | $this->assertEquals(100, $generator->getFill()->getForegroundColor()->toRgb()->getBlue()); 72 | 73 | $generator = (new Generator)->color(50, 75, 100, 0); 74 | $this->assertEquals(0, $generator->getFill()->getForegroundColor()->getAlpha()); 75 | $this->assertEquals(50, $generator->getFill()->getForegroundColor()->toRgb()->getRed()); 76 | $this->assertEquals(75, $generator->getFill()->getForegroundColor()->toRgb()->getGreen()); 77 | $this->assertEquals(100, $generator->getFill()->getForegroundColor()->toRgb()->getBlue()); 78 | } 79 | 80 | public function test_background_color_is_set() 81 | { 82 | $generator = (new Generator)->backgroundColor(50, 75, 100); 83 | $this->assertEquals(50, $generator->getFill()->getBackgroundColor()->toRgb()->getRed()); 84 | $this->assertEquals(75, $generator->getFill()->getBackgroundColor()->toRgb()->getGreen()); 85 | $this->assertEquals(100, $generator->getFill()->getBackgroundColor()->toRgb()->getBlue()); 86 | 87 | $generator = (new Generator)->backgroundColor(50, 75, 100, 25); 88 | $this->assertEquals(25, $generator->getFill()->getBackgroundColor()->getAlpha()); 89 | $this->assertEquals(50, $generator->getFill()->getBackgroundColor()->toRgb()->getRed()); 90 | $this->assertEquals(75, $generator->getFill()->getBackgroundColor()->toRgb()->getGreen()); 91 | $this->assertEquals(100, $generator->getFill()->getBackgroundColor()->toRgb()->getBlue()); 92 | } 93 | 94 | public function test_eye_color_is_set() 95 | { 96 | $generator = (new Generator)->eyeColor(0, 0, 0, 0, 255, 255, 255); 97 | $generator = $generator->eyeColor(1, 0, 0, 0, 255, 255, 255); 98 | $generator = $generator->eyeColor(2, 0, 0, 0, 255, 255, 255); 99 | 100 | $this->assertEquals(0, $generator->getFill()->getTopLeftEyeFill()->getExternalColor()->getRed()); 101 | $this->assertEquals(0, $generator->getFill()->getTopLeftEyeFill()->getExternalColor()->getGreen()); 102 | $this->assertEquals(0, $generator->getFill()->getTopLeftEyeFill()->getExternalColor()->getBlue()); 103 | $this->assertEquals(255, $generator->getFill()->getTopLeftEyeFill()->getInternalColor()->getRed()); 104 | $this->assertEquals(255, $generator->getFill()->getTopLeftEyeFill()->getInternalColor()->getGreen()); 105 | $this->assertEquals(255, $generator->getFill()->getTopLeftEyeFill()->getInternalColor()->getBlue()); 106 | 107 | $this->assertEquals(0, $generator->getFill()->getTopRightEyeFill()->getExternalColor()->getRed()); 108 | $this->assertEquals(0, $generator->getFill()->getTopRightEyeFill()->getExternalColor()->getGreen()); 109 | $this->assertEquals(0, $generator->getFill()->getTopRightEyeFill()->getExternalColor()->getBlue()); 110 | $this->assertEquals(255, $generator->getFill()->getTopRightEyeFill()->getInternalColor()->getRed()); 111 | $this->assertEquals(255, $generator->getFill()->getTopRightEyeFill()->getInternalColor()->getGreen()); 112 | $this->assertEquals(255, $generator->getFill()->getTopRightEyeFill()->getInternalColor()->getBlue()); 113 | 114 | $generator = (new Generator)->eyeColor(2, 0, 0, 0, 255, 255, 255); 115 | $this->assertEquals(0, $generator->getFill()->getBottomLeftEyeFill()->getExternalColor()->getRed()); 116 | $this->assertEquals(0, $generator->getFill()->getBottomLeftEyeFill()->getExternalColor()->getGreen()); 117 | $this->assertEquals(0, $generator->getFill()->getBottomLeftEyeFill()->getExternalColor()->getBlue()); 118 | $this->assertEquals(255, $generator->getFill()->getBottomLeftEyeFill()->getInternalColor()->getRed()); 119 | $this->assertEquals(255, $generator->getFill()->getBottomLeftEyeFill()->getInternalColor()->getGreen()); 120 | $this->assertEquals(255, $generator->getFill()->getBottomLeftEyeFill()->getInternalColor()->getBlue()); 121 | } 122 | 123 | public function test_eye_color_throws_exception_with_number_greater_than_2() 124 | { 125 | $this->expectException(InvalidArgumentException::class); 126 | (new Generator)->eyeColor(3, 0, 0, 0, 255, 255, 255); 127 | } 128 | 129 | public function test_eye_color_throws_exception_with_negative_number() 130 | { 131 | $this->expectException(InvalidArgumentException::class); 132 | (new Generator)->eyeColor(-1, 0, 0, 0, 255, 255, 255); 133 | } 134 | 135 | public function test_grandient_is_set() 136 | { 137 | $generator = (new Generator)->gradient(0, 0, 0, 255, 255, 255, 'vertical'); 138 | $this->assertInstanceOf(Gradient::class, $generator->getFill()->getForegroundGradient()); 139 | } 140 | 141 | public function test_eye_style_is_set() 142 | { 143 | $generator = (new Generator)->eye('circle'); 144 | $this->assertInstanceOf(SimpleCircleEye::class, $generator->getEye()); 145 | 146 | $generator = (new Generator)->eye('square'); 147 | $this->assertInstanceOf(SquareEye::class, $generator->getEye()); 148 | } 149 | 150 | public function test_invalid_eye_throws_an_exception() 151 | { 152 | $this->expectException(InvalidArgumentException::class); 153 | (new Generator)->eye('foo'); 154 | } 155 | 156 | public function test_style_is_set() 157 | { 158 | $generator = (new Generator)->style('square'); 159 | $this->assertInstanceOf(SquareModule::class, $generator->getModule()); 160 | 161 | $generator = (new Generator)->style('dot', .1); 162 | $this->assertInstanceOf(DotsModule::class, $generator->getModule()); 163 | 164 | $generator = (new Generator)->style('round', .3); 165 | $this->assertInstanceOf(RoundnessModule::class, $generator->getModule()); 166 | } 167 | 168 | public function test_an_exception_is_thrown_for_an_invalid_style() 169 | { 170 | $this->expectException(InvalidArgumentException::class); 171 | (new Generator)->style('foo'); 172 | } 173 | 174 | public function test_an_exception_is_thrown_for_a_number_over_1() 175 | { 176 | $this->expectException(InvalidArgumentException::class); 177 | (new Generator)->style('round', 1.1); 178 | } 179 | 180 | public function test_an_exception_is_thrown_for_a_number_under_0() 181 | { 182 | $this->expectException(InvalidArgumentException::class); 183 | (new Generator)->style('round', -.1); 184 | } 185 | 186 | public function test_an_exception_is_thrown_for_1() 187 | { 188 | $this->expectException(InvalidArgumentException::class); 189 | (new Generator)->style('round', 1); 190 | } 191 | 192 | public function test_get_renderer_returns_renderer() 193 | { 194 | $this->assertInstanceOf(RendererStyle::class, (new Generator)->getRendererStyle()); 195 | } 196 | 197 | public function test_it_calls_a_valid_dynamic_method_and_generates_a_qrcode() 198 | { 199 | $result = (new Generator)->btc('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'); 200 | $this->assertEquals("\n\n", $result); 201 | } 202 | 203 | public function test_it_throws_an_exception_if_datatype_is_not_found() 204 | { 205 | $this->expectException(BadMethodCallException::class); 206 | (new Generator)->notReal('fooBar'); 207 | } 208 | 209 | public function test_generator_can_return_illuminate_support_htmlstring() 210 | { 211 | $this->getMockBuilder(\Illuminate\Support\HtmlString::class)->getMock(); 212 | $this->assertInstanceOf(\Illuminate\Support\HtmlString::class, (new Generator)->generate('fooBar')); 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /tests/ImageMergeTest.php: -------------------------------------------------------------------------------- 1 | testImagePath = file_get_contents(dirname(__FILE__).'/Images/simplesoftware-icon-grey-blue.png'); 46 | $this->mergeImagePath = file_get_contents(dirname(__FILE__).'/Images/200x300.png'); 47 | $this->testImage = new ImageMerge( 48 | new Image($this->testImagePath), 49 | new Image($this->mergeImagePath) 50 | ); 51 | 52 | $this->testImageSaveLocation = dirname(__FILE__).'/testImage.png'; 53 | $this->compareTestSaveLocation = dirname(__FILE__).'/compareImage.png'; 54 | } 55 | 56 | public function tearDown(): void 57 | { 58 | @unlink($this->testImageSaveLocation); 59 | @unlink($this->compareTestSaveLocation); 60 | } 61 | 62 | public function test_it_merges_two_images_together_and_centers_it() 63 | { 64 | //We know the source image is 512x512 and the merge image is 200x300 65 | $source = imagecreatefromstring($this->testImagePath); 66 | $merge = imagecreatefromstring($this->mergeImagePath); 67 | 68 | //Create a PNG and place the image in the middle using 20% of the area. 69 | imagecopyresampled( 70 | $source, 71 | $merge, 72 | 205, 73 | 222, 74 | 0, 75 | 0, 76 | 102, 77 | 67, 78 | 536, 79 | 354 80 | ); 81 | imagepng($source, $this->compareTestSaveLocation); 82 | 83 | $testImage = $this->testImage->merge(.2); 84 | file_put_contents($this->testImageSaveLocation, $testImage); 85 | 86 | $this->assertEquals(file_get_contents($this->compareTestSaveLocation), file_get_contents($this->testImageSaveLocation)); 87 | } 88 | 89 | public function test_it_throws_an_exception_when_percentage_is_greater_than_1() 90 | { 91 | $this->expectException(InvalidArgumentException::class); 92 | $this->testImage->merge(1.1); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /tests/ImageTest.php: -------------------------------------------------------------------------------- 1 | imagePath = file_get_contents(dirname(__FILE__).'/Images/simplesoftware-icon-grey-blue.png'); 39 | $this->image = new Image($this->imagePath); 40 | 41 | $this->testImageSaveLocation = dirname(__FILE__).'/testImage.png'; 42 | $this->compareTestSaveLocation = dirname(__FILE__).'/compareImage.png'; 43 | } 44 | 45 | public function tearDown(): void 46 | { 47 | @unlink($this->testImageSaveLocation); 48 | @unlink($this->compareTestSaveLocation); 49 | } 50 | 51 | /** 52 | * Must test that the outputted PNG is the same because you can not compare resources. 53 | */ 54 | public function test_it_loads_an_image_string_into_a_resource() 55 | { 56 | imagepng(imagecreatefromstring($this->imagePath), $this->compareTestSaveLocation); 57 | imagepng($this->image->getImageResource(), $this->testImageSaveLocation); 58 | 59 | $correctImage = file_get_contents($this->compareTestSaveLocation); 60 | $testImage = file_get_contents($this->testImageSaveLocation); 61 | 62 | $this->assertEquals($correctImage, $testImage); 63 | } 64 | 65 | public function test_it_gets_the_correct_height() 66 | { 67 | $correctHeight = 512; 68 | 69 | $testHeight = $this->image->getHeight(); 70 | 71 | $this->assertEquals($correctHeight, $testHeight); 72 | } 73 | 74 | public function test_it_gets_the_correct_width() 75 | { 76 | $correctWidth = 512; 77 | 78 | $testWidth = $this->image->getWidth(); 79 | 80 | $this->assertEquals($correctWidth, $testWidth); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /tests/Images/200x300.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/tests/Images/200x300.png -------------------------------------------------------------------------------- /tests/Images/simplesoftware-icon-grey-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimpleSoftwareIO/simple-qrcode/8469e078ef9919e1ca1a49f31b36f713e92bde3a/tests/Images/simplesoftware-icon-grey-blue.png --------------------------------------------------------------------------------