Requirements:
- PHP 7.4 or above
- composer
- node / npm
clone the project from the Github repository, enter the project folder, open a terminal inside the project folder and run:
composer install
npm install
npm run dev
You need to create your .env file; inside the project folder run the following command:
cp .env.example .env
then setup your db schema and db credentials into the .env file and create the database using your favorite method (phpMyAdmin, MySQL Workbench, etc).
After that you need to create the database tables and populate them with data by running:
php artisan migrate --seed
A default user is created with the following credentials:
User: admin
Email: [email protected]
Pasword: password
This will create a short url that points to the provided real url, you need to send a POST request with a json body as follows:
{
"url" : "your-real-url-here"
}
if succeed, the request will respond with a json body as follows:
{
"data": {
"short_url": "generated-short-url-here"
}
}
This will return a Json array with the top 100 most visited Urls, you need to send a GET request
This will return the real Url that the provided short url points to, you need to send a GET request with your short url as a parameter on the url api call as follows:
{your-domain}/api/v1/url/real?url={your-short-url}
if succeed, the request will return a json body as follows:
{
"real_url" : "your-real-url-here"
}
In this project I show how to work with:
- Creating an API
- Fetching an API
- Livewire components
- Livewire modals
- To have separate and related tables since the same real URL could have several short URLs associated with it. This would also help in scalability of the application and in integration with other systems.
- Create a token-based authentication for the API; this way, requests to the API could be limited in a free subscription model and have another paid subscription model with unlimited requests.
- Create a pagination for the Top 100 URLs view.