A simple URL shortener. A user provides a location, we generate a unique key and provide a URL containing the key which redirects to the location. A user can view statistics covering the usage of their short URL.
Requires PHP 7.3. Download project (as a zip, or via git clone
) then run:
$ composer launch
This process will install all dependencies, migrate the database, compile assets and launch the Laravel development server. Visit 127.0.0.1:8000 once launched.
There is a test suite covering (some) core functionality.
$ vendor/bin/phpunit
- SQLite datastore
-
id
integer -
key
string -
location
string -
created_at
timestamp -
updated_at
timestamp
-
link_id
integer, foreign key on Link -
visitor_hash
string -
created_at
timestamp -
updated_at
timestamp
- A user should be able to shorten a URL
- A shortened URL should redirect to the target URL
- A user should be able to see service statistics
- A user should be able to see a shortened URL's visit statistics
- Visit statistics should be tested for uniqueness based on IP address (without storing IP addresses)
- Unique visits (all links, a link)
- Total links created
- Total visits
- Total unique visits
GET /
- Display global statistics about the service
- Display a form that accepts a URL to shorten
POST /
- Validate the URL
- Generate a unique short key
- Redirect to meta page for shortened URL
GET /~{key}
- Display the shortened URL
- Display click statistics
GET /{key}
- Create a visit with one-way hash of the visitors IP address
- One-way hash should be unique to a single URL
- Redirect to the shortened URL using a 302