1. Go to this page and download the library: Download ozankurt/laravel-security 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/ */
ozankurt / laravel-security example snippets
Route::group(['middleware' => 'firewall.all'], function () {
Route::get('/', 'HomeController@index');
});
Route::group(['middleware' => 'firewall.whitelist'], function () {
Route::get('/admin', 'AdminController@index');
});
Route::group(['middleware' => 'firewall.url'], function () {
Route::get('/admin', 'AdminController@index');
});
use App\Models\User;
use Illuminate\Support\Facades\Gate;
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Gate::define('viewSecurityDashboard', function (?User $user) {
return $user?->id === 1;
});
// ...
}
bash
php artisan vendor:publish --tag=security
bash
php artisan migrate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.