soleo / url-shortener
Make the URLs shorter
dev-master / 1.0.x-dev
2016-03-21 21:44 UTC
Requires
- php: ~5.5|~7.0
- mongodb/mongodb: ^1.0.0
Requires (Dev)
- heroku/heroku-buildpack-php: ^97.0
- mockery/mockery: ^0.9.4
- phpunit/phpunit: 4.*
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is not auto-updated.
Last update: 2025-01-16 02:29:33 UTC
README
A Simple, Self-Hosted URL Shortener with MongoDB.
Install
Via Composer
$ composer require soleo/url-shortener
Usage
use Soleo\UrlShortener\MongoConnection; use Soleo\UrlShortener\Shorty; require "vendor/autoload.php"; $mongoURI = "mongodb://demo:demodemo@ds045757.mlab.com:45757/url_shortener"; $mongoConn = new MongoConnection($mongoURI); $shorty = new Shorty($mongoConn); if (isset($_GET['longurl'])) { echo $shorty->getShortUrl($_GET['longurl']); exit; } // Get Long URL $slug = preg_replace('[^A-Za-z0-9]', '', $_SERVER['REQUEST_URI']); $longURL = $shorty->getLongUrl($slug, true); header("Location: ".$longURL, true, 302); exit;
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email shaoxinjiang@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.