在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):rydurham/Sentinel开源软件地址(OpenSource Url):https://github.com/rydurham/Sentinel开源编程语言(OpenSource Language):PHP 53.3%开源软件介绍(OpenSource Introduction):Sentinel: Sentry Implementation for LaravelThis package provides an implementation of Sentry 2 for Laravel. By default it uses Bootstrap 3.0, but you can make use of whatever UI you want. It is intended to be a very simple way to get up and running with User access control very quickly. For simple projects you shouldn't need to do much more than drop it in and dial in the configuration. The Important There are two PHP packages named "Sentinel". This is If you are looking for a quick way to get up and running with Releases There are several versions of this package, each intended for different versions of the Laravel framework.
Laravel 5 InstructionsInstall the Package Via Composer: $ composer require rydurham/sentinel Make sure you have configured your application's Database and Mail settings. This package uses "package discovery" to automatically register it's service provider with your application. Register the Middleware in your 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,
]; Publish the Views, Assets, Config files and migrations: php artisan sentinel:publish You can specify a "theme" option to publish the views and assets for a specific theme: php artisan sentinel:publish --theme="foundation" Run Run the Migrations
Be sure to set the appropriate DB connection details in your Note that you may want to remove the php artisan migrate Seed the Database: php artisan db:seed --class=SentinelDatabaseSeeder More details about the default usernames and passwords can be found here. Set a "Home" Route. Sentinel requires that you have a route named 'home' in your // routes/web.php
Route::get('/', function () {
return view('welcome');
})->name('home'); Basic UsageOnce installed and seeded, you can make immediate use of the package via these routes:
Sentinel also provides middleware which you can use to prevent unauthorized access to your application's routes & methods.
// app\Http\Controllers\ExampleController.php
public function __construct()
{
$this->middleware('sentry.member:Admins');
}
Advanced UsageThis package is intended for simple sites but it is possible to integrate into a larger application on a deeper level:
It is not advisable to extend the Sentinel controller classes; you will be better off in the long run creating your own controllers from scratch. Using Sentinel in TestsIf you find yourself in the situation where you want to do tests with user logged in, go to your ``` tests/TestCase.php `` and add this method: 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]);
} You can then start testing your application with user logged in, as such: class ExampleTest extends TestCase
{
/**
* Dashboard functional test example.
*
* @return void
*/
public function testDashboardPage()
{
$this->sentryUserBe('[email protected]');
$this->visit('/dashboard')
->see('dashboard');
}
} Documentation & QuestionsCheck the Wiki for more information about the package:
Any questions about this package should be posted on the package website. LocalizationSentinel has been translated into several other languages, and new translations are always welcome! Check out the Sentinel Page on CrowdIn for more details. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论