PHP code example of rydurham / sentinel

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

    

rydurham / sentinel example snippets


protected $routeMiddleware = [
    // ..
    'sentry.auth' => \Sentinel\Middleware\SentryAuth::class,
    'sentry.admin' => \Sentinel\Middleware\SentryAdminAccess::class,
    'sentry.member' => \Sentinel\Middleware\SentryMember::class,
    'sentry.guest' => \Sentinel\Middleware\SentryGuest::class,
];
 artisan sentinel:publish --list

// routes/web.php
Route::get('/', function () {
    return view('welcome');
})->name('home');

// app\Http\Controllers\ExampleController.php
public function __construct()
{
    $this->middleware('sentry.member:Admins');
}


    use Illuminate\Events\Dispatcher;

   /**
     * Login to sentry for Testing purpose
     * @param  $email
     * @return void
     */
    public function sentryUserBe($email='[email protected]')
    {
        $user = \Sentry::findUserByLogin($email);
        \Sentry::login($user);
        (new dispatcher)->dispatch('sentinel.user.login', ['user' => $user]);
    }

class ExampleTest extends TestCase
{
    /**
     * Dashboard functional test example.
     *
     * @return void
     */
    public function testDashboardPage()
    {
        $this->sentryUserBe('[email protected]');
        $this->visit('/dashboard')
             ->see('dashboard');
    }
}
app/Http/Kernel.php
shell
php artisan sentinel:publish
shell
php artisan sentinel:publish --theme="foundation"
shell
php artisan migrate
shell
php artisan db:seed --class=SentinelDatabaseSeeder
routes.php