Getting Started with Laravel- Project Structure

Hello guys! We’re here to make more fun. Since the Laravel framework is getting more & more popular we’re going to start a tour to learn what actually Laravel is & what it can actually do.

Now as this is the first post about this amazing Laravel framework we’re going to discover the file structure of Laravel. Before going any further go to the Laravel & download the package first. Now let’s see the picture of the structure of Laravel framework.

main_file_structure

Now let’s take a closer look at each item:

/application

This is where you’ve to work all the time. The major time that you’ll spend only in here. The routing process, data models & views are all in here.

/bundles

These are Laravel applications, they can be used to different aspects of your development. It can be downloaded from the Laravel Bundles<link> section from their website. By installing bundles with artisan you can speed up your works also extend your functionality of works that suits you.

/laravel

This is where the core file of the framework lives. You rarely have to interact with this directory. It includes the main class file or methods everything which we extend from the controller or model.

/public

This is the web root directory. What viewers will show is situated in here. It contains with css files, js files & index.php. Laravel contains bootstrap files within it while downloading a fresh copy. You can also add your own stylesheet & script file in this directory.

/storage

The storage directory is used as file store for services that use the file system as a driver, for example Sessions, or the Cache class. This directory must be writable by the web-server. You will not need to interact with this directory to build a Laravel application.

/artisan [file]

Artisan is Laravel’s Command Line Interface, it allows you to install everything like bundles, api, migration etc or even to create your own tasks! To run Artisan simply write down the below code in a command prompt or terminal but remember before write down the below code you’ve to route down to the directory where you’ve stored your source file.

php artisan

/paths.php [file]

This file is used by the Framework to determine paths to the important directories mentioned above, and provide a shortcut for retrieving them ( using path()). You should not need to edit this file.

Application Directory Sturcture

Now let’s see the application directory structure as we’ve to stay most of the time of development in here. See the picture below:

app_file_structure

Have a closer look at each one:

/config

This folder contains a number of config file that you’ll need in the development process like the url seetings, database settings, sessions settings etc.

/controllers

If anyone have the idea of MVC pattern then i can say that this is MVC’s “C” which stands for contorller. Laravel actually provides two methods of routing, using controller or routes. This contains the contoller classes that are used to provide the basic login, interact with data models and load view files for your application.

/language

In this directory, string files exist to enable easy localization of applications written on Laravel, by default the directory contains string files for pagination and form validation in the English language.

/libraries

The libraries directory can be used to ‘drop in’ single class PHP Libraries to provide extra functionality for your application, for larger Libraries it is recommended that you create a Bundle instead. The libraries folder is added to the Autoloader at startup from the start.php file.

/migrations

The migrations folder contains PHP classes which allow Laravel to update the Schema of your current database, or populate it with values, while keeping all versions of the application in sync. Migration files must not be created manually, as their file name contains a timestamp, instead use the Artisan CLI interface command php artisan migrate:make <migration_name> to create a new Migration.

/models

This is MVC’s “M” which stands for Model. It also contains with some PHP Classes. Model used for the database related work like SQL queries. To create, update, delete where we are going to show all the info from the database via models

/tasks

By creating classes in the tasks directory, you are able to add your own custom tasks to the Laravel Artisan command line interface. Tasks are represented by Classes and methods.

/tests

The tests folder provides a location for you to keep your application Unit tests. Also if you use PHPUnit, you are able to execute all tests at once using the Laravel Artisan PHP command line interface.

/views

This is MVC’s “V” which stands for View. The view will contain your all html files that you want to design for your application. You can also use Laravels Blade templating library which is much better explained in the official documentaion what you’ve to do is just make the file name example.blade.php  that’s it!

/bundles.php [file]

To enable a bundle, simply add it to the array in bundles.php, you can also use a key-value name-array pair to define extra options for the bundle. These options can be found in the Laravel documentation(link).

/routes.php [file]

The routes file contains the methods which enable routes to be mapped to their appropriate outcome with Laravel. This file also contains declarations for several events including error pages, and can be used to define View Composers or Route Filters.

/start.php [file]

The start.php contains startup routines for the /application bundles, such as auto-loading directories, loading configs, and other wonderful useful stuff! Feel free to append to this file.

This is the end of our topics. Hope that I’ll get here with more & interesting tutorials. For those who actually wants to learn Laravel please don’t forget the visit the Documentaion of Laravel.

An enthusiastic of work with over 2+ years of experience. Extensively experienced on wordpress, Codeigniter, Laravel.

##Visit my github page (https://github.com/ashawkat)
##Visit my blogging page where I spread out my knowledges around all other people (http://w3programmers.com/author/tanim)

If you want to hire me then you can contact me via email or skype.

Skype: ashawkat89
Email: [email protected]

2 comments on “Getting Started with Laravel- Project Structure

Leave a Reply

Your email address will not be published. Required fields are marked *