phil / short-link-bundle
Short links on your own domains: QR codes, start and end dates, visit limits, checked targets, and visits counted without keeping any visitor data.
Package info
github.com/parler-haut-interagir-librement/short-link-bundle
Type:symfony-bundle
pkg:composer/phil/short-link-bundle
Requires
- php: >=8.5
- ext-mbstring: *
- doctrine/dbal: ^4.5
- doctrine/orm: ^3.7
- phil/qr-code: ^0.1.1@dev
- phil/rate-limit: ^0.1.1@dev
- phil/redirects-bundle: ^0.1.1@dev
- phil/url: ^0.1.4@dev
- psr/clock: ^1.0
- psr/log: ^3.0
- symfony/config: ^8.2
- symfony/dependency-injection: ^8.2
- symfony/http-foundation: ^8.2
- symfony/http-kernel: ^8.2
- symfony/polyfill-php86: ^1.37
- symfony/rate-limiter: ^8.2
Requires (Dev)
- doctrine/doctrine-bundle: ^3.3
- phil/analytics-bundle: ^0.1@dev || ^0.2@dev
- phil/safe-http: ^0.1@dev || ^0.2@dev
- phpunit/phpunit: ^13.4
- psr/cache: ^3.0
- roave/security-advisories: dev-latest
- symfony/browser-kit: ^8.2
- symfony/cache: ^8.2
- symfony/clock: ^8.2
- symfony/css-selector: ^8.2
- symfony/dom-crawler: ^8.2
- symfony/form: ^8.2
- symfony/framework-bundle: ^8.2
- symfony/http-client: ^8.2
- symfony/options-resolver: ^8.2
- symfony/process: ^8.2
- symfony/routing: ^8.2
- symfony/security-bundle: ^8.2
- symfony/security-core: ^8.2
- symfony/security-csrf: ^8.2
- symfony/translation: ^8.2
- symfony/translation-contracts: ^3.6
- symfony/twig-bundle: ^8.2
- twig/twig: ^3.21
Suggests
- phil/analytics-bundle: To count each visit as a server event of the analytics
- phil/safe-http: To read each target before saving it, refusing private networks and targets that do not answer
- symfony/form: For the form of a short link and the administration
- symfony/security-csrf: For the CSRF token of the administration's buttons
- symfony/translation: For the administration in English and French
- twig/twig: For the administration's pages
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-21 03:03:59 UTC
README
Short links for Symfony on dedicated domains: codes in the Sqids format, validity dates, a maximum number of visits, a QR code for each link, and visits of people counted apart from robots and link previews, without any visitor data.
phil/short-link-bundle answers a short domain of its own, such as go.example.com, with one domain per locale when a
site needs it. Each link has a code — drawn at random and written in the Sqids format, or chosen —, a target URL, a
redirect status, and optional terms: a start, an end, a maximum number of visits. A visit is counted in the same
statement that checks the terms, so that two requests racing for the last visit count it once. Robots, prefetches and
the link previews of messaging services are redirected but counted apart: they never use up a maximum. A link no
longer in force answers 410 Gone; a code nobody holds answers 404. The location is written by the resolver of
phil/redirects-bundle, so a short link goes where a redirect would and is checked the same way.
Targets are absolute URLs read by phil/url, limited to the hosts the application lists, never on a short link domain,
and optionally read through phil/safe-http before saving. Creating links is rate limited per author. Nothing of the
visitor is stored: a link keeps its counts and the moment of its last visit — the User-Agent is read to classify a
visit, then dropped —, and the recorders told of a visit — the
server events of phil/analytics-bundle among them — receive identifiers only.
Status
| Part | State |
|---|---|
| Codes in the Sqids format, alphabet and blocklist configurable | Implemented, tested and fuzzed |
| Links, their terms and their Doctrine repository, on SQLite, MySQL and PostgreSQL | Implemented and tested |
Short link domains answered before the routing, 404 and 410 |
Implemented and tested |
| Atomic count of the visits, racing requests included | Implemented and tested on MySQL and PostgreSQL |
| Target checks, rate limit on creation | Implemented and tested |
| The administration, its form, its QR codes in SVG and PNG | Implemented and tested |
| Visits of people and of machines counted apart, the classifier replaceable | Implemented, tested and fuzzed |
| Visit recorders and the analytics recorder | Implemented and tested |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, registering the bundle, the table, the routes, the DNS of a short domain. |
| Configuration | Every option of phil_short_link. |
| Codes | The Sqids format, the alphabet, the blocklist, drawn and chosen codes. |
| Resolution | What a request on a short domain answers, the domains of the locales, the count of visits. |
| Safety and privacy | Targets, open redirects, the rate limit, what is kept and what is not. |
| Administration | The pages, the role, the CSRF token, the layout, the QR codes. |
| Extension points | Recorders, checks, repositories and services an application chooses or replaces. |
| Testing | The tests, the servers they read and the fuzz target. |
| Reference | Every type of the bundle, with its role. |
Quick start
composer require phil/short-link-bundle
# config/packages/phil_short_link.yaml phil_short_link: domains: - { host: go.example.com } - { host: lien.example.fr, locale: fr } home_url: 'https://www.example.com/' targets: allowed_hosts: [www.example.com, www.example.fr]
# config/routes/phil_short_link.yaml phil_short_link_admin: resource: '@PhilShortLinkBundle/config/routes/admin.php' prefix: /admin/short-links
use Phil\ShortLinkBundle\Application\ShortLinkDraft; use Phil\ShortLinkBundle\Application\ShortLinks; $draft = new ShortLinkDraft(); $draft->target = 'https://www.example.com/festival/2027'; $draft->maxVisits = 500; $link = $shortLinks->create($draft, 'user:'.$user->getUserIdentifier()); $shortLinks->url($link); // https://go.example.com/Xk3mQp
Requirements
PHP 8.5 or later, Symfony 8.2 or later, Doctrine ORM 3.7 and DBAL 4.5 or later, and phil/url 0.1.3, which requires
the intl, mbstring and URI extensions. The administration needs Twig, the forms, the translator, the security and its
CSRF tokens; the check of a target needs phil/safe-http; the analytics recorder needs phil/analytics-bundle.
Contributing
Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.
License
MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.