In this Laravel tutorial, we will learn how to install laravel and how to create your first app in laravel for beginners. Now you can learn laravel easily without the need of watching laravel video series or laravel video tutorials. This laravel tutorial will explain all the necessary concepts in easy language for you to learn laravel easily and understand it better.


Laravel is elegant, expressive and flexible PHP framework with extreme focus on clean code and speed which describes itself as “The PHP framework for web artisans”. It is a free and Open source PHP framework created by Taylor Otwell, based on Model View Controller (MVC) architecture.

Creating a web application from scratch can be daunting specially if you are beginner. A simple web application also contains various small and big pieces and creating those pieces every time you are creating a web app can be boring and repetitive and there is no point in reinventing wheels. That’s when Laravel comes to your rescue.

Laravel Tutorial

Laravel framework provides various PHP libraries and helper functions and can help you to focus on more important pieces while providing common functions and logic to speed up the development time and ease up the development.

Initially there is a bit of learning curve specially if you are a beginner and have no experience with any kind of web framework. But believe me, once you flow with it, you will not only love, you will become addicted to it. Laravel aims at creativity in development. It uses the word ‘Web Artisan’ to point out the creative hidden inside the developer’s heart.Result -> Efficient Application with fewer lines and well designed code.

To make it easier for you to learn, I wrote this laravel tutorial with beginner audience in mind. Thus you will find it easy to follow this tutorial for laravel to learn.

What you should know prior to using our Laravel tutorial?

  • HTML/CSS (Duh!)
  • Basic understanding of core PHP
  • Intermediate PHP – This is sort of optional but if you have time, do learn some intermediate concepts like php OOP, abstraction etc.
  • Basic Understanding of MVC Framework
  • Perseverance – Even though it’s easy to learn Laravel, it will test your patience at various interval. At least I had some roadblocks because I knew PHP but I had no knowledge about frameworks. Even while learning the framework, or successfully completing projects, I was having confusion in the basic underlying concepts of the MVC Framework. But I didn’t give up.
  • Passion – C’mon Web development is fun! At least Laravel made it enjoyable. It’s best to enjoy the learning journey.

Installation and Configuration

Laravel offers various ways to install in windows or mac. Best and easiest way to install Laravel is through Composer. Composer is dependency manager for PHP which you can install on your web server.

Prerequisites for installing Laravel 7

Before installing Laravel on your local platform(Localhost) you need to install following programs:

  • Web Server – Apache or nGinx
  • >= PHP 7.2.0
  • Some PHP extensions which might be pre-installed:
    1. BCMath PHP Extension
    2. Ctype PHP Extension
    3. JSON PHP Extension
    4. Mbstring PHP Extension
    5. OpenSSL PHP Extension
    6. PDO PHP Extension
    7. Tokenizer PHP Extension
    8. XML PHP Extension
  • MySQL
  • Composer
  • An IDE will be really helpful for Laravel development. I recommend Sublime 3 or Atom. Both are free to use but Sublime also has PRO version.

Steps to Install Laravel in your Localhost:

Steps for Mac UsersSteps for Windows Users

Steps for Mac users:

  1. Make sure brew is installed.
  2. Run
    brew install composer
  3. Run `composer` to verify whether it installed successfully globally or not as shown below.composer
  4. Now execute this command –
    composer global require “laravel/installer”
  5. Now execute below command to place Composer/vendor/bin directory to  $PATH variable
    echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bash_profile
  6. Once installed, you can create project simply by
    1. Going to desired folder
    2. Execute -- laravel new projectname

Steps for windows users:

  1. Download Composer from and install it.
  2. After installation, you should check whether its installed globally or not. Open command Prompt and enter command “composer” just like shown below. laravel composer windows
  3. Place ~/.composer/vendor/bin directory path in your environment variable PATH
  4. Now execute this command –
    composer global require “laravel/installer”
  5. Once installed, you can create project simply by
    1. Going to desired folder
    2. Shift + right click and select Open command prompt here
    3. Execute --- laravel new projectname

For our example , execute 

Laravel new todo

Building Simple CRUD To-do Application in Laravel : Laravel Tutorial

Best way to learn programming is to practice. Thus, here we will be learning basic concepts of Laravel by developing a simple To-Do Laravel Web App which will do below functions with the help of this laravel tutorial.

  • You can register and login to the web app
  • You can add tasks to your to-do list
  • You can edit as well as delete those tasks
  • Your list is only visible to you thus it implements authentication using email id and password

Exploring Directory Structure

Laravel applications follow the Model-View-Controller architecture design pattern.

laravel mvc structure

Image Source :
  • Models represents the entities in database and helps you to query the database and return the data
  • Views are the pages which will be displayed when accessed the app. View Component is used for the User Interface of the application.
  • Controllers handle user requests, gets required data from the models and pass them to the Views. Controllers acts as an intermediary between Model and View Components to process the business logic and incoming request.

When you installed composer, and created your first Laravel web app, you might have noticed the app folder with different files and folders. I know if you are beginner, you may have a lot of questions about what are these folders for etc. etc.

Let’s understand some





















  • App: This directory is the meat of the application and contains the core code.
    • Console: This directory contains all the custom Artisan commands created using make:command
    • Exceptions: This directory contains the application’s exception handler and is a good place to add custom exception classes to handle different exceptions thrown by your application
    • Http: This directory contains all your controllers, middleware and requests
    • Providers: This directory contains all your service providers for the application. You can know more about service providers here
  • Bootstrap: This directory contains framework bootstrap as well as configuration files. It also contains Cache directory which contains framework generated cache files
  • Config: This directory contains all your application’s configuration files.
  • Database: This directory contains all database migrations and seeds. You can also store SQLite database file here
  • Public: This directory contains assets like images, js files and CSS.
  • Resources: This directory contains all view files and LESS or SASS files. It also contains lang directory to store language files.
  • Routes: This directory contains all routes definitions for the application. php is the file which receives all the requests to your application and here you can redirect the requests to their respective controller methods.
  • Storage: This directory contains blade templates, session files, cache files and other.
  • Tests: This directory contains all the test files
  • Vendor: This directory contains all composer dependencies

Steps to create your first Laravel Application using Laravel tutorial

1) Create Your Project:

If you didn’t create your project in installation section, create now by executing below command:

laravel new todo

2) Configure Database:

We need database for our application, so it’s best to configure our database before doing anything. Laravel supports following 4 databases −

  • MySQL
  • Postgres
  • SQLite
  • SQL Server

For this example, we will use SQLite as it is easy to configure and to use and you don’t have to install anything apart from creating just one empty file.

For other databases, you need to have that database installed in your system and then you can configure accordingly.

Laravel provides config/database.php to config database for production server but Laravel also works with .env file where you can configure your database for your development server. As we are developing this app in localhost we will work with .env file, so

  • Clone .env.example file as .env
    cp .env.example .env
  •  In the file you will find code like below:

    Replace above all 6 lines with below 1 line -- i.e Change the db_connection’s value to sqlite and delete rest of the db lines like below:


    Now in your database directory, create a file – database.sqlite (this is database file with extension .sqlite):

    laravel database sqlite

3) Make Auth:

Laravel 7 comes with pre-built Authentication controllers and configuration. But since this version (Laravel 7), they removed the UI scaffolding to separate package. Thus here, we will install that package using Composer and scaffold the default authentication UI in our app.

Execute Command –

composer require laravel/ui

This package supports different types of front-end libraries/frameworks like Vue, React and also Bootstrap/jQuery. Let's keep our tutorial simply by using Bootstrap/jQuery. Execute below command:

php artisan ui bootstrap --auth

laravel bootstrap ui package

Then run "npm install && npm run dev" to compile your fresh scaffolding.

At this point -- all the configuration are done and we are ready to start building.

4) Migrations:

First step in developing any web application is to design database. Laravel offers great way to design database schema and tables and able to migrate it easily over different systems known as ‘Migrations'.

Migrations are used to create, modify as well as share the application’s database schema. They are used with Laravel’s schema builder to build database schema easily. There are many benefits to create migrations for your database. You can easily rebuild your database structure using migration files on production or any other system.

Don’t worry if you find this explanation confusing. Believe me, you will get your way soon. Just follow along.

Execute below command:

php artisan make:migration create_tasks_table --create=tasks

You will find your newly created migration in /database/migrations folder –

laravel migration

Now let’s add two more column to tasks table by editing the newly created migration file.

public function up()
    Schema::create('tasks', function (Blueprint $table) {

The new column named “description” will store the task description and column named “user_id” will store the id of the user who created the task. We added “ ->unsigned()->index()” after the user_if because it is a foreign key from users table.

Now We finished creating the database schema. To use this schema to create tables in the database, execute below command. Migrate command will update the changes made in schema to the actual database.

php artisan migrate

5) Eloquent Models

Eloquent is Laravel’s ORM which provides simple Active-record Implementation for working with database. Each Database table can have corresponding Eloquent model. Eloquent Model represents database entities and can be used to query data as well as insert and update data to the tables.So, let’s make a model for our tasks table using make:model command.

php artisan make:model Task

This command will create Task model in App directory as shown below.

laravel new model

6) One-to-Many Relationship

Relationships are used to connect tables. Eloquent provides way to connect their models through eloquent relationships. One-to-many relationship means when one model owns multiple amounts of another model.For our example: single user can have many tasks thus one-to-many relationship exists between User table and Task Table. It's very easy to define and use Eloquent relationship and the benefit is, you don’t have to run query at all. Eloquent will bind the models so you will have to only use functions.

Let’s edit Task Model and User Model to create Eloquent Relationship:

Task Model (task.php found in app/task.php):

use App\User;
class Task extends Model
    public function user()
    	return $this->belongsTo(User::class);


User Model (user.php found in app/user.php):

use App\Task;
class User extends Authenticatable
    public function tasks()
    	return $this->hasMany(Task::class);


7) Artisan Tinker -- (Totally Optional)

Laravel provides a command-line interface known as Artisan. Artisan contains various commands and among them, we will now discuss about Tinker. Tinker allows you to interact with your entire Laravel application through console window without the need of accessing web interface. Major benefit of tinker is you can test relationships, debug data and access Eloquent ORM, jobs, tests, events etc. So we will also be using Tinker in our laravel tutorial. Let’s say you registered to the app and created two tasks. Now you check those tasks directly in the console window as below:

$ php artisan tinker

Tinker directly access database so this is a great tool for testing functions as well as the data.

8) Controllers

Controllers are used to direct traffic between views and models and they can group multiple request handling logic into a single class. Thus, generally they receive all the request and based on their logic, they redirect or return respective data.In our example, now we are moving towards front-end, thus we should make controllers through which we can handle requests coming to our application. Execute below command to create controller for tasks:

php artisan make:controller TasksController

This will create taskscontroller and you can find that in app/Http/Controllers directory.

9) Routing

Routing means to accept the request and redirect it to appropriate function.Our app needs five routes which will do following:

  1. Login
  2. Register
  3. Display list of all our tasks
  4. Add new tasks
  5. Delete existing tasks

Login and register are added by default by Laravel so now we need to take care of only three routes.

Before editing routing, fix auth controllers:

Laravel provides ‘/home' page as a logged in welcome page. Thus whenever we log in, it will redirect us to ‘/home‘ route. But in our application, we don't want that. We want to redirect to homepage ‘/‘ and show our tasks list there.
So, edit LoginController.php and RegisterController.php as below:

  • Go to app/Http/Controllers/Auth and open LoginController.php and RegisterController.php and make changes as stated below to both files.
  • On around Line 28/31x, you will find code – “protected $redirectTo = ‘/home’;
  • Change it to “protected $redirectTo = ‘/’;”
  • Save and Close. You are done!

Laravel provides various route files inside ‘/routes‘ folder for various use cases. For example: routing configuration for API will go in ‘/routes/api.php‘ file while routing configuration for our regular web application will go in ‘/routes/web.php‘.

Now, let’s edit web.php. Below is the edited version of file. Make changes accordingly and delete any other. (Means remove the routing for homecontroller and add routes for taskscontroller as shown below):

Route::get('/', '[email protected]');


Route::get('/task','[email protected]');
Route::post('/task','[email protected]');

Route::get('/task/{task}','[email protected]');
Route::post('/task/{task}','[email protected]');

10) Views – Blade Templates

Views are stored in resources/views directory. Views are the front-end of the Laravel application and it separates application logic and the presentation logic. We need to create and design following views:

  1. welcome.blade.php ( Homepage which shows list of tasks if logged in)
  2. add.blade.php (Form which lets you to add new task)
  3. edit.blade.php (Form which lets you to edit any task)

Laravel comes with decent layout which contains navbar called app.blade.php located in Views/layouts directory.

With the help of laravel’s blade engine, you can divide your pages into sub-sections and also can use the laravel’s default navbar section into your new views.

Now, in /resources/views folder, create add.blade.php and edit.blade.php files with the markup given below.


//this will add laravel’s default navbar to your page


//here goes your body content


In welcome.blade.php too, replace all code with the above. We will edit the views later after defining our controller functions using Route-Model Binding concept.

11) Route-Model Bindng

Laravel has lot of amazing features to make web development easy, clean, and less time consuming. Among them, one of the most prominent feature is Route-Model Binding. It is a mechanism to inject a model instance into your routes. It means, you can pass the model object to the routes and also to views through routes which will help you to get the object values easily in the view.Don’t worry if explanation is confusing. With time, you will get to know.

Now let’s add functions handling above routes to TasksController.php. It should look like below.


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Auth;
use App\Task;

class TasksController extends Controller
    public function index()
    	$user = Auth::user();
    	return view('welcome',compact('user'));

    public function add()
    	return view('add');

    public function create(Request $request)
    	$task = new Task();
    	$task->description = $request->description;
    	$task->user_id = Auth::id();
    	return redirect('/'); 

    public function edit(Task $task)

    	if (Auth::check() && Auth::user()->id == $task->user_id)
                return view('edit', compact('task'));
        else {
             return redirect('/');

    public function update(Request $request, Task $task)
    	if(isset($_POST['delete'])) {
    		return redirect('/');
    		$task->description = $request->description;
	    	return redirect('/'); 

Here you can see that I am passing “Task $task” object in the function as well as “Request $request” object with the help of Route-model binding mechanism.

Note: Don't forget to add ‘use Auth;use App\Task;‘ otherwise you will get ‘Class not found error'

12) Editing views

Now we have our controller functions set up and returning the appropriate views with the attached model objects.So now, we need to edit our views so that it displays the form if necessary and needed data using model objects passed through routes.

  1. Display all tasks page

    Open welcome.blade.php and edit it to the following.

    <div class="container">
        <div class="card">
            @if (Auth::check())
                <div class="card-header">Tasks List</div>
                <div class="card-body">
                    <a href="/task" class="btn btn-primary">Add new Task</a>
                    <table class="table mt-4">
                            <th colspan="2">Tasks</th>
                    @foreach($user->tasks as $task)
                                <form action="/task/{{$task->id}}">
                                    <button type="submit" name="edit" class="btn btn-primary">Edit</button>
                                    <button type="submit" name="delete" formmethod="POST" class="btn btn-danger">Delete</button>
                                    {{ csrf_field() }}
                <div class="card-body">
                    <h3>You need to log in. <a href="/login">Click here to login</a></h3>


    Blade template engine allows us to use php inside HTML without enclosing it inside “<?php  ?>”.

    For if else logic, you can use :

           //your html statements
           //your html statements

    That’s what I used in the above code.

    Auth::check() is the Laravel function to check whether user is logged in or not. It gives true or false as return.

  2. Add new task page

    Open add.blade.php and edit as following:

    <div class="container">
                    <h2>Add New Task</h2>
    <form method="POST" action="/task">
        <div class="form-group">
            <textarea name="description" class="form-control"></textarea>  
        <div class="form-group">
            <button type="submit" class="btn btn-primary">Add Task</button>
    {{ csrf_field() }}


    {{  csrf_field() }} is used to generate csrf token and insert in the form. This token is used to verify that the authenticated logged user is the one making request in application. This is the security feature provided by Laravel out of the box.

  3. Edit task page

    Open edit.blade.php and edit as following.

    	<div class="container">
    	<h1>Edit the Task</h1>
    <form method="POST" action="/task/{{ $task->id }}">
    	<div class="form-group">
    		<textarea name="description" class="form-control">{{$task->description }}</textarea>	
    	<div class="form-group">
    		<button type="submit" name="update" class="btn btn-primary">Update task</button>
    {{ csrf_field() }}

    After editing this view, all the pieces are joined so you can now test your application.

    First register and then login and then check if you can create task, edit task and delete task.

13) Run the project in Localhost

To run the project, run this command in the terminal window – php artisan serve. Make sure you are in the root of your application in terminal.

Make sure to read instructions before cloning code from github

github download link

What’s next for this project:

There are still many possible things to include in this laravel project like

  • Form Validation
  • Allowing the user to create multiple list with multiple tasks
  • User Profile
  • And many more ….

I will be updating this laravel tutorial to add more features soon.


Over this long laravel tutorial, we’ve learned how to install Laravel , configure database, basic concepts like routes, models, views and controllers by building your first Laravel application – todo Laravel application.

Hope so this laravel tutorial helped you to understand Laravel’s basic concepts as well as motivated you to learn further. Please comment your views about Laravel as well as about this tutorial and also you can comment with your concerns and issues. I will be glad to help you. Thanks.

Posted by Parth Patel

I am a web developer and a tech blogger. I love to share information about latest tech trends as well as programming knowledge. Currently living in Canada, I want to master web development and then pour my knowledge to my fellow readers.


  1. Awesome Really enjoying your tut


    1. Thanks,
      Do comment here or contact me if any questions


      1. Please, how do I contact you?? Am having some issues.


        1. Hey Jude,
          You can comment here, or contact me at [email protected]


  2. Damuluri Rohini KumarJune 7, 2017 at 1:41 pm

    Hi Parth, please continue this tutorial for next parts on Validation
    Allowing the user to create multiple list with multiple tasks
    User Profile
    And many more ….


  3. Hi, thanks for the post. Following the tutorial I have a error.

    In step 7. Artisan Tinker


    PHP Parse error: syntax error, unexpected ‘class’ (T_CLASS), expecting function (T_FUNCTION) in c:\xampp\htdocs\test\app\User.php on line 30
    syntax error, unexpected ‘class’ (T_CLASS), expecting function (T_FUNCTION)

    Thanks fpr you support


    1. Hey John,
      You are using console window for php artisan tinker, right?

      And other thing is, other than step 7, rest of the steps works fine for you?


  4. Hello Parth,

    I’m having some issues in the User Class.

    I have written it like this:



    1. Hey Tumi,
      Show me the Error or email me the screenshot.
      Meanwhile you can also download the code and compare to check where you might have made mistake.

      Parth Patel


  5. Nilamkumar PatelJune 29, 2017 at 5:52 am

    Hello Parth, I was happy following instructions as beginner to this tutorial. But, I found many issues and finally had to leave it, because I got stuck at many points that is making me going nowhere. Your sqlite database setting instructions are not working, I tried to find out solution and tried some solutions but none of them worked. I configured it to mysql, now it had issues with code and many file names are either cut or may be you missed it, if you go through tutorial once again, you will find that. Finally, I have downloaded your github code and setup in local machine, it is missing whole vendor directory, kindly check that too. Now I am trying to work on it


    1. Hey Nilam,
      Please check your Mail Inbox.
      I sent you the solutions and hopefully cleared your doubts


  6. Nice article, thank you!
    An easy way to try out Laravel in action is to use Laravel 5 Boilerplate / Starter Kit –
    This is also offering Docker container, with this you don’t need a local PHP (composer, node.js, etc.) environment and can start to evaluate Laravel right away.


  7. hey parth.. I got this error what should i do?

    in RouteCollection.php (line 179)


  8. Hey bro, thank you so much for this great introductory tutorial. It served me very well.

    For those who are having trouble following this tut, there are few omission on the tut that will make a little mistake, just like I did. What I did is I looked at the error message and tried to analyze it. I got 2 errors, first is that because our bro Parth didn’t specified properly how to insert the code block in User model, I can’t login and it said model cannot be used. So I just took a peek at the User file in the github and found out how it must be inserted properly. Next is that you have to edit also RegisterController.php inside Controllers\Auth and set “protected $redirectTo = ‘/home’;” to “protected $redirectTo = ‘/’;” so that after registering you will be redirected to a proper route.

    Anyway, i’m running OSX sierra, MAMP Pro and Lara 5.4.. great start for this!


    1. Hey Hatim,
      Thanks for pointing out some mistakes and still giving positive feedback. I am sorry for some mistakes. I have updated the article. Please check and give your valuable feedback.

      Parth Patel


    2. I had an issue with the redirect as well. Got this message on both register page as well as the login page.

      Use of undefined constant ‘ – assumed ‘‘’ (this will throw an Error in a future version of PHP)

      I solved the issue by replacing ‘ with ” as suggested in the error message and it fixed it. Laravel 6 from GitHub as of 10/23/2019

      protected $redirectTo = “/”;


  9. Hey, Thanks for the nice article.

    I have one question…

    When i run this tutorial using SQLITE it runs perfectly. But in Mysql it is giving error that ” SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘test_laravel.tasks’ doesn’t exist”

    Although i have executed `php artisan migrate` command. But the tasks table not created; only ‘migrate’ and ‘users’ tables are created.

    Please help.



    1. Hey Ravi,
      Thanks for trying the tutorial.
      Did you create the database and changed the config details before migrating?
      One of the reasons for this error is when you didn’t create database.
      P.S – Migrator won’t create database automatically. It will just create or edit tables.
      If this is not the solution, then comment or contact at [email protected]
      Thanks …


  10. Hey, Thank you for your quick response.

    Yes i had create the database namely ‘test_laravel”

    Here is my .env file database settings…



    1. Run “php artisan migrate:refresh”

      Tell me if problem is solved or unsolved


  11. I also had tried this command. It gives a message in terminal that

    SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘users’ already exists (SQL: create table `users` (`id` int unsigned not nu
    ll auto_increment primary key, `name` varchar(255) not null, `email` varchar(255) not null, `password` varchar(255) not null, `remember_to
    ken` varchar(100) null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci


    SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘users’ already exists


    1. Great 🙂 . Congrats for solving the issue and thanks for replying back here.
      Keep coding


  12. best tutorial so far I have found on the internet… was very helpful


  13. the tutorial is very useful, one of the best to start.
    just to mention that “database.sqlite” file must be writable , better to add a command to the tutorial text for this.


    1. Thanks for your valuable feedback. I really appreciate it.
      Database.sqlite writable issue I think depends on the systems. If you use in localhost then you don’t need to do that manually. Server configurations are quite different and demand many more configurational changes which will need me to write another specific tutorial on that, thus I didn’t cover here.


  14. Thanks for the nice tutorial. Everything worked great. One question. In another tutorial, they had me open up the config/database.php file and change the default database setting to sqlite there. Is there any big deal to doing it your way versus the one I just described?


    1. There isn’t any difference between both methods.
      .env file is normally used for environment specific values. For example- Let’s say multiple developers are working on same project. The laravel project will be installed on multiple systems with possible different configurations. Thus, they can save their configuration details in .env file which will be different for different instances. Git will by default ignore .env files. But if you set any config in config/database then it will be pushed in git too and will be available to other developers too. So let’s say other developer push their code then the config/database file will get overwritten with his system settings.
      So this is just personal preference.
      Nothing to worry about.


  15. Hello

    i have some fault trying to run the project

    1) Psy Shell v0.8.11 (PHP 7.0.22-0ubuntu0.16.04.1 — cli) by Justin Hileman
    >>> App\User::first()->tasks;
    PHP error: Trying to get property of non-object on line 1

    2) can’t access to login page on the app

    Thanks for help



    1. Hey Alessandro,
      Can you post your code on github and send me the link at [email protected] to have a look.
      I can help easily by looking over your code.

      Parth Patel


  16. Thanks. Great tutorial. Looking forward to more.


    1. Hey Susan,
      Thanks for your generous response.
      Though I am busy, I will try to create more tutorials in future.
      Parth Patel


  17. Hello,
    Great tutorial but i’m getting this error when i try to create a new task, what could be the problem?

    Illuminate \ Database \ QueryException (23000)
    SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: tasks.description (SQL: insert into “tasks” (“description”, “user_id”, “updated_at”, “created_at”) values (, , 2017-10-09 01:49:16, 2017-10-09 01:49:16))


  18. [ErrorException]
    call_user_func_array() expects parameter 1 to be a valid callback, class ‘Illuminate\Auth\SessionGuard’ does not have a method ‘routes’


  19. Thank you, this helped a lot!


  20. Check your “web.php” I found I made a typo in routes, I had:
    Route::get(‘/task’, ‘[email protected]’);
    Route::get(‘/task’, ‘[email protected]’);

    instead of:
    Route::get(‘/task’, ‘[email protected]’);
    Route::post(‘/task’, ‘[email protected]’);


    1. Hey korni,
      Seems like web.php is correct one in github project as well as article’s code snippet. Maybe you made the typo.
      Thanks for checking out our guide though.
      Hope it helped


  21. A very nice and clear tutor to start developing with PHP.
    What are the credentials to login ?


  22. i follow your tutorial and
    when i run my application print this error
    Invalid argument supplied for foreach() (View: E:\xampp\htdocs\todo\resources\views\welcome.blade.php)
    please tell me about this


    1. Can you share your code from welcome.blade.php or compare it directly from our code (either from the article itself or github source code)


  23. this is nice but i want learn more… please provide some more tutorials. so i can be perfect in laravel….


    1. Soon,
      I will be releasing series of laravel tutorials.
      Stay tuned


  24. Nice tutorial, it helps me a lot. Thanks
    Please let me know if there is another tutorial.


  25. Hi,

    Thanks for this great tutorial. I followed these procedures and successfully installed Laravel.
    I am able to register using the login form. But when trying to logon, I had the following error:

    ErrorException (E_ERROR)
    Parse error: syntax error, unexpected ‘return’ (T_RETURN), expecting function (T_FUNCTION) or const (T_CONST) (View: C:\Users\user\todo\resources\views\welcome.blade.php)

    Then it highlights the line with “return”

    class Task extends Model
    return $this->belongsTo(User::class);

    Hope you could help. Thanks!



    1. You forgot to include function. You can’t return directly. Check this –
      class Task extends Model
      public function user()
      return $this->belongsTo(User::class);
      If need explanation , ask me 🙂


      1. Thanks for quick response.

        When adding a task…

        Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
        Class ‘App\Http\Controllers\Task’ not found


        1. I need more context to answer
          but try to find the problem
          have you included “use App\Task;” ?
          The class path is wrong because you haven’t used “use App\Task” which says where to find task model
          I don’t know where you are getting this error but mostly this might be the case


          1. Thank you very much! Forgot to include it..
            This is now working fine already 🙂

            Best regards!

  26. thanks a lot for sharing this valuable tutorial for beginners


  27. Hi Parth,

    I have an error during Registration, it says


    } elseif ($totallyGuarded) {
    throw new MassAssignmentException(sprintf(
    ‘Add [%s] to fillable property to allow mass assignment on [%s].’,
    $key, get_class($this)

    Please help me with this

    Just a begginer here!!


  28. Thanks for making this…very helpful


  29. Mind Bowing Post!………………………………………………………………………… 🙂


  30. hey parth ,,thank you so much for this great introductory tutorial.
    I have problem i got stuck at many points that is making me going nowhere. Your sqlite database setting instructions are not working, I tried to find out solution and tried some solutions but none of them worked


    1. Hey,
      You can contact me at [email protected]. I would be happy to assist you


  31. Great tutorial. Ran into some errors but i was able to debug them.
    Thank you so much for this.


  32. Great Tutorial


  33. This free tutorial is a confidence booster. God should over bless you for planting this seed. It obviously touched so many lives and mine too. Keep up the God work


  34. Thank so much! The application ran smoothly.


  35. Francisco Vieira SouzaApril 23, 2019 at 1:54 pm

    Hey man, thanks for the nice tutorial, any chance you go further and make the rest of it?


  36. Please share Windows command for crud laravel 6


    1. Hey Param,
      I have updated the article and shared installation steps for windows users too. If you have any other questions, I am one email away.

      Parth Patel


  37. hi, i copied your code and there were no problems at all with the coding structure and stufff, no errors etc. However, i tried to get it running using php artisan serve, but nothing shows up on my browser. it only says something about server started at the command prompt. how can i resolve this issue?


    1. What error does it show on browser? Have you done composer install ?


  38. Thanks. Great tutorial. Please more,more,more … 🙂


  39. Hi Parth Patel,

    Coming from symfony, need a quick intro into Laravel, this was perfect thank you.
    At the moment I do prefer how doctrine keeps everything in one model with annotation. All your joins etc and your get() set() function can be customised.
    Just time in the saddle, looking forward to learning Laravel and thank you for this clean intro




  40. clear and great explanation I ‘m so glad to came across this article , Thank you


  41. Very nice post for beginner of Laravel learner.


  42. thanks for this excellent tutorial I had 2 issues that I was able to correct the first is that it could not find the sqlite database. I corrected this by removing the ; from the php.ini. The other error was that I was not using ” in the redirect. These are my fault so thanks again for the excellent tutorial. Please post additional laravel 7 tutorials because I find it easier to read through the tutorial than to view a video. Thanks again,


    1. Hey Alexander,
      Thanks for your feedback. I am glad I could help. I am planning to post more helpful and in-depth articles soon. Stay connected. Also, if you need any help with programming, you can contact me.


  43. Kamal al mounajedApril 10, 2020 at 12:01 am

    clear and great explanation I ‘m so glad to came across this article , Thank you
    i followed the instruction step by step and every thing works fine

    i had to make these changes to make every thing works
    1- file TasksController.php i replace use Auth; with use IlluminateSupportFacadesAuth;
    2- in the file RouteServiceProvider i change public const HOME = ‘/home’; to public const HOME = ‘/’;
    3- in the file web.php i replace use Auth; with use IlluminateSupportFacadesAuth;

    if i run the application in the local host without php artisan serv
    i can’t go to other pages

    in serv

    in xampp


    i get
    Object not found!
    The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

    If you think this is a server error, please contact the webmaster.

    Error 404
    Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.2.26

    what should i do


    1. Hey Kamal,
      Can you please confirm whether above errors occur when you run using “php artisan server”?
      Configuring localhost apache for laravel is quite tricky and not worth the trouble. For Simple applications, “php artisan serve” is more than enough while for robust applications, Laravel Homestead (Vagrant) is highly recommended.
      In my localhost, the application is working without the need to do above changes ~ replacing use Auth; with use IlluminateSupportFacadesAuth;
      Let me know how that works out for you.

      Glad my article was helpful,


  44. error when run http://localhost:8000/loginse of undefined constant ‘ – assumed ‘‘’ (this will throw an Error in a future version of PHP)



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.