{"id":9702,"date":"2021-01-22T14:45:56","date_gmt":"2021-01-22T09:15:56","guid":{"rendered":"https:\/\/vividreal.co.in\/vividreal1.0\/?p=9702"},"modified":"2021-01-22T14:45:56","modified_gmt":"2021-01-22T09:15:56","slug":"step-by-step-tutorial-to-building-your-first-laravel-application","status":"publish","type":"post","link":"https:\/\/vividreal.co.in\/vividreal1.0\/step-by-step-tutorial-to-building-your-first-laravel-application\/","title":{"rendered":"Step by Step tutorial to building your first Laravel application"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">The ones acquainted with the world of coding might be aware of the sores it can give you. Continuously laying them out one by one can be very tiring as well as complicated. It is times like these when you can make use of effective <\/span><a href=\"https:\/\/vividreal.co.in\/vividreal1.0\/introduction-to-php-frameworks\/\"><span style=\"font-weight: 400;\">PHP frameworks<\/span><\/a><span style=\"font-weight: 400;\">.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Laravel is one such framework that helps web developers in creating remarkable web designs using PHP. What makes it stand apart from other similar frameworks is that its compatibility and convenience to use. It also has a number of available features that will help one in developing a rapid web application.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this article, we will guide you through the steps in which you can set up your Laravel Application. Sit back and get ready for this beginner\u2019s guide.\u00a0<\/span><\/p>\n<p><span style=\"color: #00ccff;\"><b>Laravel: Beginners Note<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Ever since its initial launch in 2011, Laravel experienced exponential growth. By the year 2015 Laravel became one of the most noted PHP frameworks on GitHub and evolved to be the go-to-go at the global level. The fact that Laravel is focused on the end-user firstly denotes its level of simplicity and clarity on getting the required work accomplished. Brands, as well as individuals, use it to build several projects.<\/span><\/p>\n<p><span style=\"color: #00ccff;\"><b>Steps to set up Laravel<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">First things first, Laravel is a framework that requires certain system requirements. It is recommended to use the Laravel Homestead virtual machine as your local development environment. In case you are not using Homestead, just make sure that your server possesses the following requirements: <\/span><span style=\"font-weight: 400;\">PHP &gt;= 7.3, Fileinfo PHP Extension, Tokenizer PHP Extension, PDO PHP Extension, XML PHP Extension, JSON PHP Extension, Ctype PHP Extension, Mbstring PHP Extension, OpenSSL PHP Extension, BCMath PHP Extension. Now let\u2019s look at the steps in installing and setting up Laravel.<\/span><\/p>\n<p><span style=\"color: #00ccff;\"><b>Step 1<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Laravel uses a composer to manage its dependencies. Therefore before you install Laravel to your system make sure you have a composer installed in it. You can download the composer from the link given below and then install it on your system.\u00a0<\/span><span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n<p><a href=\"https:\/\/getcomposer.org\/download\/\"><span style=\"font-weight: 400;\">Download Composer<\/span><\/a><\/p>\n<p><span style=\"color: #00ccff;\"><span style=\"font-weight: 400;\">\u00a0<\/span><b>Step 2<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Once the composer gets installed, try and check its installation by typing the Composer command in the command prompt.<\/span><\/p>\n<p><img loading=\"lazy\" class=\" wp-image-9708 aligncenter\" src=\"https:\/\/vividreal.co.in\/vividreal1.0\/wp-content\/uploads\/2020\/12\/pasted-image-0-300x192.png\" alt=\"\" width=\"700\" height=\"448\" srcset=\"https:\/\/vividreal.co.in\/vividreal1.0\/wp-content\/uploads\/2020\/12\/pasted-image-0-300x192.png 300w, https:\/\/vividreal.co.in\/vividreal1.0\/wp-content\/uploads\/2020\/12\/pasted-image-0.png 588w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p><span style=\"color: #00ccff;\"><b>Step 3<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Create a new directory somewhere on your computer for the Laravel project that you are going to create. Then, move on to the path where you created the new directory and type the command given below in order to install Laravel.\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">composer create-project laravel\/laravel \u2013-prefer-dist<\/span><\/pre>\n<p><span style=\"color: #00ccff;\"><b>Step 4<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can also install the Laravel framework directly with the develop branch in which the latest frameworks are included. The command to install the complete framework is given below.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">composer create-project laravel\/laravel test dev-develop<\/span><\/pre>\n<p><span style=\"color: #00ccff;\"><b>Step 5<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">This command will enable the installation of Laravel in the current directory. By executing the command given below you can start the Laravel services in your system.\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">php artisan serve<\/span><\/pre>\n<p><span style=\"color: #00ccff;\"><b>Step 6<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Once you are done executing the given command you will get to see this window &#8211;<\/span><\/p>\n<p><img loading=\"lazy\" class=\" wp-image-9709 aligncenter\" src=\"https:\/\/vividreal.co.in\/vividreal1.0\/wp-content\/uploads\/2020\/12\/image-2-300x150.png\" alt=\"\" width=\"700\" height=\"350\" srcset=\"https:\/\/vividreal.co.in\/vividreal1.0\/wp-content\/uploads\/2020\/12\/image-2-300x150.png 300w, https:\/\/vividreal.co.in\/vividreal1.0\/wp-content\/uploads\/2020\/12\/image-2.png 512w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p><span style=\"color: #00ccff;\"><b>Step 7<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Now copy the URL given in grey underline ( from the above screenshot ) and open that URL in your browser.\u00a0<\/span><\/p>\n<p><img loading=\"lazy\" class=\"wp-image-9713 aligncenter\" src=\"https:\/\/vividreal.co.in\/vividreal1.0\/wp-content\/uploads\/2021\/01\/laravel-img-3-300x171.jpg\" alt=\"\" width=\"586\" height=\"334\" srcset=\"https:\/\/vividreal.co.in\/vividreal1.0\/wp-content\/uploads\/2021\/01\/laravel-img-3-300x171.jpg 300w, https:\/\/vividreal.co.in\/vividreal1.0\/wp-content\/uploads\/2021\/01\/laravel-img-3-768x437.jpg 768w, https:\/\/vividreal.co.in\/vividreal1.0\/wp-content\/uploads\/2021\/01\/laravel-img-3.jpg 924w\" sizes=\"(max-width: 586px) 85vw, 586px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">If this screen is displayed, the installation of laravel has been completed on your system.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Always keep in mind that Laravel has to be served out of the root of the \u201cweb directory\u201d that has been configured for your web server. Never attempt to serve the application out of any subdirectory of \u201cweb directory\u201d. Doing this could cause serious issues and could even expose sensitive contents that are in your application.\u00a0<\/span><\/p>\n<p><span style=\"color: #00ccff;\"><b>Important Steps in Doing Laravel Project\u00a0<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Once you have downloaded and installed the application, let\u2019s get started with a project. If you haven\u2019t created your 1st project during the installation segment, you can create one by executing this command.\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">laravel new todo\u00a0<\/span><\/pre>\n<p><span style=\"color: #00ccff;\"><b>1. Database Configuration<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">A <\/span><a href=\"https:\/\/vividreal.co.in\/vividreal1.0\/what-are-database-management-systems\/\"><span style=\"font-weight: 400;\">database<\/span><\/a><span style=\"font-weight: 400;\"> is required for our application. Therefore it is best if you can configure the database before attempting anything. You can avail of 4 databases that Laravel supports. They are <\/span><span style=\"font-weight: 400;\">MySQL, Postgres, SQLite, SQL Server. You can use the .env file to save different credentials and data.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Laravel has a default .env file at the root where you will find a set of codes.\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">DB_CONNECTION=mysql<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">DB_HOST=127.0.0.1<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">DB_PORT=3306<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">DB_DATABASE=homestead<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">DB_USERNAME=homestead<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">DB_PASSWORD=secret<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">What you need to do is replace the above commands with a single one.\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">DB_CONNECTION=sqlite<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Now create a file &#8211; database.sqlite in your directory<\/span><\/p>\n<p><span style=\"color: #00ccff;\"><b>2. Authentication<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Laravel provides authentication scaffolding, and that means everything that is related to authentication, for example, forget the password, user login registration, two-factor authentication, etc. These things will be pre-built according to your needs and are called Laravel Jetstream. The command to install Jetstream is &#8211;<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">composer require laravel\/jetstream<\/span><\/pre>\n<p><span style=\"color: #00ccff;\"><b>3. Migrations\u00a0<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Laravel is best in providing you with great ways in designing tables, database schema, tables and to migrate it over different systems. In Laravel, one can conveniently rebuild database structures by using the migration files on production or some other system. For that, you have to execute the given command.\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">php artisan make:migration create_tasks_table --create=tasks<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">By doing this, you will find your new migration in &#8211; database\/migration folder. Try adding columns to the tasks table editing the new one.\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">public function up()<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">\u00a0\u00a0{<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">\u00a0 Schema::create('tasks', function (Blueprint $table) {<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">\u00a0 $table-&gt;bigIncrements('id');<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">\u00a0 $table-&gt;string('description');<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">\u00a0 $table-&gt;integer('user_id')-&gt;unsigned()-&gt;index();<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">\u00a0 $table-&gt;timestamps();<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">\u00a0 });<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">The migrate command will now update the changes that you\u2019ve made to the database.\u00a0<\/span><\/p>\n<p><span style=\"color: #00ccff;\"><b>4. Controllers\u00a0<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">These are used in directing the traffic between models and views. They group multiple request handling logic into one class. They receive a logic-based request which is redirected or return the respective data. The given command creates a controller for tasks.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">php artisan make:controller TasksController<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">This creates a Task Controller. You can locate them in app\/Http\/Controllers directory.<\/span><\/p>\n<p><span style=\"color: #00ccff;\"><b>Endnote<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">For beginners and ones without any further experience on web framework might have a slight starting trouble with it. But once you start using it, you are going to love it and probably become addicted to Laravel as it always aims at developing its creative sphere. The word \u2018Web Artisan\u2019 is used by Laravel to point out the hidden creativity in a developer\u2019s mind.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The competition, as well as hype to be on the top of business, is in an accelerating motion these days. Therefore, compromises can never suffice in the case of quality. If you wish to give a mind-blowing face to your website, we can help you <\/span><a href=\"https:\/\/vividreal.co.in\/vividreal1.0\/web-design\/\"><span style=\"font-weight: 400;\">craft a stunning website<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The ones acquainted with the world of coding might be aware of the sores it can give you. Continuously laying them out one by one can be very tiring as well as complicated. It is times like these when you can make use of effective PHP frameworks.\u00a0 Laravel is one such framework that helps web &hellip; <a href=\"https:\/\/vividreal.co.in\/vividreal1.0\/step-by-step-tutorial-to-building-your-first-laravel-application\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Step by Step tutorial to building your first Laravel application&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":9707,"comment_status":"closed","ping_status":"open","sticky":false,"template":"wpb-single-post.php","format":"standard","meta":[],"categories":[3,29,392,141,390,393,391,30,28],"tags":[130,121,18,123,116,107,80,395,396,394,106,101,44,5],"_links":{"self":[{"href":"https:\/\/vividreal.co.in\/vividreal1.0\/wp-json\/wp\/v2\/posts\/9702"}],"collection":[{"href":"https:\/\/vividreal.co.in\/vividreal1.0\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vividreal.co.in\/vividreal1.0\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vividreal.co.in\/vividreal1.0\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vividreal.co.in\/vividreal1.0\/wp-json\/wp\/v2\/comments?post=9702"}],"version-history":[{"count":3,"href":"https:\/\/vividreal.co.in\/vividreal1.0\/wp-json\/wp\/v2\/posts\/9702\/revisions"}],"predecessor-version":[{"id":9714,"href":"https:\/\/vividreal.co.in\/vividreal1.0\/wp-json\/wp\/v2\/posts\/9702\/revisions\/9714"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vividreal.co.in\/vividreal1.0\/wp-json\/wp\/v2\/media\/9707"}],"wp:attachment":[{"href":"https:\/\/vividreal.co.in\/vividreal1.0\/wp-json\/wp\/v2\/media?parent=9702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vividreal.co.in\/vividreal1.0\/wp-json\/wp\/v2\/categories?post=9702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vividreal.co.in\/vividreal1.0\/wp-json\/wp\/v2\/tags?post=9702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}