PHP code example of tourze / weui-bundle

1. Go to this page and download the library: Download tourze/weui-bundle 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/ */

    

tourze / weui-bundle example snippets




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');
    }
}



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');
    }
}

// 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);