A simple-as-hell URL shortener.
PHP
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
services
sql
vendor/Silex
web
.gitignore
README.md

README.md

shorten

shorten is a simple-as-hell URL shortener, and because shorten is supposed to be as simple as possible...

  • There is no ability to supply a custom short code.
  • There is no attempt to gather metrics of any kind.
  • There is no (real) web interface provided; shorten is intended to be used from a command line or via the HTTP API.

Installation

To install shorten, follow these steps (these steps are for Apache):

  1. Create the database, naming it whatever you want.
  2. Load the schema.sql into the created database.
  3. Drop the shorten codebase into your web server's DocumentRoot.
  4. Copy the config/config.php.template file to config/config.php.
  5. Change the values in config.php to match your setup.
  6. Restart your web server, and that's it.

Basic Command Line Usage

  $> curl http://shorten.dev/ -F "url=http://example.com/"
  http://shorten.dev/1

After generating that short url, loading http://shorten.dev/1 in your web browser will redirect the user to http://example.com.

Basic PHP cURL Example

<?php
$data = array('url' => 'http://example.com/');

$ch = curl_init();
curl_setopt_array($ch, array(
  CURLOPT_URL            => 'http://shorten.dev/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST           => true,
  CURLOPT_POSTFIELDS     => $data,
));
$short_url = curl_exec($ch);
curl_close($ch);

echo "Shortened URL: $short_url\n";