larexsetch/laravel-transactional
最新稳定版本:1.0.0
Composer 安装命令:
composer require larexsetch/laravel-transactional
包简介
Decorates method as transactional
README 文档
README
Decorates method as transactional
Usage
Require dependency
composer require larexsetch/laravel-transactional
Append middleware
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
$middleware->append(\Larexsetch\LaravelTransactional\Http\Middleware\TransactionalMiddleware::class);
})
->create();
Add attribute in controller
readonly class NoteController
{
public function __construct(
private SomeService $service
) {}
#[Transactional]
public function index($request): JsonResponse
{
$this->service->doOne();
$this->service->doAnother();
// ... more actions
return response()->json(['ok' => true]);
}
}
Run tests
export DOCKER_TEST_TAG=phpunit:latest docker build -t $DOCKER_TEST_TAG -f tests/Dockerfile . docker run --rm -v ./:/opt/project $DOCKER_TEST_TAG /usr/local/bin/phpunit --configuration phpunit.xml tests/Http/Middleware
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-28