This project implements a URL shortening service. Users can shorten their long URLs and be redirected to the original URL when they click the shortened link. It is built using the Laravel framework.
Turkish_ReadMe: link
- Users can shorten long URLs.
- The shortened URL is displayed to the user and redirects correctly.
- URLs are stored in a database, and a unique code is generated for each shortened URL.
To run this project, follow the instructions below.
- PHP (Version 8.x or higher)
- Composer (Dependency manager for PHP)
- MySQL (For the database)
- Laravel (Framework)
- Git (To clone the project)
First, clone this repository from GitHub:
git clone https://github.com/ahmetcotul/url-shortener.git
cd url-shortener
Use Composer to install the required dependencies for the project:
composer install
Open the .env file and configure the database settings:
-
If you are using MySQL, set up the database configuration as follows:
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=url_shortener DB_USERNAME=root DB_PASSWORD=secret
-
If you prefer SQLite, change DB_CONNECTION=sqlite and set the DB_DATABASE path appropriately:
DB_CONNECTION=sqlite DB_DATABASE=/path/to/database/database.sqlite
Create the necessary database tables using the following command:
php artisan migrate
This command will set up the required database structure.
Run the following command to start the Laravel application:
php artisan serve
This will serve the project at http://localhost:8000.
If you encounter issues, you can also try the alternative commands below:
# Run this in one terminal:
php -S localhost:8000 -t public/
# In another terminal, run:
composer run dev
Open http://localhost:8000 in your browser. Enter a long URL, click the Shorten button, and your shortened URL will be displayed. Test the shortened URL by clicking it to confirm redirection to the original URL.
To contribute to this project, follow these steps:
- Fork the repository.
- Create a new branch:
git checkout -b new-feature
. - Make your changes and commit them:
git commit -am 'Added a new feature'
. - Push your changes:
git push origin new-feature
. - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for more details.
Note: Ensure that PHP 8.x and Composer are installed on your system. Additionally, make sure the MySQL or SQLite database setup is configured correctly.