Laravel Create REST API Step By Step with Authentication

Laravel Create REST API Step By Step with Authentication

Also Read : first love marriage in the world

Laravel Create REST API Step By Step with Authentication

In this Post We Will Explain About is Laravel Create REST API Step By Step with Authentication With Example and Demo.Welcome on – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Laravel 5 AngularJS backend REST APIExample

In this post we will show you Best way to implement API Authentication – Laravel, hear for API Token Authentication in Laravel 5.2 and 5.3with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Step 1: Create new setup Laravel 5 Application

cd C:\xampp\htdocs

composer create-project laravel/laravel liveautocount

The above sour new simplece code creates a new simple project in htdocs xampp or any server named liveautocount

Step 2: Database migrations

your new simple apps path and changes config file .env file in the Laravel project root

READ :  Vuejs ui Draggable Rotatable AND Resizable Example

DB_PASSWORD=live*****[email protected]#$%^

simple Save the changes

Run studid simple script in MySQL database to create liveautocount database

CREATE DATABASE `liveautocount`;

We will use the PHP artisan command to create a simple table mysql migration file that will create a new table for student records.

php artisan migrate:install

we will get simple messageMigration table created successfully

Run artisan command to create following path migration file

php artisan make:migration create_students_table

we will get studid messageCreated migration: 2018_08_05_088758 _create_students_table

your new simple apps path and changes your new simple apps path and changes /database/migrations/20180803088758 createstudentstableModify the contents to studid

Also Read : tamilblasters, 9kmovie, filmygod, hdhub4u, vegamovies, tamilrockers website link and 1377x proxy.


    public function down() {


Save the changes.Run studid artisan command cmd to run simple the migration

php artisan migrate

READ :  AngularJS File-image Upload ng-file-upload | angular-file-upload

Step 3: Simple REST API

and then now create a laravel controller for our new simple new REST API.

Run studid artisan command

php artisan make:controller Students

we will get studid message Controller created successfully.and then now create an simple model level Eloquent ORM model for our new simple REST API

php artisan make:model Student

we will get studid messageModel created successfully.
and then now add a fillable array to our new simple model your new simple apps path and changes Student.php controller in /app/Student.php

Modify the code to studid

namespace App;
use Illuminate\Database\Eloquent\Model;
class Student extends Model
   protected $fillable = array('studid', 'name', 'useremail','phone_number','man_post');

and then now modify the controller code

your new simple apps path and changes Students.php in /app/Http/Controllers/Students.php

Update the source code to studid

        } else {
            return $this->show($studid);

    public function store(Request $request) {
        $student = new Student;

        $student->name = $request->input('name');
        $student->useremail = $request->input('useremail');
        $student->phone_number = $request->input('phone_number');
        $student->man_post = $request->input('man_post');

        return 'Student record successfully created with studid ' . $student->studid;

    public function show($studid) {
        return Student::find($studid);

    public function update(Request $request, $studid) {
        $student = Student::find($studid);

        $student->name = $request->input('name');
        $student->useremail = $request->input('useremail');
        $student->phone_number = $request->input('phone_number');
        $student->man_post = $request->input('man_post');

        return "Sucess updating user #" . $student->studid;

    public function destroy(Request $request) {
        $student = Student::find($request->input('studid'));


        return "Student record successfully deleted #" . $request->input('studid');

We now need to here path define the routes for our new simple SLIM REST API your new simple apps path and changes
Modify the simple PHP code to studid

READ :  Laravel Insert Multiple Rows Example

Route::get('/', function () {
    return view('index');

Route::get('/api/ver1/students/{studid?}', '[email protected]');
Route::post('/api/ver1/students', '[email protected]');
Route::post('/api/ver1/students/{studid}', '[email protected]');
Route::delete('/api/ver1/students/{studid}', '[email protected]');


I hope you have Got What is Laravel 5 Basic RESTFull API Authentication And how it works.I would Like to have FeadBack From My Blog( readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article( Are Most Always Welcome.