Giter Site home page Giter Site logo

2amigos / qrcode-library Goto Github PK

View Code? Open in Web Editor NEW
218.0 34.0 65.0 28.61 MB

Create QrCodes with ease

Home Page: https://2am.tech/open-source/qrcode-generator

License: Other

PHP 86.14% PostScript 5.64% Hack 0.01% Blade 8.22%
qrcode qr yii2 2amigos php blade blade-components laravel laravel-package

qrcode-library's Introduction

QrCode Library

Latest Version Software License tests Codacy Badge Codacy Badge Total Downloads

This library allows developers to generate QR codes with ease. It works standalone and also provides Yii2 components for its use on the framework.

Documentation

You can read the latest docs on http://qrcode-library.readthedocs.io/en/latest/

Contributing

Please see CONTRIBUTING for details.

Credits

License

The BSD License (BSD). Please see License File for more information.

2amigOS!

Web development has never been so fun!
www.2am.tech

qrcode-library's People

Contributors

2amjsouza avatar hoaaah avatar jafaripur avatar razonyang avatar sjonatas avatar tonydspaniard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qrcode-library's Issues

How to use new version in composer

How I can use new version? It says The requested package 2amigos/yii2-qrcode-helper 1.1.2 exists as 2amigos/yii2-qrcode-helper[0.1.0, 1.0.0, 1.0.1, 1.0.2, 1.0.3, dev-develop, dev-master, 1.0.x-dev] but these a re rejected by your constraint.

Crashes if slash or colon is entered

I'm trying to enter a website as the qrcode, something like google.com/test or https://google.com/test

When I do that, instead of a barcode I get:

���?n�h��

My code is pretty simple:
public function actionQrcode($id = 1, $size = 100, $margin = 80) {
$text = "www.google.com/test";
$qrCode = (new QrCode($text))
->setSize($size)
->setMargin($margin)
->useForegroundColor(0, 0, 0)
->setLabel($id);

$image_path = Yii::$app->basePath . '/web/uploads/barcodes/';
if (!file_exists($image_path)) {
  mkdir($image_path, 0777, TRUE);
}
$qrCode->writeFile($image_path . $id . '.png'); // writer defaults to PNG when none is specified

// display directly to the browser
header('Content-Type: ' . $qrCode->getContentType());
echo $qrCode->writeString();
}

Malformed UTF-8 characters, possibly incorrectly encoded

In wbraganca dynamic form get those error,the code like this =

<?php foreach ($modelCheckListDetail as $i => $modelCheckListDetail): ?>
            <?php
            $qrCode = (new QrCode($modelCheckListDetail->unique_key))
                ->setSize(250)
                ->setMargin(5)
                ->useForegroundColor(51, 153, 255);
            ?>
            <tr class="item">
                <td> <?= ($i + 1) ?> </td>
                <td> <?= $form->field($modelCheckListDetail, "[{$i}]unique_key")->label(false) ?> </td>
                <td> <?php
              
                        header('Content-Type: ' . $qrCode->getContentType());
                        echo $qrCode->writeString();
               
                    ?>
                </td>

            </tr>
        <?php endforeach; ?>

Two (and more) qr-codes on one page

Hello!
Your helper works great for generating one qr code per page. Is it possible to generate for example few links in controller and then show few qr codes on one page? (for example to print them all on one page)

logo and label does not show

Hello

                                    $qrCode = (new QrCode('http://example.com'));
                                    $qrCode->useLogo(__DIR__.'/../../web/img/favicon.png')
                                        ->setSize(250)
                                        ->setMargin(5)
                                        ->useEncoding('UTF-8')
                                        ->setLogoWidth(60)
                                        ->useForegroundColor(26, 179, 148)
                                        ->useBackgroundColor(200, 220, 210)
                                        ->setLabel('name');

                                    // now we can display the qrcode in many ways
                                    // saving the result to a file:

                                        $qrCode->writeFile(__DIR__.'/../../web/upload/_'. Yii::$app->language.'.png');
                                        echo Html::img(__DIR__.'/../../web/upload/_'. Yii::$app->language.'.png');

so i can see logo, and label
https://prnt.sc/kfeb3h

what i did wrong?

Mecard format to support ORG / Company

Currently MECARD doesn't support organisation. Can I request src/Format/MeCardFormat.php add in below?

public $organization;
$data[] = "ORG:{$this->organization};";

Php7.2 can no longer use the Object

use yii\base\Object;

/**
 * Class Encode
 *
 * @author Antonio Ramirez <[email protected]>
 * @link http://www.ramirezcobos.com/
 * @link http://www.2amigos.us/
 * @package dosamigos\qrcode\lib
 */
class Encode extends Object
{

should be excend yii\base\BaseObject

when can php 8.x be supported?

i am use php8 ,
it's had a error when composer require 2amigos/qrcode-library;
when can php 8.x be supported?

i look require bacon/bacon-qr-code: ^1.0,
bacon/bacon-qr-code was updated 2.x

last time , i am thank you good library

How to implement QR Code

I'm new in the Yii2 framework and I'm a bit confused where to put the code to present the QR. I'm trying to create a QR for every entry in my Yii2 advance template. This QR contains the information of the $id. I want the QR code to be generated when the user creates an entry and to present that QR in the view php

here's my controller source code:

<?php

namespace backend\controllers;

use Yii;
use common\models\Weatherstation;
use common\models\WeatherstationSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
/**
- WeatherstationController implements the CRUD actions for Weatherstation model.
  _/
  class WeatherstationController extends Controller
  {
  /_*
  - @inheritdoc
    */
    public function behaviors()
    {
    return [
        'access'=>[
                    'class'=>AccessControl::classname(),
                    'only'=>['create','update'],
                    'rules'=>[
                        [
                            'allow'=>true,
                            'roles'=>['@']
                        ],
                    ]
                ],
        'verbs' => [
            'class' => VerbFilter::className(),
            'actions' => [
                'delete' => ['POST'],
            ],
        ],
    ];
    }
  
  /**
  - Lists all Weatherstation models.
  - @return mixed
    */
    public function actionIndex()
    {
    $searchModel = new WeatherstationSearch();
    $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
    
    return $this->render('index', [
        'searchModel' => $searchModel,
        'dataProvider' => $dataProvider,
    ]);
    }
  
  /**
  - Displays a single Weatherstation model.
  - @param integer $id
  - @return mixed
    */
    public function actionView($id)
    {
    return $this->render('view', [
        'model' => $this->findModel($id),
    ]);
    }
  
  /**
  - Creates a new Weatherstation model.
  - If creation is successful, the browser will be redirected to the 'view' page.
  - @return mixed
    */
    public function actionCreate()
    {
    $model = new Weatherstation();
    
    if ($model->load(Yii::$app->request->post()) && $model->save()) {
        return $this->redirect(['view', 'id' => $model->id]);
    
    } else {
        return $this->render('create', [
            'model' => $model,
        ]);
    }
    }
  
  /**
  - Updates an existing Weatherstation model.
  - If update is successful, the browser will be redirected to the 'view' page.
  - @param integer $id
  - @return mixed
    */
    public function actionUpdate($id)
    {
    $model = $this->findModel($id);
    
    if ($model->load(Yii::$app->request->post()) && $model->save()) {
        return $this->redirect(['view', 'id' => $model->id]);
    } else {
        return $this->render('update', [
            'model' => $model,
        ]);
    }
    }
  
  /**
  - Deletes an existing Weatherstation model.
  - If deletion is successful, the browser will be redirected to the 'index' page.
  - @param integer $id
  - @return mixed
    */
    public function actionDelete($id)
    {
    $this->findModel($id)->delete();
    
    return $this->redirect(['index']);
    }
  
  /**
  - Finds the Weatherstation model based on its primary key value.
  - If the model is not found, a 404 HTTP exception will be thrown.
  - @param integer $id
  - @return Weatherstation the loaded model
  - @throws NotFoundHttpException if the model cannot be found
    */
    protected function findModel($id)
    {
    if (($model = Weatherstation::findOne($id)) !== null) {
        return $model;
    } else {
        throw new NotFoundHttpException('The requested page does not exist.');
    }
    }

}

and here's my view source code for the corresponding controller:

<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use barcode\barcode\BarcodeGenerator;

/\* @var $this yii\web\View _/
/_ @var $model common\models\Weatherstation */

$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Weatherstations', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="weatherstation-view">
    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('Delete', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>
      \
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'WeatherStation_Model',
            'WeatherStation_Name',
            'WeatherStation_Location',
            'WeatherStation_Status',
            'WeatherStation_Gateway',
            'WeatherStation_Logger',
            'WeatherStation_Number',
        ],
    ]) ?>

</div>

RegistryKeyLookupFailed `CoderModulesPath' @ error/module.c/GetMagickModulePath/667 {"userId":1,"exception":"[object] (ImagickException(code: 495): RegistryKeyLookupFailed `CoderModulesPath' @ error/module.c/GetMagickModulePath/667 at C:\\Users\\XavierPalacín\\Projects\\engel\\vendor\\bacon\\bacon-qr-code\\src\\Renderer\\Image\\ImagickImageBackEnd.php:75)

I use Windows 11 with XAMPP with:

  • PHP 8.2.4
  • Apache 2.4
  • ext-imagick-php8.2-ts-x64
  • ImageMagick-7.1.0-18-vc15-x64
RegistryKeyLookupFailed `CoderModulesPath' @ error/module.c/GetMagickModulePath/667 {"userId":1,"exception":"[object] (ImagickException(code: 495): RegistryKeyLookupFailed `CoderModulesPath' @ error/module.c/GetMagickModulePath/667 at C:\\Users\\XavierPalacín\\Projects\\engel\\vendor\\bacon\\bacon-qr-code\\src\\Renderer\\Image\\ImagickImageBackEnd.php:75)

How to personnalize

Hi.
First of all, thank you for your awesome extension !

I would like to personnalize the QR Code (the color for example), but I don't understand how to do it.
Can you give me an example please ? :)
And what are the others personnalizations ?

Thank you !

how to download qr image to local

I use \dosamigos\qrcode\QrCode::png($url); to show qrcode. it's perfect.
when I run action '/user/qrcode' I get
"�PNG � IHDRoo���� #�PLTE���U���'IDAT8��Ա��0����(ܙ�"y w^�e���J���I^�׹@��I��5���Q�!����!�ƫ�����N�U:�&<�2� �2��R��S��՞���_�xT%{�������U�����&#�~���}�=lCF�:��5�%ɔX��(i���:�l&m��%�Ό���L�.ڤ��e&̥���%��w��T6I��\�ґ��r$��T�F���H�]��^_�ɳ�6M�[� ���$[t����=@:ﻥ̖���&v쒸�XP�8�sD��,����G����79ڭ���S\R���z�� ?(�!�ʣ�JC*�e��w��������X5IEND�B`�"
I want to add one button, when I click the button I can download the qrcode image to local

BookMarkFormat not working (reading) iPhone! (iOS) - 13 >

Hello!

BookMarkFormat not working (reading) iOS 13 >

Why?

new QrCode((new BookMarkFormat(['url' => $link]))); - not working
new QrCode((new BookMarkFormat(['title' => 'My Page', 'url' => $link]))); - not working

writeFile();...

Android OS it's ok..

Please, help me!

vcard 4.0 non-english language

$format = new vCardFormat();

$format->lang = "ru-RU";
$format->name = "Antonio тест";
$qrCode = new QrCode($format);
header('Content-Type: ' . $qrCode->getContentType());
echo $qrCode->writeString();

return name «Antonio —Ç–µ—Å—Ç»

Is it possible to save this QR code as a file?

Is it possible to save this qr code as a file into the database and file system? As the image has no source file it simply points to the function that generates it.

Controller:

public function actionQrCode() {
        return QrCode::png( Yii::$app->getRequest()->getQueryParam('id'),  'file.png', Enum::QR_ECLEVEL_L, 8, 4, true );
    }

HTML:
<img src="<?= Url::to(['/product/qr-code', 'id' => $model->id])?>" />

When I look at the source code for the image tag I see the following:
<img src="/product/qr-code?id=17">

How can I save this file?

Cannot use yii\base\Object as Object because 'Object' is a special class name

What steps will reproduce the problem?

在使用组件:2amigos/yii2-qrcode-helper 的时候,报以下bug, please ! thanks

What is the expected result?

在使用组件:2amigos/yii2-qrcode-helper 的时候,报以下bug, please ! thanks

What do you get instead?

image

Additional info

Q A
Yii version 2.0.15
PHP version 7.2.3 nts 64bit
Operating system win10 64bit

how to add a simple string with line-break

Is there any possibility to add a line-break in simple string. For example, when I would scan it will show the string in 2 line like

My name is xyz.
I am a programmer.

Console application

Hello, your qr-code helper doesn’t work in a console application (Yii2 Advanced Project Template). A console application doesn’t use a session component, but you are using this component in Tools::markTime($markerId) and in Tools::timeBenchmark().

Do you have any idea to fix this issue?

SVGWriter does not add Label

Hi,
Thank you so much for your help. I implemented the SVGWriter as you suggested.

But I'm finding a new issue, when using the SVGWriter the Label is not printed.

$qrCode = (new \Da\QrCode\QrCode('https://example.com', null, new SvgWriter()))
            ->setSize(300)
            ->setLabel(new Label('QR Code Text', null,24));

return $qrCode->writeString();

Regards

Originally posted by @cesarcgfg in #39 (comment)

I am facing error Class 'BaconQrCode\Renderer\Image\Png' not found

hi, thanks a lot for such a nice library, I am using qrcode-library which is working fine in localhost, but when I upload it to online hosting it gives the error of
Class 'BaconQrCode\Renderer\Image\Png' not found

My code is like this

$qrCode = (new QrCode($model->name))
                                ->setSize(250)
                                ->setMargin(5)
                                ->useForegroundColor(51, 153, 255);


                                echo '<img src="' . $qrCode->writeDataUri() . '">';

please guide me how can I solve my issue
error

meCard & nickName error

Hi,
There is typo in var 'nickName'. Declared as 'nickName' line 34 but you try to use 'nickname' in line 83.

Additional space between last & first name would be welcome

$data[] = "N:{$this->lastName}{$this->firstName}";

Depends on country firstName is before lastName, so option to reorder them would be usefull.

Apart from above it's cool widget :)

Best regards,
Jarek

Setter functions and clone

Hi,

I wanted to know if there is a reason every setter function clones the object instead of just setting the property? Just seems weird and confusing, not sure if there is actually a point in doing so?

Also some of the "setter" functions are called useSomething instead of setSomething, which also seems a bit weird.

Incorrect QR code generated

To start with, thank you for providing open source libraries for individuals like us to quickly deliver the client tasks. I have a question pertaining to the QR codes generated using your library. Incidentally, few of the random QR codes are not readable.

I checked the 4 elements to be present: - Position marking- Alignment marking- Timing Marking- Quiet zone

It seems all are present, but still the reference attached QR code is not readable? Could you advise the problem in here! Incidentally, my client has printed more than 30K+ QR codes physically, and to control the situation, am trying to first understand the problem - and then find possible solution.

For your reference, the data stored on this reference QR code image is CARD-7818-1407-1311-191015-184607

Any help would be appreciated.
CARD-7818-1407-1311-191015-184607

QR codes not working in iOS 17.4

BookmarFormat doesn't make a readable QR code.

No usable data found, haven't found a work around. Tried with and without a title.

I found a similar issue on Apple website but restarting phone didn't fix the issue. Some other Libs seem to work.

Also tried the generator on this page
https://2am.tech/open-source/qrcode-generator/
and the same thing happened, so it's not my coding.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.