MCPSERV.CLUB
Shlink

Shlink

Self-Hosted

Self-hosted URL shortener with analytics and QR codes

Active(100)
4.4kstars
0views
Updated 1 day ago
Shlink screenshot

Overview

Discover what makes Shlink powerful

Shlink is a fully self‑hosted URL shortener written in PHP 8.3/8.4 that exposes a rich REST API, a PWA dashboard and a CLI interface for managing links. The core engine is built on the Symfony framework, leveraging its HTTP kernel, routing and dependency injection container. This gives developers a familiar structure for extending or replacing components while keeping the application lightweight enough to run in LAMP stacks, Docker containers, or even serverless PHP runtimes.

Language & Framework

Database

Extensions

Containerization

Overview

Shlink is a fully self‑hosted URL shortener written in PHP 8.3/8.4 that exposes a rich REST API, a PWA dashboard and a CLI interface for managing links. The core engine is built on the Symfony framework, leveraging its HTTP kernel, routing and dependency injection container. This gives developers a familiar structure for extending or replacing components while keeping the application lightweight enough to run in LAMP stacks, Docker containers, or even serverless PHP runtimes.

Technical Stack & Architecture

  • Language & Framework: PHP 8.3/8.4 + Symfony 6.x, using Doctrine ORM for persistence and Symfony Messenger for asynchronous tasks.
  • Database: Supports MySQL, MariaDB, PostgreSQL, Microsoft SQL Server and SQLite via PDO drivers; schema migrations are handled with Doctrine Migrations.
  • Extensions: Requires common PHP extensions (json, curl, pdo, intl, gd, gmp/bcmath). Optional extensions include apcu for caching, xml for SVG QR generation and sockets/bcmath for RabbitMQ integration.
  • Containerization: Official Docker image is available on Docker Hub; the image uses a multi‑stage build, exposing only necessary ports and allowing environment variables for configuration. The container can be orchestrated with Docker Compose, Kubernetes, or any OCI‑compatible platform.
  • API First: All CRUD operations for links, domains and statistics are exposed via a JSON‑based REST API. Authentication is token‑based (JWT or simple bearer tokens) and can be configured per instance.

Core Capabilities

  • Link Management: Create, update, delete short links with optional custom slugs; set expiration dates and redirect rules.
  • Domain Handling: Register multiple hostnames, configure custom SSL/TLS certificates and enforce domain‑level policies.
  • Analytics: Store visit events with IP, user agent, referrer and geolocation (via MaxMind GeoIP). Expose aggregated statistics via API endpoints.
  • QR Code Generation: Dynamically generate QR codes for links in PNG or SVG format using the GD extension.
  • Webhook Support: Emit events on link creation, deletion or visit for downstream processing (e.g., analytics dashboards).
  • CLI Tool: Symfony Console commands enable bulk link creation, export/import of data, and health checks without exposing the API.

Deployment & Infrastructure

Shlink is designed for self‑hosting scenarios where data sovereignty and custom domain control are paramount. It runs on any web server that can execute PHP (Apache, Nginx, FastCGI). For high‑availability setups:

  • Stateless Service: The application itself is stateless; only the database and optional message broker (RabbitMQ) hold state.
  • Horizontal Scaling: Multiple instances can be run behind a load balancer; Doctrine’s caching layer (APCu or Redis) ensures consistent ID generation.
  • CI/CD Friendly: The project ships with GitHub Actions for continuous integration, code coverage reports, and automated Docker image builds.

Integration & Extensibility

  • Plugins: The architecture supports a plugin system where developers can register custom link generators, analytics collectors or authentication providers via Symfony services.
  • Webhooks & Callbacks: External systems can subscribe to events; Shlink supports HTTP callbacks with configurable payloads.
  • Custom Domains & CNAMEs: Developers can programmatically add domains via the API, enabling multi‑tenant deployments.
  • SDKs: While not bundled, community SDKs in PHP, JavaScript and Python simplify integration into existing applications.

Developer Experience

  • Documentation: The official docs are comprehensive, with sections for API reference, CLI usage and Docker deployment. Interactive examples demonstrate common workflows.
  • Community & Support: Active GitHub repository, Slack/Discord channels, and a public issue tracker provide quick assistance. The project is MIT licensed, allowing unrestricted commercial use.
  • Configuration: Most settings are exposed via environment variables or a .env file, making it straightforward to integrate into CI/CD pipelines.

Use Cases

  1. Marketing Campaigns: Generate branded short links, track click‑through rates and embed QR codes in print media.
  2. Internal Tooling: Provide a self‑hosted link shortener for corporate intranets, ensuring URLs stay under company control.
  3. Analytics‑First Projects: Leverage the built‑in visit tracking and GeoIP data to feed dashboards or trigger serverless functions on high traffic.
  4. Multi‑Tenant SaaS: Deploy a Shlink instance per customer, each with its own domain and analytics, using the plugin system to enforce tenant isolation.

Advantages Over Alternatives

  • Open Source & Self‑Hosted: No reliance on third‑party services; full control over data and privacy.
  • Performance & Scalability: Symfony’s HTTP kernel and Doctrine’s efficient queries keep latency low; optional Redis/APCu caching boosts throughput.
  • Extensibility: Plug‑in architecture and a well‑defined API make it easy to add custom business logic or integrate with existing systems.
  • License Freedom: MIT license allows use in proprietary products without attribution or revenue sharing.

Shlink delivers a robust, developer‑friendly URL shortener that balances ease of deployment with deep customization options—ideal for teams that need a self‑hosted, analytics‑rich solution.

Open SourceReady to get started?

Join the community and start self-hosting Shlink today