{"id":17761,"date":"2020-08-29T11:37:08","date_gmt":"2020-08-29T11:37:08","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=17761"},"modified":"2021-10-29T09:59:48","modified_gmt":"2021-10-29T09:59:48","slug":"top-10-basic-laravel-interview-questions","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/top-10-basic-laravel-interview-questions\/","title":{"rendered":"Top 10 Basic Laravel Interview Questions."},"content":{"rendered":"\n<p><strong>Q:-1<\/strong> What is Laravel?<\/p>\n\n\n\n<p>Laravel is a free, open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model\u2013view\u2013controller (MVC) architectural pattern.<\/p>\n\n\n\n<p><strong>Q:-2<\/strong> How to Install Laravel via Composer?<\/p>\n\n\n\n<p>composer create-project &#8211;prefer-dist laravel\/laravel myproject<\/p>\n\n\n\n<p><strong>Q:-3<\/strong>  How to Install any Specific version of Laravel via Composer?<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/samcotocus\/539191684924c379ffc88c7c6603e858.js\"><\/script>\n\n\n\n<p><strong>Q:-4<\/strong> What is php artisan?<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Artisan is the command-line interface included with Laravel.<\/li><li>It provides a number of helpful commands that can assist you while you build your application.<\/li><li>To view a list of all available Artisan commands, you may use the list command:<br><\/li><\/ol>\n\n\n\n<script src=\"https:\/\/gist.github.com\/samcotocus\/3cf48f7a416870ed11acb8b6e666cbd3.js\"><\/script>\n\n\n\n<p><strong>Q:-5<\/strong> How to turn off CRSF in Laravel?<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Remove or comment out this line in app\\Http\\Kernel.php<\/li><li>\\App\\Http\\Middleware\\VerifyCsrfToken::class,<\/li><\/ol>\n\n\n\n<p><strong>Q:-6 <\/strong>List types of relationships available in Laravel Eloquent?<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Eloquent relationships are defined as methods on your Eloquent model classes<\/li><li>Relationships supported by Laravel Eloquent ORM:<ol><li>One To One &#8211; hasOne<\/li><li>One To Many &#8211; hasMany<\/li><li>One To Many(Inverse) &#8211; belongsTo<\/li><li>Many To Many &#8211; belongsToMany<\/li><li>Has Many Through &#8211; hasManyThrough<\/li><li>Polymorphic Relations<\/li><li>Many To Many Polymorphic Relations<\/li><\/ol><\/li><\/ol>\n\n\n\n<p><strong>Q:-7<\/strong> What is the purpose of using dd() function in laravel?<\/p>\n\n\n\n<p><strong>dd()<\/strong>&nbsp;\u2013 Stands for&nbsp;<strong>&#8220;Dump and Die&#8221;<\/strong><br>Laravel&#8217;s dd() is a helper function ,which will dump a variable&#8217;s contents to the browser and halt further script execution.<\/p>\n\n\n\n<p><strong>Q:-8<\/strong> What is Middleware in Laravel?<\/p>\n\n\n\n<p>Middleware provide a convenient mechanism for filtering all HTTP requests entering in your application.<\/p>\n\n\n\n<p><strong>Q:-9<\/strong> What is Fillable Attribute in a Laravel Model?<\/p>\n\n\n\n<p>In eloquent ORM, $fillable is an array which contains all those fields of table which can be filled using mass-assignment.<\/p>\n\n\n\n<p><em>Mass assignment, means to send an array to the model to directly create a new record in Database<\/em><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/samcotocus\/99aa6943e28a4f01649f4e13ceb096f2.js\"><\/script>\n\n\n\n<p><strong>Q:-10<\/strong> List out databases that laravel supports?<\/p>\n\n\n\n<p>Currently, Laravel supports four databases:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>MySQL<\/li><li>PostgreSQL<\/li><li>SQLite<\/li><li>SQL Server<\/li><\/ol>\n\n\n\n<p>Note:<\/p>\n\n\n\n<p>you can use NoSQL databses with laravel by installing their packages.<\/p>\n\n\n\n<p>Laravel doesn&#8217;t support mongoDB out of the box, you&#8217;ll have to install a third party package or create your own implementation. I&#8217;d suggest using https:\/\/github.com\/jenssegers\/laravel-mongodb , it seems a pretty popular package on packagist atleast. Or you could use the php mongodb class https:\/\/secure.php.net\/manual\/en\/class.mongodb.php.<\/p>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_36952\"><iframe loading=\"lazy\"  id=\"_ytid_19623\"  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_36952\"  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 class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Q:-1 What is Laravel? Laravel is a free, open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model\u2013view\u2013controller (MVC) architectural pattern&#8230;. <\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5201],"tags":[],"class_list":["post-17761","post","type-post","status-publish","format-standard","hentry","category-laravel"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/17761","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\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=17761"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/17761\/revisions"}],"predecessor-version":[{"id":24586,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/17761\/revisions\/24586"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=17761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=17761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=17761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}