Skip to content

Putr/api-shortener

Repository files navigation

Simple URL shortener API

This is a simple, self-hosted url shortener with no GUI, just an API & one YAML config file.

API documentation

If you really need a GUI, there is one but only for testing/stopgap/personal purposes.

Features

  • Multiple domains per install
  • Per domain create/delete access controll
  • Append GET paramateres to resolved URLs (configured per domain)
  • Can log short url hits to log file
  • Counts number of hits, grouped by days

Dependencies

  • Redis
  • Nginx
  • PHP 5.5+
  • Composer

Install dependencies

Redis

If using in production, make sure to secure the install correctly!

Download an install from official page

Composer

Official page

Deploy

Run Composer

composer install

Setup permissions

sudo chown [USER]:www-data log/ -R
sudo chmod 775 log -R

Configure nginx

Copy the distribution file to create a local version

cp  etc/nginx.confg.dist etc/nginx.conf

Configure it to your needs (specifically 'server_name' and path to php socket)

Restart nginx after you are done.

Configure

If deploying a development install copy the dev version:

cp config.yml.dist.dev config.yml

For production use:

cp config.yml.dist.prod config.yml

Add your own access codes and domains.

IMPORTANT: Access codes in the file must be sha1 hashed!

Note: If you change the config after you are already using the system you must purge the cache in reddis with:

php console/clear_config.php

That's it!

Development

For testing I'm using Codeception.

After installing run tests with:

codecept run --steps

Deployment

Deployment is done with Deployer.

Copy config file and configure

cp deploy.php.dist deploy.php
nano deploy.php

run with

dep deploy production

Releases

No releases published

Packages

No packages published

Languages