How to create larave...

How to create laravel project with composer in terminal.

Published May 10, 2024

Last Updated: October 07, 2024

Laravel is a powerful PHP web application framework with elegant syntax. It simplifies tasks like routing, authentication, and caching. Designed for developers, Laravel promotes clean code and rapid development. With features like Eloquent ORM and Blade templating, it provides a robust foundation for building modern, scalable, and secure web applications.

In this tutorial you will learn how we create a laravel project by command panel or terminal. To be a professional programmer, you should know the using of terminal. To setup a Laravel project via terminal, please make sure you have installed PHP and Composer in your system before starting. Here’s how you can create a basic Laravel project:

  • Step 1: Install Laravel

    Open your command-line interface (e.g., Terminal on macOS, Command Prompt on Windows). Navigate to the directory where you want to create your Laravel project. Run the following command to create a new Laravel project: composer create-project --prefer-dist laravel/laravel your-project-name Here you need to replace your-project-name with the name you want for your Laravel project.

  • Step 2: Configure Your Environment

    After the installation is complete, navigate into your project directory: cd your-project-name Create a copy of the .env.example file and rename it .env cp .env.example .env Generate an application key by entering command php artisan key:generate

  • Step 3: Set Up the Database

    Open the .env file in a text editor and configure your database connection settings. You need to set the DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD. Run database migrations to create the necessary database tables: php artisan migrate

  • Step 4: Start the Development Server

    You can start a development server by running: php artisan serve. This will start a local development server at http://localhost:8000

  • Step 5: Create Your First Route and View

    Open the : routes/wep.php file and define a route that points to a controller or a view. For example, you can create a route that returns a basic welcome view:

    Route::get('/', function () {
        return view('welcome');
    });
    
    Create a corresponding Blade view file in the resources/views directory. In this case, you can create a welcome.blade.php file. Access your Laravel application in your web browser at http:://localhost:8000. You should see the "Welcome to Laravel" page.

Congratulations! You’ve just created your first Laravel project. You can continue to build your application by defining routes, creating controllers, and adding functionality as needed. Laravel’s documentation is a valuable resource for learning more about its features and capabilities: Laravel Documentation

Avatar of shahidul

Author

Hire Me
Md Shahidul Islam
Full-Stack Software Developer
As a full-stack developer, I've been working for over 5 years. I am from Bangladesh and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, WordPress, Vue, Javascript, Tailwind CSS and Bootstrap from the early stage. I believe in Hardworking and Consistency.

Follow me:

Recent Blogs

Maybe you will benefit to know

Why SEO is very important for your website?
Why SEO is very important for your website?
Read More
The Importance of a Portfolio Website
The Importance of a Portfolio Website
Read More
The Benefits and Uses of a Queue Management System to any business
The Benefits and Uses of a Queue Management System to any business
Read More