Shlink logo

Shlink

Self-hosted URL shortener with API, CLI, and Docker

Shlink lets you run your own URL shortener on any domain, offering a REST API, command-line tools, QR code generation, and Docker deployment for full control and privacy.

Shlink banner

Overview

Overview

Shlink is a PHP‑based URL shortener you can host on your own domain. It targets developers and teams that need a private, API‑first solution for creating, tracking and managing short links. The platform provides a REST API, a full‑featured command‑line interface, and an optional web client, plus built‑in QR‑code generation.

Deployment

Run Shlink on any server with PHP 8.3 or newer and the required extensions (json, curl, pdo, intl, gd, gmp/bcmath, etc.). It supports MySQL, MariaDB, PostgreSQL, Microsoft SQL Server and SQLite via the appropriate PDO driver. For containerized environments, an official Docker image lets you configure the service through environment variables and start it with a single command. After installation, the shlink-installer script guides you through database setup and generates an API key for secure access.

Extensibility

Because Shlink is built on the Laminas/Mezzio stack, you can extend it with custom middleware, integrate RabbitMQ for asynchronous processing, or enable APCu caching for performance. The project is MIT‑licensed and actively maintained.

Highlights

Full-featured REST API for creating, tracking and managing short links
Command-line interface for installation, API‑key handling and bulk operations
Official Docker image with environment‑variable configuration for rapid deployment
Built-in QR‑code generation and support for MySQL, PostgreSQL, SQLite and more

Pros

  • Complete control over data and branding
  • Extensible via PHP middleware and plugins
  • Supports multiple relational databases
  • Docker ready for CI/CD pipelines

Considerations

  • Requires PHP 8.3+ and specific extensions
  • Self‑hosting adds operational overhead
  • No built-in UI beyond optional hosted client
  • Scaling may need additional infrastructure such as Redis or RabbitMQ

Managed products teams compare with

When teams consider Shlink, these hosted platforms usually appear on the same shortlist.

Bitly logo

Bitly

URL shortening and link management service for creating concise, trackable links with analytics

Cutt.ly logo

Cutt.ly

URL shortener with branded links, QR codes, and analytics

Rebrandly logo

Rebrandly

Branded URL shortener and link management

Looking for a hosted option? These are the services engineering teams benchmark against before choosing open source.

Fit guide

Great for

  • Teams that need a private short‑link service
  • Developers wanting an API‑first link management solution
  • Organizations with existing PHP infrastructure
  • Projects that prefer containerized deployment

Not ideal when

  • Users seeking a plug‑and‑play SaaS solution
  • Environments without PHP 8.3+ support
  • Small personal use where setup effort outweighs benefit
  • Teams lacking resources for server maintenance

How teams use it

Marketing campaign tracking

Generate branded short links with QR codes for offline media and collect click analytics via the API.

Internal documentation

Create short, searchable URLs for intranet resources, improving navigation and reducing broken links.

CI/CD integration

Automate link creation from build pipelines using the REST API, ensuring consistent short URLs across releases.

Analytics dashboard

Retrieve click statistics through the API and feed them into custom reporting tools or BI platforms.

Tech snapshot

PHP99%
Dockerfile1%
Shell1%
HTML1%

Tags

rest-apimezziolaminasphpurl-shortener

Frequently asked questions

Which databases does Shlink support?

MySQL, MariaDB, PostgreSQL, Microsoft SQL Server and SQLite via the appropriate PDO drivers.

How can I run Shlink with Docker?

Pull the official Docker image, set required environment variables (e.g., database credentials), and start the container. The image includes all needed extensions.

How do I secure the Shlink API?

Generate an API key with `bin/cli api-key:generate` and include it in the `Authorization` header of each request.

Can Shlink generate QR codes for short links?

Yes. QR‑code generation in SVG format is built in and requires the PHP `xml` extension.

Project at a glance

Active
Stars
4,601
Watchers
4,601
Forks
369
LicenseMIT
Repo age9 years old
Last commit2 weeks ago
Self-hostingSupported
Primary languagePHP

Last synced 3 hours ago