Introduction to laravel 5.x application structure

There are more than 40 PHP frameworks available. The popular frameworks are Cakephp, Zend, Symfony, Codeigniter, Yii etc. In recent times Laravel got very popular among web developers. Currently, Laravel is one of the top PHP frameworks for modern web development.

\"popular

Laravel did major changes in its Application structure from 4.x to 5.x.

Application Structure

Laravel 4.X
  • app
    • commands
    • config
    • controller
    • database
    • lang
    • start
    • storage
    • database
    • tests
    • views
    • filters.php
    • routes.php
  • bootstrap
    • autoload.php
    • path.php
    • start.php
  • public
    • css
    • fonts
    • img
    • js
    • locales
    • packages
    • .htacess
    • index.php
    • robots.txt
  • vendor
    • composer.json
    • composer.lock
    • server.php
Laravel 5.X
  • app
    • Console
    • Http
      • Controllers
      • Filters
      • Requests
    • Providers
  • bootstrap
  • config
  • database
    • migrations
    • seeds
  • public
  • resources
    • lang
    • views
  • storage
    • cache
    • logs
    • meta
    • sessions
    • views
    • work

Laravel 5.x Application structure

App directory only contain application core code. App directory contains directories such as console , http , providers.

  • The Console directory contains all of the custom Artisan commands for your application.
  • The Http directory conatins code to handle request entering your application.It conatins controllers, middleware, and form requests.
    – Filters for authentication in laravel 4.x have been converted to middleware , if you want to use filter you can still use in laravel 5.x.
    The old app/models directory has been removed but if you want to use it you can implement.

You can also create other directories and classes as per your requirement inside app directory to extend your application.

Config directory contains all configuration file of application.

Database directory contains your database migration and seeds.

Resources directory contains all your appliactions views , assest and language files.

Storage directory contains compiled blade templates, file based cache , logs etc.

Why Laravel 5.x changed Application structure?

New structure help developers to easily understand and work with framework , as you can see its follows \”best practice\” that development community follow.

It also implemented advanced objected oriented features like name spacing etc.

New route:cache Artisan command to speed up the registration of your application routes.

Most important key point is Laravel 5.1 and above version is compatible with PHP7.

Update: Also read Read how to upgrade Laravel 4.2 to 5.0 and above version