Generate QR Codes with PHP
HTML-код
- Опубликовано: 13 июн 2024
- Please consider supporting my channel:
☕ ko-fi.com/davehollingworth
Learn how to generate a QR code using PHP.
QR codes are two dimensional barcodes that can hold up to 2000 characters of text. Depending on the content, when you scan a QR code they can simply display the text they contain; open a browser at a specific URL, call a phone number and so on.
In the context of a web application, you might want to use them to link to an online invoice, a unique code for a ticket to gain entry to an event, a location on a map and so on.
Full PHP course:
➤ davehollingworth.net/phpy
In this video you'll learn:
• the basics of generating a QR code using PHP
• changing the colour and size
• adding labels and watermark images
• setting error correction levels
• outputting the QR code as a PNG image
• saving the image to a file on the server
Code shown in the video:
‣ gist.github.com/daveh/c63af8c...
Endroid QR-Code package:
‣ github.com/endroid/qr-code
WikiPedia QR Code:
en.wikipedia.org/wiki/QR_code
CSS:
‣ watercss.kognise.dev/
00:00 Introduction
00:50 Install package
01:18 Create a QR code
02:05 Set size and margin
03:32 Change colours
04:19 Add a label
05:10 Change label colour
05:34 Change label alignment
06:04 Add a logo
06:51 Resize the logo
07:09 Readability
07:38 Set the error correction level
08:15 Save to a local file
09:23 Summary
#PHP #qrcode - Наука
Out of interest, why do you want to generate a QR code in PHP?
Can you do a file streaming (copying a file from one server to another as a post )tutorial using php and Guzzle
Honestly, this video was just recommended to me by RUclips's hIgH-tIeRer algorithm. But seriously, this is a very well-made video that isn't getting enough attention.
@techzacharyzn6296 It takes time for programming vids to get views.
It's quite hassle if you call an API to generate the QRCode when you can make it inside the app.
@@tristanjayvirtudazo2268 Just to clarify, the video uses a third-party package to generate the QR code, not an API - the package is installed inside the application code.
Your tutorials are incredibly clear and well explained. Thank you, Dave.
This is crazy ... I never knew I could do this in PHP ... I thought it was only JavaScript that I could use to do Qr codes... Man you're on another level of PHP... And also your tutorials are way too awesome, simple, concise and beginner friendly
Thank you dave for such a simple explanation.
A nice and simple tutorial, thanks dave!
It's awesome, David. Thanks for sharing!
Dave, as always your explanation is amazing!
I expect more courses from you in Udemy related to more Senior PHP content.
Good Tutorial. Thanks for taking your time and putting much effort produce high quality content.
To find a job as a web developer, I think it will come in handy at the interview, and of course in future work. Thank you very much for your work!
hello Dave, thank you for awesome content, really looking forward for more videos like this
Very interesting, Thanks Dave
literatly the best programming video ever
Awesome videos I wish you can start making videos about Object Oriented PHP, I love how you explain things
I am impressed the moment you do not just use a library but show us how to write the algorithm...
Merci beaucoup ! très bon travail
Thank you for this video. 👍
Thank you for your easy and professional tutorials.
Can you make one about PHP and LDAP????
Excellent lecture
nice thanks sir it works!
thank you so much sir, ive appreciate you
Thanks, this is useful!
What an amazingly valuable content. Insta sub. Thank you!
Hi Dave, thank you for the continued content. I have no need to generate a QR code but I like to follow your content as I find it valuable.
Do you have anymore Udemy course planned?
Thank you for your kind words Alan! Currently working on rewriting my PHP MVC course, I hope to have it ready soon 🙂
you are really brilliant
That is amazing!
Great thanks. One can create QR code for e-invoice
This is great tutorial. Thanks for sharing. Do you have any video that explains how to scan the QR code?
Not at the moment, but I might do a video about this in the future if I get chance.
hi Sir, on this encoder side of the qr, how do i make a decoding in my project? do i have to use composer to install another package?
Yes, there are several packages here: packagist.org/?query=decode%20qr
We need more PHP tuts from intermediate to advanced level like this. btw how to implement login to PHP app using QR Code
great vid, really useful. Do you have a video for QR reading?
Not at the moment I'm afraid, but it's on my list!
Thanku...❤❤
Thank you for this. I got as far as the header, but I received the error that headers have already been set, and I could not proceed that way.
I've subscribed. Thank you.
Try this: ruclips.net/video/_WYExkPyYuc/видео.html (and thank you for subscribing!)
@@dave-hollingworth Thank you very much. Such a small thing but a massive need-to-know.
In the end, I decided to save the QR code as a file, and then insert the URI path into my database.
Thank you Dave. You are an awesome teacher. But please can you do a tutorial that teaches how to build REST APIS in Codeigniter 4 using JWT? Seen some tutorials, but they are not so great. I recently bought you CI4 tutorial on Udemy.
how can i make rounded cornders of a qrcode?
and can i make the logo background free, or add some margin to the logo
You could process the image afterwards to get rounded corners
Thanks, it's really informative, can you please share details on how I can add an image to the description?
There's a link in the description to the official documentation: github.com/endroid/qr-code
@@dave-hollingworth Thanks Dave
Hello David, I'm following your PHP for beginners course on Udemy but do you now why it appears on draft mode? yesterday I had access to it but today It changed to draft mode.
Thank you for letting me know - Udemy tell me this was a technical fault, but it's fixed now - if you still get a problem, please let me know. Thanks!
@@dave-hollingworth Thanks! now all is working and I don't have any problems.
Hey!, what if i need to upload that qr-image or i will want to use in a database?
The video covers how to save the image to a file at time index 8:15
i just get errors when trying to do the composer stage.....
Hi, great Video! But is it possible to change the size, color etc. in a HTML Form in the form.php and not in the code?
Absolutely, just create form input elements that provide those values then use those when setting the properties
@@dave-hollingworth Thank you for the quick response. I will try it out!
Class "Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh" not found
will this be usable in visual studio code also?
Not sure I know what you mean - the editor I use in the video is Visual Studio Code
Hello Dave, this worked perfectly with my Xamp, but it was blank when I uploaded it on live server. Please assist me
Pardon me, It because of the PHP version of the server, I upgraded it and it worked. Thanks
I have a question where can I install the composer?
Installation instructions at getcomposer.org/
Hi Dave, how do I make this a unique QR code every time I press the Generate? Thank you!
It depends on the contents - you could add a random string to the end of the content that would change the image; in the case of a URL, so you don't break the URL you could add a random string like this: example.com/?r=abc123
@@dave-hollingworth Hi Dave, thank you for the quick reply, how do I do this? I'm trying to make a system that will give a unique qr code for every visitor on our school
@@kenaquino3815If you just want a unique string, you can use something like the uniqid function: www.php.net/manual/en/function.uniqid.php
@@dave-hollingworth Thank you so much Dave!
I am getting this error
Fatal error: Uncaught Exception: Unable to generate image: please check if the GD extension is enabled and configured correctly in C:\xampp\htdocs\TestMail\vendor\endroid\qr-code\src\Writer\AbstractGdWriter.php:26 Stack trace: #0 C:\xampp\htdocs\TestMail\vendor\endroid\qr-code\src\Writer\PngWriter.php(25): Endroid\QrCode\Writer\AbstractGdWriter->write(Object(Endroid\QrCode\QrCode), NULL, Object(Endroid\QrCode\Label\Label), Array) #1 C:\xampp\htdocs\TestMail\generate.php(29): Endroid\QrCode\Writer\PngWriter->write(Object(Endroid\QrCode\QrCode), NULL, Object(Endroid\QrCode\Label\Label)) #2 {main} thrown in C:\xampp\htdocs\TestMail\vendor\endroid\qr-code\src\Writer\AbstractGdWriter.php on line 26
You need to install / enable the PHP GD extension - www.google.co.uk/search?q=install+php+gd+extension
Great
please help when i try to install qr code package with composer its show error !! dont know why
text error = failed to download dasprid/enum from dist: the zip extension and unzib/7z commands are both missing
@@laptopmaroc1064Looks like you need to install the PHP zip and 7z extensions
@@dave-hollingworth thank you very much your answer solved the problem for me
Show me how to create Admin Panel
Any discount your course Udemy PHP rest API
Hello is there discount your API course on Udemy
You can use this link, it expires in 2 days: www.udemy.com/course/php-apis/?couponCode=APRIL2023
Does it work with php 8.2?
Yep
Hello my friend, could you do a tutorial about a follow/unfollow system? Thanks very much
Thank you for the idea, I'll put it on my list!
@@dave-hollingworth thank you :)
Does it work in php 8.2
yup
Well now the code is not working because the "endroid" package changed
Please can you be more specific? In what way isn't it working, do you get any error messages?
I'm sorry I wasn't clear with my comment, your code works great actually, the not working part is the package, I get this message "Fatal error: Call to undefined function: imagecreate()"@@dave-hollingworth
👍
i have $16 and i need your course rest api please can it be reduced to $16 dollars
You can learns it free from youtube. Else ping me anyway.
when are you gonna change profile picture?
Interesting question! Why do you think I need to change the profile picture?
Because it's always the same and in your thumbnail too. It makes me nervous.
@@hichamizem3462 Er, ok... well I have been meaning to change it for some time anyway, so I will be changing it soon!
@@dave-hollingworth I really like your new profile ! The smile is giving a really good vibe to your youtube account.
Wow it really seems better now, congratulations:))
Thank you Dave. You are an awesome teacher. But please can you do a tutorial that teaches how to build REST APIS in Codeigniter 4 using JWT? Seen some tutorials, but they are not so great. I recently bought you CI4 tutorial on Udemy.