{"id":16198,"date":"2020-07-13T17:28:35","date_gmt":"2020-07-13T17:28:35","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=16198"},"modified":"2021-10-30T06:29:17","modified_gmt":"2021-10-30T06:29:17","slug":"directory-structure-of-laravel","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/directory-structure-of-laravel\/","title":{"rendered":"Directory Structure of Laravel"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"167\" height=\"568\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/directory-structure.png\" alt=\"\" class=\"wp-image-16201\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/directory-structure.png 167w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/directory-structure-88x300.png 88w\" sizes=\"auto, (max-width: 167px) 100vw, 167px\" \/><\/figure>\n\n\n\n<p>The image is showing the files and directories of <strong>laravel<\/strong>. It is automatically created when we create a project using a composer or laravel installer.<\/p>\n\n\n\n<p>Let&#8217;s we overview these files and directories.<\/p>\n\n\n\n<p>First we understand about <strong>files<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">.env <\/h3>\n\n\n\n<p>This is an environment file where we put credentials (username password and other information) which will use in the project. Ex. Database username, password, database name, any third party creds like Mailgun, Redis, etc.<\/p>\n\n\n\n<p>We can change the path of this file for more security purpose. Go to <strong>vendor\\vlucas\\phpdotenv\\src\\Loader <\/strong>and change it in the constructor.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">.gitattribute<\/h3>\n\n\n\n<p>It just hint about git. Don&#8217;t think more about this file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">.gitignore<\/h3>\n\n\n\n<p>Here we put file name which will not commit in bitbucket or git repos.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">artisan<\/h3>\n\n\n\n<p>When we run <strong>PHP <\/strong>artisan command in terminal or command prompt actually we trigger this file only. It runs The Artisan Application.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">composer.json<\/h3>\n\n\n\n<p>This is the configuration file that specifies all dependencies or dependencies for development purpose.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">composer.lock<\/h3>\n\n\n\n<p>It lock the version of dependencies. So, In future when we&#8217;ll install the dependency, Install same version.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">package.json<\/h3>\n\n\n\n<p>This is related to frontend dependency. you may find the which frontend dev dependencies (with version) is installed. Ex.vue,jquery etc.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">server.php<\/h3>\n\n\n\n<p>This file allows us to emulate Apache&#8217;s &#8220;mod_rewrite&#8221; functionality from the built-in PHP web server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">webpack.mix.js<\/h3>\n\n\n\n<p>It compiles scss or less or js files.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">api.php<\/h3>\n\n\n\n<p>Here we can register API routes for our application.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">channels.php<\/h3>\n\n\n\n<p>Here we may register all of the event broadcasting channels that our application supports.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">console.php<\/h3>\n\n\n\n<p>Here we may define all of our Closure based console commands and run on terminal. ex. PHP artisan inspire or PHP artisan foobar etc.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">web.php<\/h3>\n\n\n\n<p>we can register web routes for our application. <\/p>\n\n\n\n<p>Ex. Route::get(&#8216;\/&#8217;,&#8217;RegisterController@index&#8217;); Route::post(&#8216;\/register&#8217;,&#8217;RegisterController@register&#8217;);<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Directories<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">App Directory<\/h3>\n\n\n\n<p>The app directory contains the core code of your application.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Bootstrap Directory<\/h3>\n\n\n\n<p>The bootstrap directory contains the app.php file which bootstraps the framework.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Config Directory<\/h3>\n\n\n\n<p>The config directory, as the name implies, contains all of your application&#8217;s configuration files.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Database Directory<\/h3>\n\n\n\n<p>The database directory contains your database migrations, model factories, and seeds.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Public Directory<\/h3>\n\n\n\n<p>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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Resources Directory<\/h3>\n\n\n\n<p>The resources directory contains your views as well as your raw, un-compiled assets such as LESS, SASS, or JavaScript. This directory also houses all of your language files.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Routes Directory<\/h3>\n\n\n\n<p>The routes directory contains all of the route definitions for your application.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Storage Directory<\/h3>\n\n\n\n<p>The storage directory contains your compiled Blade templates, file-based sessions, file caches, and other files generated by the framework.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Test Directory<\/h3>\n\n\n\n<p>This directory contain the test code of our project for testing purpose.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">vendor Directory<\/h3>\n\n\n\n<p>This directory contains the core files of the composer so no need to worry about this and here we don&#8217;t create files\/folders writes code in existing files.<\/p>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_84488\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_86276\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_84488\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>The image is showing the files and directories of laravel. It is automatically created when we create a project using a composer or laravel installer. Let&#8217;s we overview these files and directories. First we understand about files. .env This is an environment file where we put credentials (username password and other information) which will use&#8230;<\/p>\n","protected":false},"author":9,"featured_media":16205,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[5201],"tags":[568,5203,177],"class_list":["post-16198","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-bootstrap","tag-laravel","tag-php"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/16198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=16198"}],"version-history":[{"count":4,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/16198\/revisions"}],"predecessor-version":[{"id":24670,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/16198\/revisions\/24670"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/16205"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=16198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=16198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=16198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}