tourze/weui-bundle
最新稳定版本:1.0.2
Composer 安装命令:
composer require tourze/weui-bundle
包简介
A Symfony Bundle for WeUI frontend framework integration
README 文档
README
A Symfony Bundle that provides simple integration with WeUI frontend framework. Main features include:
- Quick rendering of success and error pages with WeUI styling
- Support for custom titles and subtitles
- Control over action button display (
showOpparameter) - Company name configuration via environment variables
- Automatic copyright year generation
- Mobile-optimized responsive design
Installation
Install via Composer:
composer require tourze/weui-bundle
Quick Start
After installation, the bundle will be automatically registered. You can immediately start using the NoticeService in your controllers:
<?php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use WeuiBundle\Service\NoticeService; class DemoController extends AbstractController { #[Route('/success', name: 'app_success')] public function success(NoticeService $noticeService): Response { return $noticeService->weuiSuccess('Operation Successful', 'Data has been processed'); } #[Route('/error', name: 'app_error')] public function error(NoticeService $noticeService): Response { return $noticeService->weuiError('Operation Failed', 'Please try again later'); } }
Basic Usage
<?php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use WeuiBundle\Service\NoticeService; class DemoController extends AbstractController { #[Route('/success', name: 'app_success')] public function success(NoticeService $noticeService): Response { return $noticeService->weuiSuccess('Operation Successful', 'Data has been processed'); } #[Route('/error', name: 'app_error')] public function error(NoticeService $noticeService): Response { return $noticeService->weuiError('Operation Failed', 'Please try again later'); } }
API Reference
NoticeService
weuiSuccess(string $title, string $subTitle = '', bool $showOp = true): Response
Renders a success page with green checkmark icon.
Parameters:
$title(string): Main title text$subTitle(string, optional): Subtitle text below the main title$showOp(bool, optional): Whether to show the "Close Page" button (default: true)
Returns: Response object containing the rendered HTML
weuiError(string $title, string $subTitle = '', bool $showOp = true): Response
Renders an error page with warning icon.
Parameters:
$title(string): Main title text$subTitle(string, optional): Subtitle text below the main title$showOp(bool, optional): Whether to show the "Close Page" button (default: true)
Returns: Response object containing the rendered HTML
Environment Configuration
Set the company name in your .env file, which will be displayed at the bottom of the page:
COMPANY_NAME=Your Company Name
Advanced Usage
Hiding Operation Buttons
If you want to hide the "Close Page" button:
// Success page without close button return $noticeService->weuiSuccess('Success', 'Task completed', false); // Error page without close button return $noticeService->weuiError('Error', 'Something went wrong', false);
Custom Templates
The bundle uses the following templates:
@Weui/success.html.twig- Success page template@Weui/failed.html.twig- Error page template@Weui/base.html.twig- Base template
You can override these templates in your application by creating them in your templates/bundles/WeuiBundle/ directory.
Testing
Run unit tests:
./vendor/bin/phpunit packages/weui-bundle/tests
License
This project is licensed under the MIT License - see the LICENSE file for details.
统计信息
- 总下载量: 3.24k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-12