iankibet/laravel-streamline
最新稳定版本:1.2.0
Composer 安装命令:
composer require iankibet/laravel-streamline
包简介
A package that allows front end to interact with backend without the need for routes and controller
README 文档
README
Overview
A laravel package that makes it possible to bind service/streamline class to frontend vue component
Installation
composer require iankibet/laravel-streamline
Config
Streamline uses a config file to determine the namespace of the service/streamline classes. To publish the config file, run the following command:
php artisan vendor:publish --tag=laravel-streamline
Here is how the config file looks like:
return [ 'class_namespace' => 'App\\Streams', 'class_postfix' => 'Stream', 'route' => 'api/streamline', 'middleware' => ['auth:sanctum'], 'guest_streams' => [ 'auth/auth' ] ];
Modify the values to suit your application.
class_namespace
This is the namespace where the stream classes are located. The default value is App\Streams.
class_postfix
This is the postfix that is added to the stream class to easily identify streamline . The default value is Stream. For example, if the Stream name is User, the stream class will be UsersStream.
guest_streams
This is an array of streams that can be accessed without authentication. The default value is ['auth/auth'].
Implementation
To use, first import the Stream and extend it in yur class as show below:
use iankibet\Streamline\Stream; class TasksStreamline extends Stream { }
Validation
To validate, use Validate attribute as shown below:
use iankibet\Streamline\Stream; use iankibet\Streamline\Validate; // in the method #[Validate([ 'name' => 'required|string', 'description' => 'required|string' ])] public function addTask() { // code here $data = $this->only(['name', 'description']); } }
Permission Authorization
To authorize, use Permission attribute as shown below:
use iankibet\Streamline\Component; use iankibet\Streamline\Permission; // in the method #[Permission('create-task')] public function addTask() { // code here $data = $this->only(['name', 'description']); } }
Create a new Stream
To create a new Stream, use the following command:
php artisan streamline:stream TasksStream
This will create a new Stream class in the app/Streams directory.
Testing the Stream
To test the Stream, use the following command: Replace TasksStream with the name of your streams.
php artisan streamline:test TasksStream
统计信息
- 总下载量: 3.24k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-21