Getting started with Laravel

How to create a Laravel Project
For beginners who would like to get started with Laravel, i’ll provide the most crucial snippets of code that you will encounter in this amazing framework

Prerequisites

PHP: Laravel requires PHP 8.0 or later.
Composer…


This content originally appeared on DEV Community and was authored by Brian

How to create a Laravel Project
For beginners who would like to get started with Laravel, i'll provide the most crucial snippets of code that you will encounter in this amazing framework

Prerequisites

  1. PHP: Laravel requires PHP 8.0 or later.

  2. Composer: This is a dependency manager for PHP

  3. Web server: Apache, Nginx, or Laravel's built-in-server

Start your XAMPP web server since this will be required for the database

Creatae a new project using composer directly. Replace project-name with the desired name

composer create-project --prefer-dist laravel/laravel project-name


cd project-name

cd project-name

Serve the Application

php artisan serve

This command will start the development server at 'http://localhost:8000'.

Configure your environemnt

Laravel uses a '.env file for environmental configuaration. Open the '.env' file in the root of your project and configure your database and other settings

As for the latest installation it comes with sqlite by default but i prefer using mysql so we are going to change that

This is what it looks like by default

DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

change it to, make sure to uncomment the commented parts

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel-dev-database
DB_USERNAME=root
DB_PASSWORD=


Run migrations
Laravel uses migrations to create database tables. Run the migration with

php artisan migrate

Laravel uses MVC (Model, View, Controller) Architecture
We are going to discuss this in a moment

Congratulations, you have successfully created your first Laravel application.


This content originally appeared on DEV Community and was authored by Brian


Print Share Comment Cite Upload Translate Updates
APA

Brian | Sciencx (2024-07-12T21:09:10+00:00) Getting started with Laravel. Retrieved from https://www.scien.cx/2024/07/12/getting-started-with-laravel/

MLA
" » Getting started with Laravel." Brian | Sciencx - Friday July 12, 2024, https://www.scien.cx/2024/07/12/getting-started-with-laravel/
HARVARD
Brian | Sciencx Friday July 12, 2024 » Getting started with Laravel., viewed ,<https://www.scien.cx/2024/07/12/getting-started-with-laravel/>
VANCOUVER
Brian | Sciencx - » Getting started with Laravel. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/12/getting-started-with-laravel/
CHICAGO
" » Getting started with Laravel." Brian | Sciencx - Accessed . https://www.scien.cx/2024/07/12/getting-started-with-laravel/
IEEE
" » Getting started with Laravel." Brian | Sciencx [Online]. Available: https://www.scien.cx/2024/07/12/getting-started-with-laravel/. [Accessed: ]
rf:citation
» Getting started with Laravel | Brian | Sciencx | https://www.scien.cx/2024/07/12/getting-started-with-laravel/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.