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. https://windows.php.net/download/
Download the dependencies manager composer at https://getcomposer.org/download/, 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
- 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
- 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 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.
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
php vendor/bin/phpunit commands.
vendor folder contains the composer dependencies.