A modern, responsive URL shortener built with plain PHP. LinkForge lets you create short URLs, use custom aliases, set expiration dates, track clicks, and manage everything from a clean dashboard — all without setting up a database.
Name: linkforge-php
Short description: Responsive PHP URL shortener with custom aliases, expiration dates, click analytics, and zero-database setup.
- Create short URLs from long links
- Optional custom alias support
- Optional expiration date for each short link
- Automatic click tracking
- Recent activity panel with IP, referrer, and device info
- Delete links from the dashboard
- Responsive UI for desktop, tablet, and mobile
- CSRF protection on create and delete actions
- JSON-based file storage for quick local setup
- Clean routing with the built-in PHP server
- PHP 8+
- HTML5
- CSS3
- Vanilla JavaScript
- JSON file storage
This is not a single-file beginner demo. It is structured like a real project with controllers, services, repositories, templates, storage, and reusable helpers. It is easy to clone, easy to run, and good for showcasing practical PHP skills on your GitHub profile.
linkforge-php/
├── bootstrap.php
├── router.php
├── config/
│ └── app.php
├── public/
│ ├── index.php
│ └── assets/
│ ├── css/style.css
│ └── js/app.js
├── src/
│ ├── Controllers/
│ │ ├── HomeController.php
│ │ ├── RedirectController.php
│ │ └── DeleteController.php
│ ├── Repositories/
│ │ └── LinkRepository.php
│ ├── Services/
│ │ ├── LinkService.php
│ │ ├── ShortCodeGenerator.php
│ │ └── UrlValidator.php
│ ├── Storage/
│ │ └── JsonStorage.php
│ └── Support/
│ ├── helpers.php
│ ├── Flash.php
│ └── View.php
├── templates/
│ ├── home.php
│ ├── layouts/
│ │ └── app.php
│ └── partials/
│ └── flash.php
├── storage/
│ ├── links.json
│ └── clicks.json
├── LICENSE
└── README.md
- The user enters a long URL.
- The app validates and normalizes the URL.
- A unique short code is generated, or a custom alias is used.
- The record is stored in
storage/links.json. - When the short link is visited, a click log is stored in
storage/clicks.json. - The visitor is redirected to the original URL.
- PHP 8.0 or higher
- No database required
- No Composer packages required
git clone https://github.com/BhartiKuldeep/linkforge-php.git
cd linkforge-phpphp -S localhost:8000 router.phphttp://localhost:8000
- Enter a long URL
- Optionally add a custom alias
- Optionally select an expiration date
- Click Create short URL
Open a generated short URL like:
http://localhost:8000/my-link
The app will track the click and redirect the user to the original URL.
Use the Delete button in the dashboard to remove any saved short link.
This project uses JSON files instead of MySQL so it works immediately after cloning.
storage/links.jsonstores all shortened linksstorage/clicks.jsonstores click history
To reset the app data locally, you can clear those files and replace their contents with:
[]- CSRF token validation is used for form submissions
- Input is validated before saving
- Custom aliases are sanitized before use
- Output is escaped in templates to reduce XSS risk
- User authentication
- Admin dashboard with search and filters
- QR code generation
- REST API for programmatic link creation
- Export analytics as CSV
- Docker setup
- MySQL version for production-style deployment
- Password-protected short links
This project is licensed under the MIT License.