Implementation of Laravel authentication is very simple. All you need is to execute
php artisan make:auth
, then it generates the authentication functions already.
However, I would like to know what changes have been made in order to modify it and to fit into my own code. There is a way to do so: git version control.
All I have to do is to commit everything before making authentication and show the difference after. It will show the changes have been made.
Let’s start a Laravel project called “Laravel_test”.
Start the test project
> laravel new laravel_test
:
:
> cd laravel_test
Start git control
git init
git add .
git commit -m "Initial Commit"
Make Authentication
Now execute the make:auth
command.
> php artisan make:auth
Authentication scaffolding generated successfully.
Show the files changed and added:
> git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: routes/web.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
app/Http/Controllers/HomeController.php
resources/views/auth/
resources/views/home.blade.php
resources/views/layouts/
- File changed:
routes/web.php
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
- Files added:
- app/Http/Controllers/HomeController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}
-
resources/views/auth/
resources/views/auth/passwords/email.blade.php
resources/views/auth/passwords/reset.blade.php
resources/views/auth/login.blade.php
resources/views/auth/register.blade.php
resources/views/auth/verify.blade.php -
resources/views/layouts/app.blade.php
-
resources/views/home.blade.php
Remove the Laravel authentication
The changes havn’t been commited yet at this stage. If we need to go back to the original status (before make:auth
), just run the git
command:
- Revert changes to modified files.
> git reset --hard
HEAD is now at 096f938 Add README.txt
The routes/web.php
has been changed to the original status.
- Remove all untracked files and directories.
(-f
isforce
,-d
isremove directories
)
> git clean -fd
Removing app/Http/Controllers/HomeController.php
Removing resources/views/auth/
Removing resources/views/home.blade.php
Removing resources/views/layouts/
This comment has been removed by the author.
ReplyDelete