Create Laravel 10 project from scratch

  • avatar
  • 7.5K Views
  • 2 Likes
  • 5 mins read

Laravel is an open-source PHP web application framework designed for building web applications following the Model-View-Controller (MVC) architectural pattern. It was created in 2011 and become one of the most popular PHP frameworks used for web development.

Laravel provides developers with a number of powerful features and tools, including a simple and expressive syntax, built-in database migration and schema management, automated testing, and a robust ecosystem of third-party packages. Some of the key features of Laravel include its powerful routing engine, which allows developers to easily define application routes using a simple and intuitive syntax, and its comprehensive ORM (Object-Relational Mapping) system, which makes working with databases and models a breeze.

Laravel also includes a templating engine called Blade, which makes it easy to create dynamic, reusable views for your application, and a built-in authentication system for managing user authentication and authorization.

Prerequisites

Laravel utilizes Composer to manage its dependencies. Take a look on how to install Composer 2 on your computer.

Installation

Assuming that Composer is already installed on your computer, you can generate a fresh Laravel project directly using Composer. Upon execution, this command will create a new project within a directory named my_project in the current location and install any necessary dependencies:

composer create-project laravel/laravel my_project

Configuring Laravel

Initial configuration must be performed in order to run Laravel.

Directory Permissions

You may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run.

Environment variables

Environment variables are used to store sensitive data such as passwords, credentials and other information that should not be written directly in code. Environment variables must be used to configure variables or configuration details that may differ between environments. Laravel provides an example of how should initial environment file look like in .env document. It should be modified based on your needs and configuration.

Encryption key

When you install Laravel, an application key is automatically generated for your project. This key is a random string that is used to safeguard your user sessions and encrypt data. To generate a new key, you can execute the following command:

php artisan key:generate

The command sets the APP_KEY value in your .env file. It is important to note that if the encryption key needs to be regenerated after an application has been in use, any data that was previously encrypted using the old key cannot be decrypted using the new encryption key.

Using Laravel

Once you have configured the application, you can initiate Laravel's local development server. To do this, navigate to the project directory and use the following artisan command to start up the server:

php artisan serve

We will see that our terminal will be blocked by the process and will show us the URL to access the APP from any browser installed on our computer. Usually it will be something similar to http://127.0.0.1:8000

Laravel Artisan serve

To unlock the terminal and stop the execution use the Ctrl+C combination on our keyboard.

 Join Our Monthly Newsletter

Get the latest news and popular articles to your inbox every month

We never send SPAM nor unsolicited emails

0 Comments

Leave a Reply

Your email address will not be published.

Replying to the message: View original

Hey visitor! Unlock access to featured articles, remove ads and much more - it's free.