Laravel-1 Project Setup and Structure

Kaidong Wu
Apr 9 · 3 min read

Install PHP stack

First check your computer whether have any PHP stack installed (MAMP), if we got any of those installed then we already have PHP in the system. If not, head to the website and download the dist package.

Install Composer

Download the dependencies manager composer at, During the installation, set the php path where you installed the php at last step (or go to MAMP\bin\php\php[version]\php.exe).

Create New Laravel Project

Create a new directory anywhere in your system for your new Laravel project. After that, move to path where you have created the new directory and type the following command there to install Laravel.

composer create-project laravel/laravel [your project folder name] –-prefer-dist

The above command will install Laravel in the current directory. Start the Laravel service by executing the following command.

php artisan serve

Laravel Project Setup from Git

For those Laravel project in the collaboration team, you will already have you project folder in your computer, but that doesn’t mean you can start serving your website right away, these are the steps you need to perform:

  • Install all the dependencies of your Laravel project
composer install/update
  • Create your own .env file, the .env would be ignore by git as the .env would be specific for different database configuration.

After performing these two steps, your Laravel project would be good to go

Laravel project architecture

The app folder mainly contains the cold of our application.

  • Under the app folder
    All the Eloquent model we creates all go under the app folder
  • Under the console folder
    The Console directory contains all of the custom Artisan commands for your application. These commands may be generated using the make:command command.
  • Under exceptions folder
    The Exceptions directory contains your application’s exception handler and is also a good place to place any exceptions thrown by your application. If you would like to customize how your exceptions are logged or rendered, you should modify the Handler class in this directory.
  • Under Http folder
    The Http directory contains your controllers, middleware, and form requests. Almost all of the logic to handle requests entering your application will be placed in this directory.
  • The controller folder: place all the controllers in this folder
  • The resources folder: place all the resources in this folder
  • The middleware folder: place all the deployed middleware in this folder

All the configuration can be found in this folder

Contains all the migration files and seeders files in this folder

The public directory contains the index.php file, which is the entry point for all requests entering your application and configures autoloading. This directory also houses your assets such as images, JavaScript, and CSS.

The resources directory contains your views (html, blade) as well as your raw, un-compiled assets such as LESS, SASS, or JavaScript. This directory also houses all of your language files.

The routes directory contains all of the route definitions for your application.

  • web.php: This route file is the default route file that you can put all the routes in this file
  • api.php: This route files is the route file that you can put all the restful api routes here

The storage directory contains your compiled Blade templates, file based sessions, file caches, and other files generated by the framework. This directory is segregated into app, framework, and logs directories. The app directory may be used to store any files generated by your application. The framework directory is used to store framework generated files and caches. Finally, the logs directory contains your application’s log files.

The storage/app/public directory may be used to store user-generated files, such as profile avatars, that should be publicly accessible.

The tests directory contains your automated tests. An example PHPUnit is provided out of the box. Each test class should be suffixed with the word Test. You may run your tests using the phpunit or php vendor/bin/phpunit commands.

The vendor folder contains the composer dependencies.