PHP code example of polaris / laravel

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

    

polaris / laravel example snippets


// config/auth.php
'guards' => ['polaris' => ['driver' => 'polaris']],

// routes/api.php: your own routes behind Polaris access tokens
Route::middleware('auth:polaris')->get('/me/orders', function (Request $request) {
    $user = $request->user();          // Polaris\Laravel\Auth\PolarisUser
    $user->user->email;                // Polaris\Model\User
    $user->claim('org');               // the active organization from the token
});

// Polaris events are Laravel events
Event::listen(Polaris\Event\UserRegistered::class, fn ($event) => ...);

// The services
app(Polaris\Wiring\Graph::class)->organizations();
sh
composer n polaris:install     # publishes config/polaris.php, writes the migration
php artisan migrate             # the Polaris tables, the permission catalog, the system roles