Laravel Project Structure Explained

When you create a Laravel project or application, you’ll see there’s a lot of folders and files in it. You might be confused as to what each folders are for, which folders should be modified or left as is. Well, let’s dive into that together.

Note : the version I’m using and explaining is Laravel 9, but all versions have similar or the same structure. If you are interested in reading from the official documentation, you can find it here. If you don’t know how to set up a Laravel project, you can learn here.

Before we dive into the folders, you’ll notice there are several files in the root folder. They are mostly auto generated and auto updated file that you don’t have to modify. There might one file that catches your eye because it matches the name of the dependency manage we use, which is composer.json. It shows you the general information of your Laravel installation including its packages and it is auto updated.

One file that you need to modify in the root folder is .env. It contains the information of your project which includes your project name, project URL, database name, etc. It is important for both development and hosting.

.env

Now, these are the folders that are in the project :

  • app
  • bootstrap
  • config
  • database
  • lang
  • public
  • resources
  • routes
  • storage
  • tests
  • vendor

app

The app folder contains the logic of your project or application. There are ready to be used functionalities that use can use to make it easier to develop your application, which is the main purpose of Laravel. The functionalities include Console, Exceptions, Controllers, Middleware, Models and Providers. They are basically classes and function that are already provided so you don’t need to code them for scratch.

bootstrap

The bootstrap folder contains the application instance which is app.php and also the caching of your application. Not to confuse the name of the folder with the bootstrap framework, bootstrap here basically means to process Laravel takes to combine the application together. You don’t need to modify any files in this folder.

config

The config folder contains the various configurations of your application. You occasionally need to modify the content as you register new or custom functionalities to your application.

database

The database folder contains all things you can do to your database. You can use migration to create or modify your database and you can use factory or seeder to fill your database.

lang

The lang folder is where the language of your application is stored. You can use different language for your application if you don’t want it to be in the default language which is in English.

public

The public folder is where your index.php is. As you know, when a website is hosted, it always looks for index.php or index.html as the primary file to be executed. This is where your application will be run. It will be modified beheind the screen and combined with all your Laravel codes. This is also where you put your assets like images, CSS and JS files.

resources

The resources folder contains your views which will be used to display your web.

routes

The routes folder manages the routing of your application. You can determine the routes of your web or even API here.

storage

The storage folder contains compiled files made by Laravel and also user generated content which is dynamic. You can also store images which is connected with database here.

tests

The tests folder is where you write your automated testing scripts.

vendor

The vendor folder contains your installed third party libraries or packages which you install via Composer.

Summary

That was a brief overview of what the Laravel folders are. It is certainly not enough to fully understand Laravel but it is important to know so you can modify it later on. You can open each of the folders and files to see what they contain for yourself to understand it better.

For you next reading on Laravel topics, I recommend Laravel Migrate Fresh And Refresh Difference.

Now that you understand more about Laravel, if you’re looking for where to host your Laravel App, I recommend Cloudways. It is compatible, fast, reliable and has a specific option for Laravel. There are also tons of resources about Laravel hosting on Cloudways. Go ahead and check it out!

If you’re looking to refresh your PHP skill, you can try Codecademy’s free PHP course. Go ahead and check out the syllabus to see if it fits you. If you’re interested, go and try it for free!

Now, go explore!

Leave a Comment