Laravel new installation
Here's a step-by-step guide to installing Laravel:
Prerequisites
- PHP 7.2.5 or higher
- Composer (the PHP package manager)
- A code editor or IDE (e.g., Visual Studio Code, Sublime Text, etc.)
Step 1: Install Composer
If you haven't already, download and install Composer from the official website: https://getcomposer.org/
Step 2: Create a new Laravel project
Open your terminal or command prompt and run the following command:
composer create-project --prefer-dist laravel/laravel project-name
Replace project-name
with the desired name for your Laravel project.
Step 3: Change into the project directory
Navigate into the newly created project directory:
cd project-name
Step 4: Install dependencies
Run the following command to install Laravel's dependencies:
composer install
This may take a few minutes, depending on your internet connection and the speed of your computer.
Step 5: Configure the environment
Create a new file called .env
in the root of your project directory. This file will store your environment variables. You can copy the contents of the .env.example
file provided by Laravel and update the values as needed.
Step 6: Generate an application key
Run the following command to generate an application key:
php artisan key:generate
This will generate a random key for your Laravel application.
Step 7: Set up the database
Create a new database for your Laravel application. You can use a database management system like MySQL, PostgreSQL, or SQLite.
Update the .env
file with your database credentials:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password
Step 8: Run the migrations
Run the following command to run the database migrations:
php artisan migrate
This will create the necessary tables in your database.
Step 9: Start the development server
Run the following command to start the development server:
php artisan serve
This will start a development server at http://localhost:8000
. You can access your Laravel application by navigating to this URL in your web browser.
That's it! You now have a brand new Laravel installation up and running.