Class ‘App\Http\Controllers\Student’ not found

In this tutorial I’m going to describe how to solve “Class ‘App\Http\Controllers\Student’ not found” if you got this types of error please follow some easy steps

1step this types of error is showing when you’re not using class name whatever you have define below code as like :-

public function index()
$students = Student::all();

return view(‘students.dashboard’,compact(‘student’));

2nd you have to add your model name above of the StudenController class name

3rd step got your Controller :- StudentController.php

And add model name in the Student Controller class here as like this

use App\Student;

Then refresh your browser and you got solve your errors.

Thanks hopefully it will helpful for you. 👍👍

Tagged : / / / /

$_GET and $_POST Variable in PHP

  • $_GET and $_POST is generally used in the forms to transfer data from one file to another file. Both the variables are kind of same except when we need to keep our data secure we use $_POST and generally in the form we use $_POST.

We will see the explanation by a example:



In this form we have used “get” method and we will see the output below:

As we can see we have used the method “get” in the form and in the output page of testform.php we can see the input given, also with that in the URL box we can see the details which we have provided in the form.html.

If we use “post” method in the form.html we will see the difference below:

As we can see in the URL box there is no such details provided which we can see while using “post” method.

Tagged : / / /

Super Global Variables in PHP

  • What is Super Global Variable?

Super global variable is a variable which can be used in two different files for manipulation.

For example we have a variable “a” in File1.php and we need to print, edit or any manipulation needed to be done in the variable in File2.php then we have to use Super Global Variable as a variable in File1.php.

  • Types of Super Global Variable in PHP:-

– $_GET

– $_POST





  • To see the use of variable $_GET and $_POST follow the link given below:


  • Use of variable $_REQUEST

 $_REQUEST can catch the data which is sent using both POST GET methods whereas $_GET and $_POST can catch the data which is sent by get and post.

  • Use of variable $_SERVER

When we use $_SERVER we can extract extra data from the client when the form is filled. Extra data in a sense we can extract:

– HTTP Connection

– Server Information

– Host Information

– URL Information

We can see it with the example given below:

Now when we insert the data in the form.html we will see the following information:

  • Use of $_COOKIE variable:

Cookies are small file that the server embeds on the user’s computer each time the same computer requests a page with a browser it will send the cookie too. With PHP, we can both create and retrieve cookie values.

To create a cookie we need to run the following command:



setcookie(name, value, expire, path, domain, secure, httponly);

In the syntax only the name parameter is mandatory rest other parameters are optional.

Example for creating a cookie:

  • Use of $_SESSION variable

For session variable refer the link given below:

How Session works in PHP

Tagged : / / / /

How Session works in PHP

Session is a way to store information (in variables) to be used across multiple pages. We can see the architecture of session workflow below:

  • Initially we need to write the command session_start() to start a session.
  • Once we write the command server will check if there is a session available.
  • If there is no server then it will store a cookie in the client machine with the cookie name – PHPSESSID amd it will create a session id of 26 or 32 characters.
  • With that it will also store a file on server (Default Location – C:\xampp\tmp) with session id in the suffix.
  • If there is already a session in the client machine then it will show the variables stored in the session under (C:\xampp\tmp) the server.
  • Once we close the browser all the session ends.


Tagged : /

Using Role Based Authentication, Create Different Users DashBoard


i. Create a project in C:/xamp/htdocs directory by using Git Bash. To create a new project run the following code in Git Bash terminal

composer create-project --prefer-dist laravel/laravel project_name "5.8.*"

ii. Open the project in your code editor like VS Code

Step-1 : To use User Authentication in your project run the following code in code editor terminal

php artisan make:auth

Step-2 : Customize users table to add role field in the table. Go to database/migration/2021_03_20_000000_create_users_table.php and make some changes in users table.

Step-3: Create a Role Model and Migration for Role Table by using the following code:

php artisan make:model Role -m

Step-4: Now customize the Role table and add role_id and role_name field .Go to database/migration/2020_03_20_060108_create_roles_table and make some changes in up() function.

Step-5: Make Relationship between Users and Roles tables through Role Model and User Model.

i. To create relationship make changes in users( ) function in Role.php.

ii. In User.php make a role( ) function and write the following code .

Step-6 :  Create UsersTableSeeder  and RolesTableSeeder file by writting following two command in terminal.

php artisan make:seed UsersTableSeeder
php artisan make:seed RolesTableSeeder 

Step-7: Add Insert function in UsersTableSeeder.php and RolesTableSeeder.php file for Insert data in users table and role table. Add ” use Illuminate\Support\Facades\DB; ” in use area.

i. Go to database/seeds/UsersTableSeeder.php and add the following insert operation in run( ) function :

ii. Go to database/seeds/RolesTableSeeder.php and add the following insert operation in run( ) function :

Step-8 : Create a new Database and link it with the project

i. Run Apache and MySql .

ii. Open phpmyadmin/localhost in your web browser.

iii. Create a new database and set its name.

iv. Set Mysql Server Username ,Password and Database Name in .env file

DB_DATABASE=multipleuser (Your DB name)

v. Migrate it by following command:

php artisan migration

Step-9 : Insert data in the table

php artisan db:seed

Step-10: Create DashboardController for Admin Dashboard work and User Dashboard work.

i. For Admin Dashboard

php artisan make:controller Admin/DashboardController

ii. For User Dashboard

php artisan make:controller User/DashboardController

Step-11 : Make AdminMiddleware and UserMiddleware for Admin and User Authentication work.

i. For AdminMiddleware

php artisan make:middleware AdminMiddleware

ii. For UserMiddleware

php artisan make:middleware UserMiddleware

Step-12: Go to app/Http directory and Use Auth class for Authentication in AdminMiddleware.php and UserMiddleware.php in use section. Implement the following condition in handle( ) function:

i. In AdminMiddleware.php add the following codition:

i. In UserMiddleware.php add the following codition:

Step-12: Go to app/Http/Middleware/RedirectIfAuthenticated.php . Implement Condition for Admin and User Login in RedirectIfAuthenticated.php. and not forget to put ” use Auth; ” in use section.

Step-13: Go to app/Http/Controllers/Auth/ directory and remove = ‘/home’ from protected $redirectTo = ‘/home’; for ResetPasswordController.php and LoginController.php . Implement Condition Login in both php file in __construct( ) function.

i. In LoginController.php

ii. In ResetPasswordController.php

Step-14.A : Use AdminMiddleware and UserMiddleware in Kernel.php File in app/Http/Kernel.php directory

i. For AdminMiddleware

use App\Http\Middleware\AdminMiddleware;

ii. For UserMiddleware

use App\Http\Middleware\UserMiddleware;

Step-14.B : Define AdminMiddleware and UserMiddleware in routeMiddleware

i. For AdminMiddleware

'admin' => AdminMiddleware::class,

ii. For UserMiddleware

use App\Http\Middleware\UserMiddleware;

Tagged : /

Data types in PHP (Array)

In this tutorial we will learn about Array data type in PHP, before that you can see all the data types in PHP given below:

  • String
  • Integer
  • Float
  • Boolean
  • Array
  • Object
  • Null

In PHP we have a special data type where we can assign number of values in single variable using array.

For example: $a = array(10,20,30);

In PHP, there are three types of arrays:

  • Indexed array
  • Associative array
  • Multidimensional array

Indexed array:- PHP indexed array is an array which is represented by an index number by default. All elements of array are represented by an index number which starts from 0. PHP indexed array can store numbers, strings or any object. PHP indexed array is also known as numeric array.



We can also use <pre> tag to print both the key and value in the output.


Another way to write the array in PHP which shows the same output as above:

Tagged : /

Difference between Single quotes ‘ and Double quotes ” in PHP

In this tutorial we will learn about the difference in single quotes and double quotes. Theoretically if we understand then single quotes doesn’t parse the data and double quotes is said to be interpreted.

In simple words if we understand then if we write anything in double quotes then it passes the value in the variable whereas if we write anything inside single quotes then it passes the value as string. We will see it though example to make it clear.


It shows that if we write within the single quotes it doesn’t parse the data and shows the value as string.

  • One more thing we should know that we cannot use Single quotes within single quotes and Double quotes within double quotes.

This is a wrong way of using quotes and we will fetch an error if it is compiled instead of this we can use the below format:

  • To use double quotes within double quotes and single quotes within single quotes then we have to use skip “\”.


Tagged :

What is var_dump in PHP

Var_dump function is used to check the data type of a variable. In PHP we do not have to write the data type while declaring the variable so if we want to print the data type we will use “var_dump” function to see type of data of the variable.

For example:


Here, we can see in the output that it has printed the data type of all the variables which we have used.


Tagged : / /