tourze / weui-bundle
A Symfony Bundle for WeUI frontend framework integration
Installs: 2 913
Dependents: 4
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/weui-bundle
Requires
- nesbot/carbon: ^2.72 || ^3
- symfony/config: ^7.3
- symfony/console: ^7.3
- symfony/dependency-injection: ^7.3
- symfony/event-dispatcher: ^7.3
- symfony/expression-language: ^7.3
- symfony/form: ^7.3
- symfony/framework-bundle: ^7.3
- symfony/http-foundation: ^7.3
- symfony/http-kernel: ^7.3
- symfony/messenger: ^7.3
- symfony/property-access: ^7.3
- symfony/string: ^7.3
- symfony/twig-bundle: ^7.3
- symfony/yaml: ^7.3
- tourze/bundle-dependency: 1.*
- tourze/symfony-dependency-service-loader: 1.0.*
- twig/twig: ^3.21
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- tourze/phpunit-symfony-kernel-test: 1.0.*
- tourze/phpunit-symfony-unit-test: 1.*
This package is auto-updated.
Last update: 2025-11-03 03:47:07 UTC
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.