PHP code example of bor3y / apitemplate

1. Go to this page and download the library: Download bor3y/apitemplate 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/ */

    

bor3y / apitemplate example snippets

 php
    /**
     * Get the identifier that will be stored in the subject claim of the JWT.
     *
     * @return mixed
     */
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }
    
    /**
     * Return a key value array, containing any custom claims to be added to the JWT.
     *
     * @return array
     */
    public function getJWTCustomClaims()
    {
        return [];
    }
 bash
$ php artisan auth:api:publish
 php
    protected function mapApiRoutes()
    {
        Route::prefix('api')
             ->middleware('api')
             ->namespace($this->namespace . '\API')
              ->as('api.')
             ->group(base_path('routes/api.php'));
    }
 php
    Route::group(['prefix' => 'auth', 'namespace' => 'Auth'], function(){
        Route::group(['middleware' => 'auth.api.public'], function() {
            Route::post('/register', 'AuthController@register')->name('register');
            Route::post('/login', 'AuthController@login')->name('login');
            Route::group(['prefix' => 'password', 'as' => 'password.'], function(){
                Route::post('/forget', 'PasswordController@sendResetLinkEmail')->name('forget');
            });
            
            Route::post('/token/refresh', 'AuthController@refreshToken')->name('refreshToken');
        });
    
        Route::group(['middleware' => 'auth:api'], function(){
            Route::get('/user', ['as' => 'user', 'uses' => 'AuthController@user']);
            Route::post('/logout', ['as' => 'logout', 'uses' => 'AuthController@logout']);
            Route::post('/password/change', 'PasswordController@changePassword')->name('password.change');
        });
    });
 php
    'auth.api.public' => \App\Http\Middleware\AuthorizePublicApiRequests::class