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
.htaccessornginx.confrewrites 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=shorturlacceptPOSTdata (url, optionalkeyword) 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=statsor 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
authhook. - 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_urloption 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
- Internal Marketing – Teams can generate branded short links with analytics to track campaign performance.
- Developer Tooling – Embed YOURLS into CI/CD pipelines to generate temporary URLs for test environments.
- Self‑Hosted SaaS – Offer a URL shortening micro‑service to clients, leveraging the plugin system for custom branding.
- 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
| Feature | YOURLS |
|---|---|
| Zero‑Cost, Open Source | MIT licensed, no vendor lock‑in |
| Full Data Control | All stats stored locally; no external tracking |
| Extensibility | Hook‑based plugin system, Webhooks |
| Lightweight | < 200 KB codebase, minimal dependencies |
| API‑Ready | RESTful endpoints for programmatic use |
| Scalable | Compatible 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
Related Apps in apis-services
Mastodon
Decentralized, real‑time social networking
Discourse
Open‑source community forum platform with real‑time chat and AI
Rocket.Chat
Secure, open‑source team communication platform
Novu
Unified notification platform for multi‑channel delivery
Mattermost
Secure, self‑hosted team collaboration with chat, voice, and AI
Jitsi Meet
Free, encrypted video conferencing for everyone
Weekly Views
Repository Health
Information
Explore More Apps
DOMjudge
Automated programming contest management system
SelfHostBlocks
Your privacy‑first, NixOS‑powered self‑hosting platform
Traggo
Tag‑based time tracking for flexible work logging
Mainsail
Lightweight web UI for Klipper printers
Samba
Self-hosted other
Audioserve
Simple, minimal audio book server for web and mobile