1. Go to this page and download the library: Download imunew/tymon-jwt-auth library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
imunew / tymon-jwt-auth example snippets
// App\Http\Controllers\Auth\Login
public function __invoke(LoginRequest $request)
{
$credentials = $request->only(['login_id', 'password']);
if (! $token = $this->jwtGuard->attempt($credentials)) {
throw new AuthenticationException();
}
return new AuthResource(new JwtToken($token, $this->factory->getTTL() * 60));
}