katmore/shrturl

a URL shortener webservice

v1.0.2 2016-12-13 21:17 UTC

This package is not auto-updated.

Last update: 2024-12-21 21:19:44 UTC


README

a URL shortener webservice

Shrturl is a RESTful web service that behaves similar to enterprise level URL shortening services (such as bit.ly).

Terminology

  • code or short code: the unique portion (token) contained in a short URL that serves as reference to full URL. The typically jibberish looking sequence of alpha numeric characters used in most URL shorteners.
  • short url: the full URL that includes the short code (ie: http://example.com/shrt.php?code=abc)
  • target url: the full URL that needs to be changed into a short URL

Installation

  1. extract/copy the shrturl project somewhere
git clone https://github.com/katmore/shrturl.git
cd shrturl
  1. create autoloader and resolve dependencies using Composer...
composer update
  1. run the db-install.php script...
php bin/db-install.php
  1. copy app/config/shrturl/mysql-sample.ini to mysql.ini and edit...
cp app/config/shrturl/mysql-sample.ini app/config/shrturl/mysql.ini
vi app/config/shrturl/mysql.ini
  1. populate the database with initial set of randomly generated short codes...
php bin/make-codes.php 1000

Webservice Usage

Webservice Deployment Suggestions

  • use 2 different FQDNs (fully qualified domain names) for this service

    • FQDN #1 for 'end use' the short code, such as:

    http://rlysh.rt

    • FQDN #2 for API calls to short code service, such as:

    https://shrturl.example.com

  • for example:

    1. on the 'end use FQDN' (#1)
      1. install/configure project as described in installation section of this document
      2. configure a url_base in addition to the 'default'

      see url_base section in shrt-config-example.php

    • contains example of .htaccess or equivelent configuration for web server
    • http://rlysh.rt/abc will work now
    • where 'abc' is the short code provided by previous call to short API
    1. on the 'API FQDN' (#2) use as described in usage section

    in API requests to obtain a short code ensure that: provide a url_base parameter in query that corresponds to the 'end use' that is set in your shrt-config-example.php

Legal

Copyright

Flat webapp - https://github.com/katmore/flat-webapp

Copyright (c) 2012-2017 Doug Bird. All Rights Reserved.

License

"shrturl" is copyrighted free software.

You can redistribute it and/or modify it under either the terms and conditions of the "The MIT License (MIT)"; or the terms and conditions of the "GPL v3 License".