PHP code example of scriptpage / framework

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

    

scriptpage / framework example snippets

     
Route::middleware('auth')->group(function () {

    /**
     * Home routes
     */
    addRoute('web/home');

    /**
     * Users routes
     */
    addRoute('web/users');

});

/**
 * Auth routes
 */
addRoute('api/auth');

/**
 * Users routes
 */
Route::prefix('v1')->group(function () {
        addRoute('api/users');
});

'defaults' => [
    'guard' => 'api',
    'passwords' => 'users',
],

...

'guards' => [
    'api' => [
        'driver' => 'jwt',
        'provider' => 'users',
    ],
],

...

use App\Traits\traitUserJWT;

class User extends Authenticatable implements JWTSubject
{
  ...

  use traitUserJWT;
     
protected $middlewareAliases = [
        ...

        'auth' => \Scriptpage\Middleware\EnsureUserAuth::class,
];
     
protected $middlewareAliases = [
        ...

        'roles' => \Scriptpage\Middleware\EnsureUserHasRole::class,
];
     
use Scriptpage\Traits\traitApiRenderableResponse;

class Handler extends ExceptionHandler
{
        use traitApiRenderableResponse;

        ...

        $this->renderable(function (Exception $e, Request $request) {
                return $this->apiRenderableResponse($e, $request);
        });

'version' => env('APP_VERSION', '1.0.0'),
'project_name' => env('APP_PROJECT_NAME', 'app'),
terminal
php artisan vendor:publish --tag=scriptpage-install
json
    "autoload": {
        "psr-4": {
        ...
        },
        "files": [
            "app/helpers.php"
        ]
terminal
composer or:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
php artisan jwt:secret
php artisan vendor:publish --tag=scriptpage-jwt
terminal
php artisan vendor:publish --tag=scriptpage-role