MCPSERV.CLUB
YOURLS

YOURLS

Self-Hosted

Self-hosted URL shortener with full data control

Active(93)
11.6kstars
0views
Updated 4 days ago

Overview

Discover what makes YOURLS powerful

**YOURLS (Your Own URL Shortener)** is a lightweight, PHP‑based web application that lets developers host their own URL shortening service. At its core, it exposes a REST‑like API and a user interface for creating short links, tracking clicks, and managing analytics—all while keeping the data on the host’s server. The application is intentionally minimalistic yet highly extensible, making it suitable for embedding into larger PHP projects or running as a standalone micro‑service.

Language & Frameworks

Database

Web Layer

Plugin Architecture

Overview

YOURLS (Your Own URL Shortener) is a lightweight, PHP‑based web application that lets developers host their own URL shortening service. At its core, it exposes a REST‑like API and a user interface for creating short links, tracking clicks, and managing analytics—all while keeping the data on the host’s server. The application is intentionally minimalistic yet highly extensible, making it suitable for embedding into larger PHP projects or running as a standalone micro‑service.

Technical Stack & Architecture

  • Language & Frameworks: Pure PHP (≥7.4) with no external framework dependencies, allowing direct integration into any PHP ecosystem. The codebase follows PSR‑4 autoloading and adheres to SOLID principles for testability.
  • Database: Supports MySQL/MariaDB, SQLite, and PostgreSQL via PDO. The schema is intentionally simple (links, clicks, users, options tables), which aids migration and replication.
  • Web Layer: Uses standard Apache/Nginx configurations with .htaccess or nginx.conf rewrites to route short URLs (/s/<code>) to a single PHP entry point. The front‑end is built with Bootstrap 4, ensuring responsive design without heavyweight JS frameworks.
  • Plugin Architecture: Hooks (add_action, do_action) and filters enable developers to inject logic before/after core operations (e.g., custom authentication, analytics enrichment). Plugins are distributed as Composer packages or ZIP archives and can be activated via the admin UI.

Core Capabilities & Developer APIs

  • URL Shortening API: Endpoints such as /api.php?action=shorturl accept POST data (url, optional keyword) and return JSON with the short code, full URL, and statistics. Rate limiting can be added via middleware.
  • Analytics: Each click is recorded with timestamp, referrer, user agent, and IP. Aggregated stats are available via /api.php?action=stats or the admin dashboard, enabling integration with external reporting tools.
  • Authentication & Permissions: Built‑in user system (admin, editor) with password hashing. Developers can replace it with OAuth or LDAP by extending the auth hook.
  • Batch Operations: Bulk creation and deletion of links via CSV upload, useful for migrating legacy shorteners.

Deployment & Infrastructure

  • Self‑Hosting: Requires a LAMP/LEMP stack; Docker images are available on Docker Hub (yourls/yourls) with optional Compose files. The application scales horizontally by sharing the same database; read replicas can be configured for high‑traffic scenarios.
  • Performance: Caching layers (APCu, Redis) can be hooked into the click‑logging routine to reduce DB load. The lightweight codebase keeps memory usage under 50 MB for typical deployments.
  • Security: All inputs are sanitized, and CSRF tokens protect admin actions. HTTPS is mandatory for production to safeguard click data.

Integration & Extensibility

  • Plugins: The plugin system is mature, with dozens of community‑maintained extensions (e.g., custom domains, QR code generation, social media sharing). Developers can create plugins in pure PHP or as Composer packages.
  • Webhooks: Custom events (yourls_insert_link, yourls_click) trigger HTTP callbacks, enabling real‑time integration with external analytics or notification services.
  • Custom Domains: By configuring the base_url option and adjusting DNS, developers can serve short URLs from multiple domains or subdomains without code changes.

Developer Experience

  • Documentation: The official docs (docs.yourls.org) cover installation, API reference, plugin development, and advanced configuration. Inline code comments are plentiful, aiding comprehension.
  • Community: Active GitHub discussions, a dedicated Discord channel, and an “Awesome YOURLS” repo provide support and showcase extensions.
  • Licensing: MIT license permits commercial use without copyleft obligations, making it attractive for SaaS providers.

Use Cases

  1. Internal Marketing – Teams can generate branded short links with analytics to track campaign performance.
  2. Developer Tooling – Embed YOURLS into CI/CD pipelines to generate temporary URLs for test environments.
  3. Self‑Hosted SaaS – Offer a URL shortening micro‑service to clients, leveraging the plugin system for custom branding.
  4. Data‑Privacy Compliance – Organizations that cannot rely on third‑party shorteners (GDPR, CCPA) can host YOURLS to keep click data in‑house.

Advantages Over Alternatives

FeatureYOURLS
Zero‑Cost, Open SourceMIT licensed, no vendor lock‑in
Full Data ControlAll stats stored locally; no external tracking
ExtensibilityHook‑based plugin system, Webhooks
Lightweight< 200 KB codebase, minimal dependencies
API‑ReadyRESTful endpoints for programmatic use
ScalableCompatible with Docker, can share DB across instances

For developers seeking a customizable, self‑hosted URL shortener that can be tightly integrated into existing PHP stacks or exposed as a micro‑service, YOURLS offers the perfect blend of simplicity, flexibility, and community support.

Open SourceReady to get started?

Join the community and start self-hosting YOURLS today

Weekly Views

Loading...
Support Us
Most Popular

Infrastructure Supporter

$5/month

Keep our servers running and help us maintain the best directory for developers

Repository Health

Loading health data...

Information

Category
apis-services
License
MIT
Stars
11.6k
Technical Specs
Pricing
Open Source
Database
Multiple
Docker
Community
Supported OS
LinuxDocker
Author
YOURLS
YOURLS
Last Updated
4 days ago