Content Index
QR (Quick Response) codes are an evolution of the two-dimensional barcodes we see every day on the products we buy. They are capable of storing different types of information: numbers, text, URLs, contact data, among others. Precisely that versatility —having encoded information without exposing it directly— is what has made them the medium par excellence for sharing resources quickly, both on physical products and on websites.
To read a QR code you do not need any special application: it is enough to open your smartphone camera, point it at the code, and the operating system takes care of the rest.
A QR code looks like the following:

Laravel, being the quintessential PHP framework for web development, has a huge ecosystem of third-party packages that expand its capabilities without needing to reinvent the wheel. Generating QR codes is no exception: there is a Laravel package developed specifically for this framework that allows us to create and customize QR codes with very few lines of code.
In this post we will look at how to implement a QR code generator in Laravel, step by step: from installing the package to customizing the QR with colors, size, and even a superimposed image.
Install the Simple QrCode Package in Laravel
The package we are going to use is SimpleSoftwareIO/simple-qrcode, one of the most popular and maintained packages for generating QR codes in PHP. You can review its complete documentation on the official GitHub page.
To install it, run the following command in your Laravel project terminal:
composer require simplesoftwareio/simple-qrcode "~4"Make sure you have Composer installed and your Laravel environment properly configured (PHP, necessary extensions, etc.) before proceeding.
Once the installation is complete, the package becomes available immediately thanks to Laravel's automatic package discovery: you do not need to register any Service Provider or Alias manually.
Generate a Simple QR Code with Laravel
With the package installed, open the controller where you want to implement the logic and add the following function:
use SimpleSoftwareIO\QrCode\Facades\QrCode;
public function qr_generate()
{
// Generate QR in SVG format with red color
//QrCode::format('svg')->size(700)->color(255,0,0)->generate('Desarrollo libre Andres', '../public/qrcodes/qrcode.svg');
// Generate QR in PNG format with superimposed logo
QrCode::format('png')
->size(700)
->color(255, 0, 0)
->merge('https://www.desarrollolibre.net/assets/img/logo.png', .3, true)
->generate('Desarrollo libre Andres', '../public/qrcodes/qrcode.png');
}Code Explanation
The flow is quite straightforward. We use the Facade QrCode which exposes a fluent interface (method chaining) to build the QR with the configuration we need:
format('png')— Defines the output image format. You can use'png'or'svg'. The SVG format is ideal for web because it scales without losing quality, while PNG is more compatible when you need a raster image.size(700)— Sets the size of the QR in pixels (width and height are equal, since it is always square).color(255, 0, 0)— Defines the color of the QR modules in RGB format. In this example, pure red. The background is white by default, although it can also be customized withbackgroundColor().merge()— Superimposes an image (for example, a logo) in the center of the QR code. It receives three parameters: the path or URL of the image, the relative size percentage to the QR (.3equals 30%), and a boolean to indicate whether the image should be scaled absolutely.generate('text', 'path')— Receives the content to encode (a URL, free text, etc.) and the path where the generated file will be stored within the project.
Customize the QR Code
The package offers plenty of flexibility to adjust the appearance of the QR. When generating and saving the code in the public folder of your project, the fundamental parameters you must configure through the QrCode Facade are:
- Format —
format('png')orformat('svg') - Size —
size(pixels) - Color —
color(R, G, B) - Content to encode — the text or URL that is converted into a QR
With those four basic parameters you already get a result like the following:

More Examples with Simple QrCode for Laravel
Below are some concrete examples from the simplesoftwareio/simple-qrcode package for you to adapt directly to your project. If you haven't installed the package with the fixed version yet, you can also do it like this:
$ composer require simplesoftwareio/simple-qrcodeThese are some representative examples illustrating the most common combinations:
// QR in SVG with red color
QrCode::format('svg')->size(700)->color(255,0,0)->generate('Desarrollo libre Andres', '../public/qrcodes/qrcode.svg');
// QR in PNG with superimposed logo (merge)
QrCode::format('png')->size(700)->color(255, 0, 0)->merge('/assets/img/logo.png', .3, true)->generate('Desarrollo libre Andres', '../public/qrcodes/qrcode.png');The package has a very self-descriptive API:
format()defines the image type,color()accepts RGB values,size()controls the dimensions,merge()embeds a logo, andgenerate()receives the text to encode along with the destination path of the resulting file.
As you can see, with a few chained methods it is possible to control the format, size, color, and content of the QR, which is finally generated and stored in the location you indicate within your application —in this example, inside Laravel's public folder.