Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xsavitar/url-shortener
This is a URL shortener application built using PHP and MySQL database MS.
https://github.com/xsavitar/url-shortener
ajax ajax-request css3 html5 javascript mysqli php php56 url-shortener
Last synced: 3 months ago
JSON representation
This is a URL shortener application built using PHP and MySQL database MS.
- Host: GitHub
- URL: https://github.com/xsavitar/url-shortener
- Owner: xSavitar
- License: mit
- Archived: true
- Created: 2016-08-14T12:03:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-05T07:45:43.000Z (about 6 years ago)
- Last Synced: 2024-09-28T19:23:08.839Z (3 months ago)
- Topics: ajax, ajax-request, css3, html5, javascript, mysqli, php, php56, url-shortener
- Language: PHP
- Homepage: https://tools.wmflabs.org/durl-shortener/shortener.php
- Size: 234 KB
- Stars: 8
- Watchers: 3
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# URL Shortener app with PHP + MySQL / MariaDB
A mini/micro project meant for URL shortening using PHP & MySQL as DBMS.
# Setting up project locally / production
## Clone the repository;
NOTE: Make sure to navigate to your web-server directory (for example `/var/www/html` for Ubuntu OS)
```shell
git clone https://github.com/ch3nkula/url-shortener.git
```## Install dependencies for the project;
```shell
composer update
```NOTE: You must have `composer` installed for this to work. To install `composer`, check [the official website](https://getcomposer.org/download/).
## Setup database & it's credentials;
1. Import the `urls.sql` database schema to your database (with name `url_shortener`). You can import using phpMyAdmin or Command-Line for MySQL. Once you import this schema, move straight to setting up credentials.
2. Duplicate the file called `.env.example` and rename the duplicate copy to `.env`
```shell
cp .env.example .env
```3. In the `.env` file, there are two sections, one for local config and the other for production configs. Fill the section for local configs for example;
```
LOCAL_DB_HOST=
LOCAL_DB_USER=
LOCAL_DB_PASSWORD=
LOCAL_DB_NAME=
```## Run / Test the application locally
Once you are done with the steps above, try to run and test the application using PHP's in-built server.
1. Run the application by typing and executing the command below;
```shell
php -S localhost:3000
```NOTE: It's important to use port `3000` as it's used in the application.
2. Move over to your favorite browser, mine is `Google Chrome` or `Safari` and test the application by typing in the address bar; `https://localhost:3000`.
If things work as expected, then you should see this on your browser
![alt text](assets/running-application.png)
## Final Step
If you see the above image, then you are almost there, try pasting a long URL in the form field and see if the app generates a short URL (see image below). If you get a short URL, then it work well. Enjoy!
![alt text](assets/shortening-url.png)
## License
MIT License