Self-hosted free QR code generator API and QR code manager source code built with pure PHP and MySQL. It includes static QR codes, dynamic QR redirects, scan analytics, protected QR links, verification pages, PNG/SVG/PDF export, logo support, and JSON API endpoints.
Live demo: qrcode.navneetyadav.me
This repository is for developers, agencies, students, and small teams searching for:
- Free QR code generator source code
- PHP QR code generator with MySQL database
- Free QR code API source code
- Dynamic QR code generator with analytics
- Self-hosted QR code SaaS starter
- cPanel QR code manager script
Most QR generator examples only create a single image. This project is a complete QR management app that can be hosted on regular PHP hosting and extended into a client portal, internal tool, or SaaS product.
- Static QR support for URL, Text, WiFi, vCard, Email, and SMS payloads
- Dynamic QR support with
/r/{token}redirects and editable destinations - Scan tracking with device, browser, OS, referrer, IP, and timeline analytics
- QR image generation with PNG, SVG, PDF, ZIP export, colors, margins, and logos
- Password-protected dynamic QR links
- Public verification pages for QR authenticity
- API key management and JSON API endpoints
- Admin dashboard, roles, user management, pagination, filters, and CSV import
- Secure PHP implementation with PDO prepared statements, bcrypt, sessions, CSRF protection, and rate limiting
- Shared-hosting friendly structure with no framework, Docker, or Node build step required
- PHP 8.2+
- MySQL 5.7+/8.0+ or MariaDB
- Composer
- HTML, CSS, JavaScript
- Local Chart.js asset
- Endroid QR Code, Dompdf, PHPMailer, Dotenv
Generate a QR preview:
curl -X POST "https://yourdomain.com/api/generate" \
-H "Accept: application/json" \
-H "X-API-Key: qrm_your_api_key" \
-F "type=dynamic" \
-F "qr_type=url" \
-F "destination_url=https://example.com" \
-F "foreground_color=#111827" \
-F "background_color=#ffffff"Get QR statistics:
curl "https://yourdomain.com/api/stats/1" \
-H "Accept: application/json" \
-H "X-API-Key: qrm_your_api_key"Record a scan:
curl -X POST "https://yourdomain.com/api/scan/{token}" \
-H "Accept: application/json"/config App, database, and route configuration
/controllers Request handlers
/database Clean schema and upgrade SQL
/models Database models
/public Web root, assets, generated public storage
/src Core app classes, HTTP request, services, helpers
/storage Logs, cache, session storage
/views PHP templates
-
Clone the project into
C:\xampp\htdocs\qr-code -
Install Composer dependencies:
composer install
-
Copy the environment file:
copy .env.example .env
-
Open
.envand update:APP_NAME=QR Control CenterAPP_URL=http://localhost/qr-code/publicDB_NAME=qr_code_managerDB_USER=rootDB_PASS=- set
APP_KEYto any long random string
-
Create the database and tables by importing database/schema.sql
-
Make sure Apache
mod_rewriteis enabled -
Browse to http://localhost/qr-code/public
-
Register the first account. The first user is promoted to
adminautomatically.
- Upload the project and run
composer install --no-dev --optimize-autoloader, or upload the generatedvendor/folder if Composer is unavailable on the server - Point your domain or subdomain document root to
/public; if your host points to the project root, keep the root.htaccessfile in place - Create a MySQL database and import database/schema.sql
- Create
.envfrom.env.examplewith your production values - Set:
APP_ENV=productionAPP_DEBUG=falseSESSION_SECURE=truewhen using HTTPSAPP_URL=https://yourdomain.com
- Ensure these folders are writable:
/storage/cache/storage/logs/storage/sessions/public/storage/exports/public/storage/logos/public/storage/qrs
Run database/upgrade.sql on your current database to add verification fields and API key support.
Use a CSV header like:
name,type,qr_type,url,destination_url,text,foreground_color,background_color,size,margin,custom_domainNotes:
typeshould bestaticordynamicqr_typeshould beurl,text,wifi,vcard,email, orsms- Dynamic rows should include
destination_url - Static URL rows should include
url
- Passwords use bcrypt
- SQL queries use prepared statements through PDO
- CSRF protection is enabled for form submissions
- Scan tracking is rate limited per QR/IP combination
- Password-protected dynamic QR codes use hashed access passwords
- Output in views is escaped with
htmlspecialchars .env, sessions, logs, generated QR assets, and live database dumps are excluded from Git
- Add PHPUnit tests for services and controllers
- Add GeoIP database integration for country/city enrichment
- Add OpenAPI documentation for the JSON API
- Add scheduled cleanup for old exported PDFs and rate-limit cache files
- Improve onboarding screenshots using demo-safe sample data
Free QR code generator, QR code generator source code, QR code API, free QR code API, PHP QR code generator, MySQL QR code manager, dynamic QR code generator, self-hosted QR code SaaS, QR code analytics, QR code tracking, cPanel QR code generator, open source QR code generator PHP.
If this QR code generator source code helps you, star the repository, fork it, open issues with real use cases, and share improvements through pull requests. Stars and issues help other developers find the project faster.