
Prerequisites
Before setting up your Laravel project, ensure the following tools are installed on your system:
1. Git
Git is a version control system used to track changes in your source code.
-
Download: https://git-scm.com/
-
Check installation:
git --version
2. PHP (v7.3 or higher)
Laravel requires PHP 7.3+.
-
📦 Check installation:
php -v
3. Composer
Composer is the dependency manager used by Laravel.
-
Download: https://getcomposer.org/
-
Check installation:
composer --version
4. Web Server
Laravel includes a built-in development server, but for production, use Apache or Nginx.
5. Database
Ensure you have a supported database system installed, such as MySQL, PostgreSQL, or SQLite.
6. Postman
Postman is useful for testing APIs.
-
Download: https://postman.com/
Steps to Clone and Set Up the Laravel Project
1. Clone the Repository
Open a terminal and run:
git clone https://github.com/StarCodeKh/Laravel-11-Back-End-API.git
2. Navigate to the Project Directory
cd Laravel-11-Back-End-API
3. Install Dependencies
composer install
4. Set Up Environment File
cp .env.example .env
Edit the .env
file to configure your database and app settings.
5. Generate Application Key
php artisan key:generate
6. Set Up OAuth Keys for Laravel Passport
Ensure these lines exist in your .env
file:
PASSPORT_PRIVATE_KEY=path/to/private.key PASSPORT_PUBLIC_KEY=path/to/public.key
If you haven't generated the keys, run:
php artisan passport:install
7. Configure Database in .env
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_db DB_USERNAME=root DB_PASSWORD=your_password
8. Run Database Migrations
php artisan migrate
9. Create Personal Access Client (Optional)
php artisan passport:client --personal
10. Start the Laravel Development Server
php artisan serve
Your application will be accessible at:
👉 http://localhost:8000