Skip to content

Instantly share code, notes, and snippets.

View farindra's full-sized avatar

Farindra farindra

View GitHub Profile
@farindra
farindra / movie.php
Last active April 12, 2021 22:52
Lumen Jwtauth Part 1 - Movie Route
<?php
/* movie group */
$router->group(['prefix' => 'movie', 'as' => 'movie'], function () use ($router) {
/* all movies */
$router->get('/all', [ 'as' => 'all', 'uses' => 'MovieController@all']);
/* show movies by id */
$router->get('/{id}', [ 'as' => 'show', 'uses' => 'MovieController@show']);
@farindra
farindra / AuthController.php
Last active April 12, 2021 22:42
Lumen Jwtauth Part 1 - Auth Controller
<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class AuthController extends Controller
@farindra
farindra / UserRegistration.php
Last active April 7, 2021 22:37
Lumen Jwtauth Part 1 - Test User Registration
<?php
use Laravel\Lumen\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Artisan;
use app\Libraries\Core;
class UserRegistrationTest extends TestCase
{
use DatabaseMigrations;
@farindra
farindra / EndpointTest.php
Last active April 11, 2021 10:27
Lumen Jwtauth Part 1 - Test Endpoint
<?php
use Illuminate\Support\Facades\Config;
class EndpointTest extends TestCase
{
/**
* unknown route shoult return 404
*
* @return void
@farindra
farindra / phpunit.xml
Last active April 4, 2021 23:59
Lumen Jwtauth Part 1 - phpunit config
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
testdox="true"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
@farindra
farindra / user.php
Last active April 12, 2021 22:32
Lumen user route
<?php
/* registration */
$router->post('/register', [ 'as' => 'register', 'uses' => 'AuthController@register']);
/* login */
$router->post('/login', [ 'as' => 'login', 'uses' => 'AuthController@login']);
/* restrict route */
$router->group(['middleware' => 'auth'], function () use ($router) {
@farindra
farindra / web.php
Last active April 11, 2021 10:22
Lumen Jwtauth Part 1 - Route web default
<?php
use App\Libraries\Core;
/* v1 group */
$router->group(['prefix' => 'v1', 'as' => 'v1'], function () use ($router) {
Core::renderRoutes('v1', $router);
});
@farindra
farindra / common.php
Last active April 11, 2021 10:23
Lumen Jwtauth Part 1 - Route Common
<?php
/* test response */
$router->get('/ping', [ 'as' => 'ping', function () use ($router) {
return 'pong';
}]);
/* lumen version */
$router->get('/version', [ 'as' => 'version', function () use ($router) {
return $router->app->version();
@farindra
farindra / BaseController.php
Last active April 1, 2021 23:08
Lumen base controller
<?php
namespace app\Http\Controllers;
use App\Http\Controllers\Controller;
use app\Libraries\Core;
use Illuminate\Http\Request;
class BaseController extends Controller
{
/**
@farindra
farindra / Core.php
Last active April 2, 2021 01:02
Lumen app core library
<?php
namespace app\Libraries;
use Illuminate\Support\Facades\Log;
class Core
{
/**
* Custom Response HTTP
*