Laravel: Installation and Directory Structure

Let’s see how can we install or setup a Laravel application. And what files and directories do we get after the installation is complete.

Installation

There are multiple ways to created and install Laravel application. We are discussing 2 ways-

  1. Directly, using composer.
  2. Dockerizing Laravel application.

WARNING

We are using Composer to create Laravel project and manage dependencies. So, make sure you have Composer installed on your machine.

Create a Laravel application named “bigboxapp“, using Composer. use the following command.

composer create-project laravel/laravel bigboxapp
Bash

That’s it. There will be a directory named “bigboxapp” where you executed the command and in teh directory Laravel files and directories will be created.

You can navigate to the “bigboxapp” directory and start playing with the application. Run the following command to run the application-

# Make sure you are inside the application directory
# In our case, it is 'bigboxcode'

php artisan serve
Bash

You can access the application on “http://localhost:8000”, as 8000 is the default port when we run it from CLI.

NOTE

To Dockerize a Laravel application use the following tutorial. We have discussed the process of Dockerizing of Laravel app there, step-by-step.

Directory Structure

Just after creating a new Laravel project, you will see a directory structure like below-

Laravel Application
    |
    ├── app
    │   ├── Http
    │   │   |── Controllers
    │   │       |── Controller.php
    │   ├── Models
    │   │   |── User.php
    │   |── Providers
    │       |── AppServiceProvider.php
    |
    ├── artisan
    |
    ├── bootstrap
    │   ├── app.php
    │   ├── cache
    │   │   ├── packages.php
    │   │   |── services.php
    │   |── providers.php
    |
    ├── config
    │   ├── app.php
    │   ├── auth.php
    │   ├── cache.php
    │   ├── database.php
    │   ├── filesystems.php
    │   ├── logging.php
    │   ├── mail.php
    │   ├── queue.php
    │   ├── services.php
    │   |── session.php
    |
    ├── database
    │   ├── factories
    │   │   |── UserFactory.php
    │   ├── migrations
    │   │   ├── 0001_01_01_000000_some_migration.php
    │   |── seeders
    │       |── DatabaseSeeder.php
    |
    ├── public
    │   ├── favicon.ico
    │   ├── index.php
    │   |── robots.txt
    |
    ├── resources
    │   ├── css
    │   │   |── app.css
    │   ├── js
    │   │   ├── app.js
    │   │   |── bootstrap.js
    │   |── views
    │       |── welcome.blade.php
    |
    ├── routes
    │   ├── console.php
    │   |── web.php
    |
    ├── storage
    │   ├── app
    │   │   ├── private
    │   │   |── public
    │   ├── framework
    │   │   ├── cache
    │   │   │   |── data
    │   │   ├── sessions
    │   │   ├── testing
    │   │   |── views
    │   |── logs
    |
    ├── tests
    │   ├── Feature
    │   │   |── ExampleTest.php
    │   ├── TestCase.php
    │   |── Unit
    │       |── ExampleTest.php
    |
    ├── composer.json
    ├── composer.lock
    ├── package.json
    ├── phpunit.xml
    |── vite.config.js
Plaintext

Let’s see what is the purpose of each directory, and which of our files should go into which directory.

Leave a Comment


The reCAPTCHA verification period has expired. Please reload the page.