<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>laravel project Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/laravel-project/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/laravel-project/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Mon, 12 Jul 2021 09:27:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>How to Create Multiple Role Based Authentication in Laravel 5.8</title>
		<link>https://www.scmgalaxy.com/tutorials/how-to-create-multiple-role-based-authentication-in-laravel-5-8/</link>
					<comments>https://www.scmgalaxy.com/tutorials/how-to-create-multiple-role-based-authentication-in-laravel-5-8/#respond</comments>
		
		<dc:creator><![CDATA[Joydeep M]]></dc:creator>
		<pubDate>Fri, 16 Apr 2021 07:22:26 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[laravel project]]></category>
		<category><![CDATA[Login]]></category>
		<category><![CDATA[logout]]></category>
		<category><![CDATA[multi authentication]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=5893</guid>

					<description><![CDATA[<p>In this tutorial we will see how we can create a basic multiple role based authentication page by using Laravel. [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-create-multiple-role-based-authentication-in-laravel-5-8/">How to Create Multiple Role Based Authentication in Laravel 5.8</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In this tutorial we will see how we can create a basic multiple role based authentication page by using Laravel. To understand it we should have more than basic understandings of Laravel.</p>



<ul class="wp-block-list"><li>To start it as we all know we have to create a project (xampp/htdocs directory) in our terminal by running the command given below:</li></ul>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">composer create-project --prefer-dist laravel/laravel multi-auth "5.8.*"</span></code></pre>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">cd multi-auth</span></code></pre>



<ul class="wp-block-list"><li>Once we have created the project we will run the make:auth command to create the default login authentication system of laravel.</li></ul>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">php artisan make:auth</span></code></pre>



<ul class="wp-block-list"><li>Now we need to customize the users_table under migration as per our requirement.</li></ul>



<script src="https://gist.github.com/Joydeep-cotocus/5c679518c74fda9d6c42f325145aa6c5.js"></script>



<ul class="wp-block-list"><li>Now we have to create model and migration for role table where we can see the different roles who can login like &#8216;admin&#8217;, &#8216;user&#8217; etc.</li></ul>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">php artisan make:model Role -m
</span></code></pre>



<ul class="wp-block-list"><li>In the roles table we will customize the Schemas as per the requirement.</li></ul>



<script src="https://gist.github.com/Joydeep-cotocus/840aaae005b136e252fd7aa715433d83.js"></script>



<ul class="wp-block-list"><li>So now we have two model naming Users and Roles and both are dependent on each other hence we need to make a relationship between them.</li><li>To create a relationship we will create functions in both the model for the other one by giving the command given below.</li></ul>



<script src="https://gist.github.com/Joydeep-cotocus/33ec12e64aaff627178188a7db5fe3c2.js"></script>



<script src="https://gist.github.com/Joydeep-cotocus/5aa63d070c5f06e585eff7146eb48fe8.js"></script>



<ul class="wp-block-list"><li>In the next step we need to create seeders for each of the model (User , Role). To create the UsersTableseeder and</li></ul>



<p class="wp-block-paragraph">RolesTableSeeder we will run the command given below.</p>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">php artisan make:seed UsersTableSeeder
php artisan make:seed RolesTableSeeder</span></code></pre>



<ul class="wp-block-list"><li>After the following step we need to add<strong> insert</strong> function in the <strong>UsersTableseeder</strong> and <strong>RolesTableSeeder</strong> and also declare the<strong> use Illuminate\Support\Facades\DB;</strong> in both the seeders in the beginning since we will be using DB class in the seeders.</li></ul>



<script src="https://gist.github.com/Joydeep-cotocus/9b4ae503abedb52bffbd0d0d3f50f1f4.js"></script>



<script src="https://gist.github.com/Joydeep-cotocus/a39049e4507a74a9e1af5086278ea1c9.js"></script>



<ul class="wp-block-list"><li>Once we are done with the steps given above we will create a database and link it with the project in the .env file. In this project I have named the database as <strong>corona </strong>(since it is in trend <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f61b.png" alt="😛" class="wp-smiley" style="height: 1em; max-height: 1em;" />) and added that in my .env file as shown below, with that we will keep the username as <strong>root</strong> and leave the password blank.</li></ul>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="604" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/04/env-1024x604.jpg" alt="" class="wp-image-5894" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/04/env-1024x604.jpg 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/04/env-300x177.jpg 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/04/env-768x453.jpg 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/04/env.jpg 1201w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<ul class="wp-block-list"><li>Once done with the database creation we will migrate our tables into the database with the command given below.</li></ul>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">php artisan migrate</span></code></pre>



<ul class="wp-block-list"><li>In the next step we need to define two created seeders files (UsersTableSeeder and RolesTableSeeder) into the DatabaseSeeder.php as shown below:</li></ul>



<script src="https://gist.github.com/Joydeep-cotocus/04883a7777df6cdd2b184a82e7b0788c.js"></script>



<ul class="wp-block-list"><li>Now we need to import our data stored in the Seeder files into the database which we created using the command:</li></ul>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">php artisan db:seed</span></code></pre>



<ul class="wp-block-list"><li>Until here we have set up the database for storing the details which will be provided by the user and now we need to create the controllers and the middleware to authenticate and redirect the users to there respective pages.</li><li>First of all we need to create controller for User and the Admin.</li><li>To create the controller we need to the follow the command given below:</li></ul>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">php artisan make:controller Admin/AdminController</span>
<span class="has-inline-color has-vivid-red-color">php artisan make:controller User/UserController</span></code></pre>



<ul class="wp-block-list"><li>Now we will be creating middleware for the authentication of the Admin and the User.</li></ul>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">php artisan make:middleware AdminMiddleware
php artisan make:middleware UserMiddleware</span>
</code></pre>



<ul class="wp-block-list"><li>Now we will add Auth trait in the AdminMiddleware and UserMiddleware for authentication of the User and the Admin by writing <strong>use Auth;</strong></li><li>In the next step we will add <strong>handle() </strong>function in the AdminMiddleware and UserMiddleware.</li></ul>



<script src="https://gist.github.com/Joydeep-cotocus/7725e51cf1bdd0dcaf413969a858f312.js"></script>



<script src="https://gist.github.com/Joydeep-cotocus/d6bf8d1a3b0aad0ab11530d0c1eed33f.js"></script>



<ul class="wp-block-list"><li>We will also implement Condition for <strong>Admin </strong>and <strong>User</strong> Login in <strong>RedirectIfAuthenticated </strong>which is in <strong>app/Http/Middleware/RedirectIfAuthenticated.php</strong>.</li></ul>



<script src="https://gist.github.com/Joydeep-cotocus/7b9d1f429963d00a585f382596d8dc70.js"></script>



<ul class="wp-block-list"><li>Now we will be implementing condition in the login controller before that we will remove <strong>‘/home’</strong>&nbsp;from protected&nbsp;<strong>$redirectTo = ‘/home’;</strong> since we don&#8217;t want to redirect the page to <strong>Home</strong> after logging in.</li></ul>



<script src="https://gist.github.com/Joydeep-cotocus/17bb714a11deae02aa4965c7a6784023.js"></script>



<ul class="wp-block-list"><li>Likewise we will implement condition in the <strong>ResetPasswordController </strong>and remove <strong>‘/home’</strong>&nbsp;from protected&nbsp;<strong>$redirectTo = ‘/home’</strong>;</li></ul>



<script src="https://gist.github.com/Joydeep-cotocus/d8c4f8af61d240945a32fa91df71ec5c.js"></script>



<ul class="wp-block-list"><li>Once we are done with the above steps we will use AdminMiddleware and UserMiddleware in Kernal.php which is in <strong>app/Http/Kernel.php</strong>.</li></ul>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">use App\Http\Middleware\AdminMiddleware;
use App\Http\Middleware\UserMiddleware;</span></code></pre>



<ul class="wp-block-list"><li>After that we need to define and for defining we will add the command given below in routeMiddleware.</li></ul>



<pre class="wp-block-code"><code><span class="has-inline-color has-vivid-red-color">'admin' =&gt; AdminMiddleware::class,
'user' =&gt; UserMiddleware::class,</span></code></pre>



<ul class="wp-block-list"><li>Now we are almost done with it and need to write the routes for the Admin and the User. </li></ul>



<script src="https://gist.github.com/Joydeep-cotocus/7061dc124e2421b0da98f6792c05e605.js"></script>



<ul class="wp-block-list"><li>Almost done but we need to make the views as well where we can redirect the admin or user once they login.</li></ul>



<p class="wp-block-paragraph">-Create a blade file for Admin dashboard under <strong>resource/views/admin/dashboard.blade.php</strong>.</p>



<p class="wp-block-paragraph">-Create a blade file for User dashboard under <strong>resource/views/user/dashboard.blade.php.</strong></p>



<ul class="wp-block-list"><li>Under the dashboard blades of User and Admin we can write the basic HTML to check whether it is showing it when redirected.</li></ul>



<script src="https://gist.github.com/Joydeep-cotocus/97649d356909a595ee46abe0c281bc3f.js"></script>



<script src="https://gist.github.com/Joydeep-cotocus/773d46c474372fea7049d21c6051d3a6.js"></script>



<p class="wp-block-paragraph"><strong>It&#8217;s good to go now. You can leave a comment if getting any error while following the steps.</strong></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-create-multiple-role-based-authentication-in-laravel-5-8/">How to Create Multiple Role Based Authentication in Laravel 5.8</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/how-to-create-multiple-role-based-authentication-in-laravel-5-8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Creating tables in Migration</title>
		<link>https://www.scmgalaxy.com/tutorials/creating-tables-in-migration/</link>
					<comments>https://www.scmgalaxy.com/tutorials/creating-tables-in-migration/#respond</comments>
		
		<dc:creator><![CDATA[Joydeep M]]></dc:creator>
		<pubDate>Thu, 11 Mar 2021 12:41:56 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[laravel database]]></category>
		<category><![CDATA[laravel migrations]]></category>
		<category><![CDATA[laravel project]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5496</guid>

					<description><![CDATA[<p>In Laravel to create a new database table first of all we need to make a migration which we have [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/creating-tables-in-migration/">Creating tables in Migration</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In Laravel to create a new database table first of all we need to make a migration which we have explained in the previous blog. I recommend you to read that blog, you can refer the link given below:</p>



<p class="wp-block-paragraph"><br><a href="https://www.scmgalaxy.com/tutorials/explanation-of-database-migrations-in-laravel-5-8/">https://www.scmgalaxy.com/tutorials/explanation-of-database-migrations-in-laravel-5-8/</a></p>



<p class="wp-block-paragraph">Once we are done with creating a migration file, to create a new database<br>table we have to use the create method on the Schema facade. The create method accepts two arguments:-</p>



<p class="wp-block-paragraph">The first is the name of the table, while the second is a closure which receives a Blueprint object that may be used to define the new table:</p>



<pre class="wp-block-code"><code>use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Schema::create('users', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->string('email');
    $table->timestamps();
});</code></pre>



<p class="wp-block-paragraph">In the table we can add number of $table as per our requirement. There are several data type which we can use while creating the $table. Few of them are given below:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow" id="column-method-bigIncrements"><p><code>bigIncrements()</code></p></blockquote>



<p class="wp-block-paragraph">The&nbsp;<code>bigIncrements</code>&nbsp;method creates an auto-incrementing&nbsp;<code>UNSIGNED BIGINT</code>&nbsp;(primary key) equivalent column:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
$table-&gt;bigIncrements(&#039;id&#039;);
</pre></div>


<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow" id="column-method-bigInteger"><p><code>bigInteger()</code></p></blockquote>



<p class="wp-block-paragraph">The&nbsp;<code>bigInteger</code>&nbsp;method creates a&nbsp;<code>BIGINT</code>&nbsp;equivalent column:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
$table-&gt;bigInteger(&#039;votes&#039;);
</pre></div>


<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow" id="column-method-id"><p><code>id()</code></p></blockquote>



<p class="wp-block-paragraph">The&nbsp;<code>id</code>&nbsp;method is an alias of the&nbsp;<code>bigIncrements</code>&nbsp;method. By default, the method will create an&nbsp;<code>id</code>&nbsp;column; however, you may pass a column name if you would like to assign a different name to the column:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
$table-&gt;id();
</pre></div>


<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow" id="column-method-rememberToken"><p><code>rememberToken()</code></p></blockquote>



<p class="wp-block-paragraph">The&nbsp;<code>rememberToken</code>&nbsp;method creates a nullable,&nbsp;<code>VARCHAR(100)</code>&nbsp;equivalent column that is intended to store the current &#8220;remember me&#8221;&nbsp;<a href="https://laravel.com/docs/8.x/authentication#remembering-users">authentication token</a>:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
$table-&gt;rememberToken();
</pre></div>


<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow" id="column-method-string"><p><code>string()</code></p></blockquote>



<p class="wp-block-paragraph">The&nbsp;<code>string</code>&nbsp;method creates a&nbsp;<code>VARCHAR</code>&nbsp;equivalent column of the given length:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
$table-&gt;string(&#039;name&#039;, 100);
</pre></div>


<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow" id="column-method-text"><p><code>text()</code></p></blockquote>



<p class="wp-block-paragraph">The&nbsp;<code>text</code>&nbsp;method creates a&nbsp;<code>TEXT</code>&nbsp;equivalent column:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
$table-&gt;text(&#039;description&#039;);
</pre></div>


<p class="wp-block-paragraph">To know more about creating tables and adding columns, you can refer the video given below:</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe  id="_ytid_54441"  width="640" height="360"  data-origwidth="640" data-origheight="360" src="https://www.youtube.com/embed/pd99VUe7b0o?enablejsapi=1&#038;list=PLT9miexWCpPXuMenRSnpek96ncK3dXf90&#038;index=13&#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__  epyt-is-override  no-lazyload" title="YouTube player"  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>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/creating-tables-in-migration/">Creating tables in Migration</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/creating-tables-in-migration/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How Control flow in Laravel</title>
		<link>https://www.scmgalaxy.com/tutorials/how-control-flow-in-laravel/</link>
					<comments>https://www.scmgalaxy.com/tutorials/how-control-flow-in-laravel/#respond</comments>
		
		<dc:creator><![CDATA[abhishek k]]></dc:creator>
		<pubDate>Thu, 11 Mar 2021 08:46:30 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[control flow explanation]]></category>
		<category><![CDATA[control flow in laravel]]></category>
		<category><![CDATA[laravel control flow]]></category>
		<category><![CDATA[laravel project]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5456</guid>

					<description><![CDATA[<p>Route::get(&#8216;task&#8217;,&#8217;TaskController@index&#8217;)-&#62;name(&#8216;task&#8217;); Explanation:- name(&#8216;task&#8216;) is given in the URL as http://127.0.0.1:8000/task. Control flow:- As the URL is hit the control will [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-control-flow-in-laravel/">How Control flow in Laravel</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"><em>Route::get(&#8216;task&#8217;,&#8217;TaskController@index&#8217;)-&gt;name(&#8216;task&#8217;);</em>                                        Explanation:-                                                                                                                              name(&#8216;<strong>task</strong>&#8216;) is given in the URL as <strong>http://127.0.0.1:8000/task</strong>.                                         <span class="has-inline-color has-vivid-red-color"><strong>Control flow</strong></span>:-                                                                                                                                                                                                                  As the URL is hit the control will go the route(<strong><em>web.php</em></strong>), there it will get <em>Route::get(&#8216;task&#8217;,&#8217;TaskController@index&#8217;)-&gt;name(&#8216;task&#8217;);</em>                                                       Here, there will be a name match from the URL and if there is match then there will be a function call named <strong>index</strong> and route will redirect to <em><strong>TaskController.php</strong></em> where it will find the function <em>index </em>and operate according to the instructions given inside it.                                                                       </p>



<p class="wp-block-paragraph">After the create operation we need to store the data in the database for this we used <strong><em>&lt;form&nbsp;action=&#8221;{{route(&#8216;store&#8217;)}}&#8221;&nbsp;method=&#8221;POST&#8221;&gt;</em></strong> which will call store function.                                                                                                                                  The store function be like                                                                                                        </p>



<script src="https://gist.github.com/abhi040498/c57065a3124ffb12ff36e63334907604.js"></script>



<p class="wp-block-paragraph">The in store function we create object <strong>$var</strong> of <strong>Task </strong>class make variables as <strong>$var-&gt;task</strong>&nbsp;which is assigned&nbsp;<strong>$request-&gt;task;</strong>&nbsp;(gets value from 1<sup>st</sup> field) &amp; <strong>$var-&gt;detail </strong>which is assigned&nbsp;<strong>$request-&gt;detail;</strong>&nbsp;(gets value from 2<sup>nd</sup> field) and <strong><em>$var-&gt;save(); </em></strong>function will save it to the database.</p>



<p class="wp-block-paragraph">                               </p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-control-flow-in-laravel/">How Control flow in Laravel</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/how-control-flow-in-laravel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Setup a Laravel Project and Understand the Folder Structure</title>
		<link>https://www.scmgalaxy.com/tutorials/setup-a-laravel-project-and-understand-the-folder-structure/</link>
					<comments>https://www.scmgalaxy.com/tutorials/setup-a-laravel-project-and-understand-the-folder-structure/#respond</comments>
		
		<dc:creator><![CDATA[abhishek k]]></dc:creator>
		<pubDate>Thu, 04 Mar 2021 07:39:55 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[files and folder in laravel]]></category>
		<category><![CDATA[folder structure&#039;]]></category>
		<category><![CDATA[laravel project]]></category>
		<category><![CDATA[laravel project and folder structure]]></category>
		<category><![CDATA[project setup in laravel]]></category>
		<category><![CDATA[setup Laravel project]]></category>
		<category><![CDATA[understand folder structure]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5386</guid>

					<description><![CDATA[<p>Setting up a Laravel project is an easy task. We need to have the composer installed in our system. Then [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/setup-a-laravel-project-and-understand-the-folder-structure/">Setup a Laravel Project and Understand the Folder Structure</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-medium-font-size wp-block-paragraph"><strong>Setting up a Laravel project is an easy task.</strong></p>



<p class="has-normal-font-size wp-block-paragraph"><br>We need to have the composer installed in our system. Then we need to download the Laravel installer, the command for installation is<br><em><strong>composer global require “laravel/installer=~1.1”</strong></em><br>if this does not works then we could just write<br><em><strong>composer global require “laravel/installer”</strong></em><br>and it would install the file.<br>Then we need to create a project and for this, we need to type<br><strong><em>composer create-project –prefer-dist laravel/laravel blog “5.8”</em></strong><br>if this does not works then we could just write<br><strong><em>composer create-project –prefer-dist laravel/laravel blog</em></strong><br>it would create a Laravel project named blog.</p>



<p class="wp-block-paragraph">Soon after the project is created we now have to </p>



<p class="has-medium-font-size wp-block-paragraph"><strong>Understanding the Folder structure</strong></p>



<p class="has-normal-font-size wp-block-paragraph">The most important thing in the Laravel project is understanding the structure of files and folders. Understanding the files and folder structure’s <em>main purpose is to understand where we need to write codes for Html, Model, Controller, Routing, Filestore, Config, and Database.<br></em>The time after the Laravel project is created we see different folders and files. All the files and folder build while building the project have their use and gives it easy access while writing codes.<br>The main folder in the project consists of</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-1.png" alt="" class="wp-image-5389" width="149" height="226"/></figure></div>



<p class="has-normal-font-size wp-block-paragraph">Let’s take a brief look at the different folders created and the files in them.</p>



<p class="wp-block-paragraph"><br>The first one <em><strong>App </strong></em>mainly includes codes for <strong>HTML, Model, and Controller</strong> which are in folders shown below.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-2.png" alt="" class="wp-image-5390" width="133" height="139"/></figure></div>



<p class="has-normal-font-size wp-block-paragraph"><br>In the <strong><em>console</em></strong> directory, there is a <em>kernel.php</em> file that has codes for the custom command. <br><em>Exception </em>folders have <em>handler.php</em> that includes all the codes for different exceptions.<br>The <em>HTTP </em>folder has 2 sub-folders namely <em>controllers</em> and <em>middleware</em>.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-5.png" alt="" class="wp-image-5401" width="239" height="392" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-5.png 319w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-5-183x300.png 183w" sizes="auto, (max-width: 239px) 100vw, 239px" /></figure></div>



<p class="has-normal-font-size wp-block-paragraph"><em>Controllers </em>and <em>Middleware </em>mainly include files acting as a bridge between database and webpage. These include files for <em>authentication login validation, registering ids, resetting the password</em>, etc.</p>



<p class="has-normal-font-size wp-block-paragraph"><em>Cookies </em>that are used to store some data of the user are also managed here. <em>Controllers </em>act as an interface between database and web-page and <em>Middleware </em>filters out the request.</p>



<p class="wp-block-paragraph">The <em><strong>Model<code> </code></strong></em>directory contains all of your&nbsp;model classes. It provides a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding &#8220;Model&#8221; which is used to interact with that table. Models allow you to query for data in your tables, as well as insert new records into the table.</p>



<p class="wp-block-paragraph">Then we have a <em><strong>Provider </strong></em>directory.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-6.png" alt="" class="wp-image-5402" width="290" height="141" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-6.png 386w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-6-300x146.png 300w" sizes="auto, (max-width: 290px) 100vw, 290px" /></figure></div>



<p class="wp-block-paragraph">where we write different kinds of services like authentication services, routing services, and more.</p>



<p class="wp-block-paragraph">Then we have <strong><em>Bootstrap </em></strong>directory that has an <em>app.php </em>file that helps in bootstrapping the application i.e loading the application on the browser.</p>



<p class="wp-block-paragraph">Then we have a <em><strong>config </strong></em>directory that contains all the configuration files like database configurations, email configurations, session configurations, login configurations, catch configurations, and many more.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-7.png" alt="" class="wp-image-5403" width="216" height="326" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-7.png 288w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-7-199x300.png 199w" sizes="auto, (max-width: 216px) 100vw, 216px" /></figure></div>



<p class="wp-block-paragraph">The <strong><em>database </em></strong>directory mainly includes three folders i.e<em> factories, migrations, </em>and <em>seed</em>. </p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-8.png" alt="" class="wp-image-5404" width="332" height="160" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-8.png 442w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-8-300x145.png 300w" sizes="auto, (max-width: 332px) 100vw, 332px" /></figure></div>



<p class="wp-block-paragraph"><em>Factories&nbsp;</em>provide&nbsp;a&nbsp;convenient&nbsp;way&nbsp;to&nbsp;generate&nbsp;new&nbsp;model&nbsp;instances&nbsp;for&nbsp;  testing/seeding the&nbsp;application&#8217;s&nbsp;database.                                                                                                  In <em>Migrations, </em>one database is shared with another database and also between developers.                                                                                                                                          <em>Seeding </em>simply means putting the fake/dummy data in the database. </p>



<p class="wp-block-paragraph">The <strong><em>public </em></strong>directory </p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-9.png" alt="" class="wp-image-5405" width="269" height="156" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-9.png 359w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-9-300x174.png 300w" sizes="auto, (max-width: 269px) 100vw, 269px" /></figure></div>



<p class="wp-block-paragraph">has <em>CSS, js</em>, and more files that have predefined JavaScript and CSS of the project and most importantly <em>index.php</em> file. This is the first file that is loaded in the browser when our server (local server) is hosted.</p>



<p class="wp-block-paragraph">The <strong><em>resource </em></strong>directory </p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-10.png" alt="" class="wp-image-5406" width="265" height="135" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-10.png 353w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-10-300x153.png 300w" sizes="auto, (max-width: 265px) 100vw, 265px" /></figure></div>



<p class="wp-block-paragraph">is the important part where all the public files of HTML, CSS, js files are coded and sometimes local files. This directory most importantly  includes <em>views </em>where we write the complete HTML. All the HTML pages that we want to display shall be placed here. These files can be placed directly or can placed inside the folder in views.</p>



<p class="wp-block-paragraph">The <strong><em>route </em></strong>directory&#8217;s main purpose is placing the codes for URLs for the web as well as API.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-12.png" alt="" class="wp-image-5408" width="290" height="134" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-12.png 387w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-12-300x138.png 300w" sizes="auto, (max-width: 290px) 100vw, 290px" /></figure></div>



<p class="wp-block-paragraph">The&nbsp;<strong><em>storage </em></strong>directory contains the <em>app, framework</em>, and <em>log </em>directory. The <em>storage&nbsp;</em>directory is used to store framework-generated files and <em>caches</em>. They also contain compiled <em>Blade </em>templates, file-based <em>sessions, </em>file <em>caches</em>, and other files generated by the framework and the log<em> </em>directory contains your application&#8217;s log files.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-14.png" alt="" class="wp-image-5410" width="326" height="239" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-14.png 435w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-14-300x220.png 300w" sizes="auto, (max-width: 326px) 100vw, 326px" /></figure></div>



<p class="wp-block-paragraph">The <strong><em>test&nbsp;</em></strong>directory contains automated tests. We may run tests using the&nbsp;<code><em>phpunit</em></code>&nbsp;or<em>&nbsp;<code>php vendor/bin/phpunit</code></em>&nbsp;commands.</p>



<p class="wp-block-paragraph"><strong><em>Vendor </em></strong>directory stores all the package files which are installed by the composers.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-13.png" alt="" class="wp-image-5409" width="248" height="452" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-13.png 331w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-13-165x300.png 165w" sizes="auto, (max-width: 248px) 100vw, 248px" /></figure></div>



<p class="wp-block-paragraph"> In simple terms, the <em><strong>vendor </strong></em>directory acts as a store-keeper for all the package files for the project in laravel. </p>



<p class="wp-block-paragraph">We have few more files that are necessary like environment file (<em>env.php</em>), composer file (<em>composer.json</em>), package file (<em>package.json</em>).</p>



<p class="wp-block-paragraph">We use <em>webpack.mix.js</em> for integration of CSS and js files from different developers for effective use. It also serves as a better security for CSS and js files  in the project so that it cannot be publicly accessed. </p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/setup-a-laravel-project-and-understand-the-folder-structure/">Setup a Laravel Project and Understand the Folder Structure</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/setup-a-laravel-project-and-understand-the-folder-structure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
