1. Go to this page and download the library: Download ttlphp/laravel-crbac 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/ */
namespace App\Http\Controllers;
use Laravel\Crbac\Controllers\Controller;
/**
* 追加该控制器全部中间件
* @middleware(auth)
*/
class TestController extends Controller {
/**
* @methods(GET)
* @middleware(auth)
*/
public function testMenu(){
}
/**
* @methods(GET, POST)
*/
public function testItem(){
}
}
namespace App\Http\Controllers;
use Laravel\Crbac\Controllers\Controller;
use Laravel\Crbac\Annotation\Request\Methods;
use Laravel\Crbac\Annotation\Request\Middleware;
#[@Middleware('auth')]
class TestController extends Controller {
#[Methods(Methods::GET)]
#[@Middleware('auth')]
public function testMenu(){
}
#[Methods(Methods::GET, Methods::POST)]
public function testItem(){
}
}
// 使用注解:@powerMenu(参数) 和 @powerItem(参数)。
namespace App\Http\Controllers;
use Laravel\Crbac\Controllers\Controller;
class TestController extends Controller {
/**
* @powerMenu('测试菜单')
*/
public function testMenu(){
}
/**
* @powerItem('测试权限项')
*/
public function testItem(){
}
}
namespace App\Http\Controllers;
use Laravel\Crbac\Annotation\PowerMenu;
use Laravel\Crbac\Annotation\PowerItem;
use Laravel\Crbac\Controllers\Controller;
use Laravel\Crbac\Annotation\Request\Methods;
use Laravel\Crbac\Annotation\Request\Middleware;
class TestController extends Controller {
#[PowerMenu('测试菜单')]
public function testMenu(){
}
#[PowerItem('测试权限项')]
public function testItem(){
}
}
namespace App\Http\Controllers;
use Laravel\Crbac\Controllers\Controller;
class TestController extends Controller {
/**
* @methods(POST)
*/
public function test(){
$file = $this->getUploadFile('file'); // 分割与非分割上传均可
$dir = public_path('static/images');
$file->move($dir, $filename);
return prompt(['url' => '/static/images/' . $file->getBasename()]);
}
}
crbac_config($key, $default);
shell
php artisan crbac:table
shell
php artisan crbac:lang
shell
php artisan crbac:power
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.