This PHP Slim application will create a URL shortener that allows anyone to input a long URL and receive a generated URL that is domain.io/i/uniqueCode
(assuming domain.io
is your domain of course).
The application requires you to install some stuff first. Since this application is GPLv3, the dependencies cannot be shipped with this application. You must "acquire them" on your own, by using the installer.
This application requires:
apache
orhttpd
(either2.2.x
or2.4.x
)php
(minimumv5.6
, recommendedv7.0
)mysql
(viamysql-client
) (minimum5.1.x
recommended5.5.x
)php5-mcrypt
orphp7-mcrypt
You must also have access to the following:
- A command line interface with
bash
capabilities (sudo
orroot
is not required) - A LAMP stack (macOS = MAMP, Windows = WAMP)
- MySQL administrative privileges
-
Install composer
-
The application installs composer by downloading
https://getcomposer.org/installer
tosetup-composer.php
. -
PHP executes
setup-composer.php
which checks dependencies and downloads a file calledcomposer.phar
-
-
Compose Packages Are Installed
- The installer reads the
composer.json
file and downloads each of the dependencies into thevendor/
directory
- The installer reads the
-
The installer generates the configuration
-
A randomly generated password using PHP7's
random_bytes()
function (orrandom_compact
for PHP 5.6+) -
A domain is required - enter the name of your shortened domain, for dev, use something like:
myshort.local
-
You will need to specify the
database host
,database name
,database username
anddatabase password
. -
Saving the configuration:
iv.1. If the installer is able to access the MySQL server, the host, database, username, and password are encrypted with the randomly generated password (from 3.i) and stored as a
base64
hash inside theconfig.inc.php
file.iv.2. If the installer cannot access then the installation script will keep prompting for a combination that works.
-
SQL table/database installation
v.1. If the installer is able to create the database, it will attempt to install the necessary tables
v.2. If the installer is unable to create the database, it will generate a file called
install-url-shortener.sql
v.3. If
install-url-shortener.sql
is created, you must, with a privileged mysql user run the following commandmysql -u root -p < install-url-shortener.sql
-
This software is provided "as-is" and comes with absolutely no warranty or guarantee. Please use at your own discretion. No contributor to this project shall be responsible for any issues caused as a result of executing this software. That being said, the software is fully open-source, so have at it... look it over, understand it, and determine on your own merits whether or not you should use it.