ricwein / shurl
PHP based URL shortener
Requires
- php: >= 7.0.0
- hashids/hashids: ^2.1@dev
- klein/klein: dev-master
- leafo/scssphp: dev-master
- monolog/monolog: ^2.0@dev
- phpfastcache/phpfastcache: ^6.0
- symfony/console: 3.4.x-dev
- symfony/yaml: ^3.2
- usmanhalalit/pixie: ^2.0
Requires (Dev)
- phpunit/phpunit: ^6.4@dev
This package is auto-updated.
Last update: 2023-09-29 01:52:38 UTC
README
Another PHP based URL shortener.
Install
project
To create a new shurl instance, the project can be initialized through composer, just run the following command:
composer create-project ricwein/shurl -s dev
Database
Initializing the Database structure can be done two ways. Either run the static queries from resources/database/database.sql, or use the init
commandline tool.
This tool requires you, to first setup your wished database configuration! This can be done, as described in Configuration. A valid Database-user is required, and needs either: the database to be already existing, or rights to create a new one.
bin/shurl init
Since this tool, acknowledges your database-configuration, the resulting database-structure is customizable! use table-prefixes, custom charsets, or even another database name!
Configuration
The default configuration is stored in src/Config/Config.php $__config
Array, but can be overwritten by adding a config-file at config/config.yml
.
It should has the following format:
--- database: username: usernamehere prefix: shurl_ cache: enabled: true
This way it's possible, to override each single setting.
You can copy an example file to start with
cp config/example.config.yml config/config.yml
rootURL
For some features, shurl need to know your webservers Domain and Path to shurl. This URL can be set inside the described configfile:
--- rootURL: https://fancy.url
Adding a new URL
Adding a new URL to the shortener Server is done with the bundled CLI tool. Just run bin/shurl url:add
, and follow the instructions.
For more Informations see bin/shurl url:add --help
.
Remove an URL
Removing an URL from the list, is as easy as adding one. Execute bin/shurl url:remove
from your command line should do the job.
List available URLs
A list of all currently available URls can be accessed through: bin/shurl url:show
Routes
There are several different routes, which are supported by shurl.
- / The root displays a welcome message
- /{slug} redirects to a given url
- /preview/{slug} shows a resolved-URL preview
- /api/{slug} exposes a simple JSON api (
GET
Method), which provides access to the resolved URL
[{ "slug": "shurl", "original": "https:\/\/s.ricwein.com" }]