diff --git a/demo/laravel/app/Http/Controllers/DemoController.php b/demo/laravel/app/Http/Controllers/DemoController.php new file mode 100644 index 00000000..0548fe94 --- /dev/null +++ b/demo/laravel/app/Http/Controllers/DemoController.php @@ -0,0 +1,192 @@ +input('type', 'success'); + $message = $request->input('message', 'Notification message'); + $title = $request->input('title'); + $theme = $request->input('theme', 'flasher'); + $adapter = $request->input('adapter', 'flasher'); + $position = $request->input('position', 'top-right'); + $timeout = (int) $request->input('timeout', 5000); + + $flasher = match ($adapter) { + 'toastr' => toastr(), + 'sweetalert' => sweetalert(), + 'noty' => noty(), + 'notyf' => notyf(), + default => flash()->use("theme.{$theme}"), + }; + + $options = [ + 'position' => $position, + 'timeout' => $timeout, + ]; + + if ($adapter === 'toastr') { + $options['positionClass'] = 'toast-' . str_replace('-', '-', $position); + $options['timeOut'] = $timeout; + } elseif ($adapter === 'noty') { + $options['layout'] = match ($position) { + 'top-right' => 'topRight', + 'top-left' => 'topLeft', + 'top-center' => 'topCenter', + 'bottom-right' => 'bottomRight', + 'bottom-left' => 'bottomLeft', + 'bottom-center' => 'bottomCenter', + default => 'topRight', + }; + $options['timeout'] = $timeout; + } elseif ($adapter === 'notyf') { + $positionParts = explode('-', $position); + $options['position'] = [ + 'y' => $positionParts[0] ?? 'top', + 'x' => $positionParts[1] ?? 'right', + ]; + $options['duration'] = $timeout; + } + + if ($title) { + $flasher->{$type}($message, $title, $options); + } else { + $flasher->{$type}($message, $options); + } + + return response()->json(['success' => true]); + } + + public function runExample(Request $request, string $scenario): JsonResponse + { + match ($scenario) { + 'registration' => $this->registrationExample(), + 'login_failed' => $this->loginFailedExample(), + 'validation' => $this->validationExample(), + 'shopping_cart' => $this->shoppingCartExample(), + 'file_upload' => $this->fileUploadExample(), + 'settings' => $this->settingsExample(), + 'payment_success' => $this->paymentSuccessExample(), + 'payment_failed' => $this->paymentFailedExample(), + 'delete_confirm' => $this->deleteConfirmExample(), + 'session_expiring' => $this->sessionExpiringExample(), + default => flash()->info('Example not found'), + }; + + return response()->json(['success' => true]); + } + + private function registrationExample(): void + { + flash()->success('Welcome! Your account has been created.'); + flash()->info('Please check your email to verify your account.'); + } + + private function loginFailedExample(): void + { + flash()->error('Invalid email or password.'); + flash()->info('Forgot your password? Click here to reset.'); + } + + private function validationExample(): void + { + flash()->error('The email field is required.'); + flash()->error('Password must be at least 8 characters.'); + flash()->error('Please accept the terms and conditions.'); + } + + private function shoppingCartExample(): void + { + flash()->success('iPhone 15 Pro added to cart!'); + flash()->warning('Only 2 items left in stock!'); + flash()->info('Add $20 more for free shipping!'); + } + + private function fileUploadExample(): void + { + flash()->success('document.pdf uploaded successfully!'); + flash()->info('File size: 2.4 MB'); + } + + private function settingsExample(): void + { + flash()->success('Settings saved successfully!'); + flash()->info('Some changes may require a page refresh.'); + } + + private function paymentSuccessExample(): void + { + flash()->success('Payment of $149.99 confirmed!'); + flash()->info('Order #12345 - Receipt sent to your email.'); + } + + private function paymentFailedExample(): void + { + flash()->error('Payment declined by your bank.'); + flash()->warning('Please try a different payment method.'); + flash()->info('Your cart has been saved.'); + } + + private function deleteConfirmExample(): void + { + sweetalert() + ->showCancelButton() + ->confirmButtonText('Yes, delete it!') + ->cancelButtonText('Cancel') + ->warning('Are you sure? This cannot be undone.'); + } + + private function sessionExpiringExample(): void + { + flash()->warning('Your session will expire in 5 minutes.'); + flash()->info('Click anywhere to stay logged in.'); + } +} diff --git a/demo/laravel/app/Livewire/ContactForm.php b/demo/laravel/app/Livewire/ContactForm.php new file mode 100644 index 00000000..201780c1 --- /dev/null +++ b/demo/laravel/app/Livewire/ContactForm.php @@ -0,0 +1,36 @@ + 'required|min:2', + 'email' => 'required|email', + 'message' => 'required|min:10', + ]; + + public function submit(): void + { + $this->validate(); + + // Simulate form processing + flash()->success('Message sent successfully!'); + flash()->info('We will respond within 24 hours.'); + + $this->reset(['name', 'email', 'message']); + } + + public function render() + { + return view('livewire.contact-form'); + } +} diff --git a/demo/laravel/app/Livewire/Counter.php b/demo/laravel/app/Livewire/Counter.php index 5ba34d52..72eb9696 100644 --- a/demo/laravel/app/Livewire/Counter.php +++ b/demo/laravel/app/Livewire/Counter.php @@ -1,25 +1,31 @@ success('increment'); - $this->count++; + flash()->success("Count increased to {$this->count}!"); } - public function decrement() + public function decrement(): void { - flash()->info('decrement'); - $this->count--; + flash()->warning("Count decreased to {$this->count}"); + } + + public function reset(): void + { + $this->count = 0; + flash()->info('Counter has been reset.'); } public function render() diff --git a/demo/laravel/app/Livewire/DeleteItem.php b/demo/laravel/app/Livewire/DeleteItem.php new file mode 100644 index 00000000..76cc35f4 --- /dev/null +++ b/demo/laravel/app/Livewire/DeleteItem.php @@ -0,0 +1,41 @@ + 'onConfirmed', + 'sweetalert:denied' => 'onDenied', + ]; + + public function confirmDelete(): void + { + sweetalert() + ->showDenyButton() + ->showCancelButton() + ->confirmButtonText('Yes, delete it!') + ->denyButtonText('Keep it') + ->warning('Are you sure you want to delete this item?'); + } + + public function onConfirmed(array $payload): void + { + // Simulate deletion + flash()->success('Item has been deleted successfully!'); + } + + public function onDenied(array $payload): void + { + flash()->info('The item was kept safe.'); + } + + public function render() + { + return view('livewire.delete-item'); + } +} diff --git a/demo/laravel/resources/views/adapters.blade.php b/demo/laravel/resources/views/adapters.blade.php new file mode 100644 index 00000000..fd402b72 --- /dev/null +++ b/demo/laravel/resources/views/adapters.blade.php @@ -0,0 +1,354 @@ +@extends('layouts.app') + +@section('title', 'Adapters') + +@section('content') +
+

Notification Adapters

+

PHPFlasher supports multiple notification libraries. Choose your favorite!

+
+ +
+ {{-- Flasher (Default) --}} +
+
+
+
+
+
+
+ + + +
+
+

Flasher

+

Default adapter with 17+ themes

+
+
+ +

The default PHPFlasher adapter with beautiful built-in themes. No additional JavaScript libraries required.

+ +
+ + + + +
+ +
+
+ Installation +
+
composer require php-flasher/flasher-laravel
+
+ +
+
+ Usage +
+
flash()->success('Operation completed!');
+
+
+
+
+
+ + {{-- Toastr --}} +
+
+
+
+
+
+
+ + + +
+
+

Toastr

+

Simple, elegant toast notifications

+
+
+ +

Classic toast notifications with smooth animations. One of the most popular notification libraries.

+ +
+ + + + +
+ +
+
+ Installation +
+
composer require php-flasher/flasher-toastr-laravel
+
+ +
+
+ Usage +
+
toastr()->success('Data saved successfully!');
+
+// With options
+toastr()
+    ->closeButton()
+    ->progressBar()
+    ->positionClass('toast-top-right')
+    ->success('Profile updated!');
+
+
+
+
+
+ + {{-- SweetAlert --}} +
+
+
+
+
+
+
+ + + +
+
+

SweetAlert 2

+

Beautiful, responsive, customizable alerts

+
+
+ +

Feature-rich modal dialogs with confirmations, inputs, and beautiful animations. Perfect for important user interactions.

+ +
+ + + + +
+ +
+
+ Installation +
+
composer require php-flasher/flasher-sweetalert-laravel
+
+ +
+
+ Usage +
+
sweetalert()->success('Great job!', 'Success');
+
+// Confirmation dialog
+sweetalert()
+    ->showDenyButton()
+    ->showCancelButton()
+    ->confirmButtonText('Save')
+    ->denyButtonText("Don't save")
+    ->warning('Do you want to save the changes?');
+
+
+
+
+
+ + {{-- Noty --}} +
+
+
+
+
+
+
+ + + +
+
+

Noty

+

Dependency-free notification library

+
+
+ +

A flexible, dependency-free notification library with multiple layouts and themes.

+ +
+ + + + +
+ +
+
+ Installation +
+
composer require php-flasher/flasher-noty-laravel
+
+ +
+
+ Usage +
+
noty()->success('Data saved!');
+
+// With layout options
+noty()
+    ->layout('topCenter')
+    ->timeout(3000)
+    ->progressBar()
+    ->info('Processing your request...');
+
+
+
+
+
+ + {{-- Notyf --}} +
+
+
+
+
+
+
+ + + +
+
+

Notyf

+

Minimalist, responsive notifications

+
+
+ +

A minimalist JavaScript library for toast notifications. Tiny footprint with smooth animations.

+ +
+ + +
+ +
+
+ Installation +
+
composer require php-flasher/flasher-notyf-laravel
+
+ +
+
+ Usage +
+
notyf()->success('Minimal and clean!');
+
+// With options
+notyf()
+    ->position('x', 'right')
+    ->position('y', 'top')
+    ->dismissible(true)
+    ->ripple(true)
+    ->success('File uploaded successfully!');
+
+
+
+
+
+
+ +{{-- Comparison Table --}} +
+
+

Adapter Comparison

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureFlasherToastrSweetAlertNotyNotyf
Toast NotificationsYesYesYesYesYes
Modal DialogsNoNoYesNoNo
ConfirmationsNoNoYesYesNo
Progress BarYesYesYesYesNo
Built-in Themes17+4151
DependenciesNonejQueryNoneNoneNone
+
+
+@endsection diff --git a/demo/laravel/resources/views/examples.blade.php b/demo/laravel/resources/views/examples.blade.php new file mode 100644 index 00000000..64d02223 --- /dev/null +++ b/demo/laravel/resources/views/examples.blade.php @@ -0,0 +1,349 @@ +@extends('layouts.app') + +@section('title', 'Real-World Examples') + +@section('content') +
+

Real-World Examples

+

See how PHPFlasher handles common application scenarios. Click to run each example.

+
+ +
+ {{-- User Registration --}} +
+
+
+
+
+ + + +
+
+

User Registration

+

Account creation flow

+
+
+ +

Simulates a successful user registration with welcome message and email verification notice.

+ + + +
+
PHP
+
flash()->success('Welcome! Your account has been created.');
+flash()->info('Please check your email to verify your account.');
+
+
+
+ + {{-- Login Flow --}} +
+
+
+
+
+ + + +
+
+

Login Failed

+

Authentication error

+
+
+ +

Shows how to display login failure messages with helpful guidance.

+ + + +
+
PHP
+
flash()->error('Invalid email or password.');
+flash()->info('Forgot your password? Click here to reset.');
+
+
+
+ + {{-- Form Validation --}} +
+
+
+
+
+ + + +
+
+

Form Validation

+

Multiple field errors

+
+
+ +

Demonstrates displaying multiple validation errors from a form submission.

+ + + +
+
PHP
+
flash()->error('The email field is required.');
+flash()->error('Password must be at least 8 characters.');
+flash()->error('Please accept the terms and conditions.');
+
+
+
+ + {{-- Shopping Cart --}} +
+
+
+
+
+ + + +
+
+

Shopping Cart

+

E-commerce interactions

+
+
+ +

Shows notifications for adding items to cart with stock warnings and promotions.

+ + + +
+
PHP
+
flash()->success('iPhone 15 Pro added to cart!');
+flash()->warning('Only 2 items left in stock!');
+flash()->info('Add $20 more for free shipping!');
+
+
+
+ + {{-- File Upload --}} +
+
+
+
+
+ + + +
+
+

File Upload

+

Upload progress and status

+
+
+ +

Demonstrates file upload progress with success and additional info.

+ + + +
+
PHP
+
flash()->success('document.pdf uploaded successfully!');
+flash()->info('File size: 2.4 MB');
+
+
+
+ + {{-- Settings Saved --}} +
+
+
+
+
+ + + + +
+
+

Settings Saved

+

Preferences updated

+
+
+ +

Shows settings save confirmation with additional context.

+ + + +
+
PHP
+
flash()->success('Settings saved successfully!');
+flash()->info('Some changes may require a page refresh.');
+
+
+
+ + {{-- Payment Success --}} +
+
+
+
+
+ + + +
+
+

Payment Success

+

Transaction completed

+
+
+ +

Payment confirmation with order details and receipt notification.

+ + + +
+
PHP
+
flash()->success('Payment of $149.99 confirmed!');
+flash()->info('Order #12345 - Receipt sent to your email.');
+
+
+
+ + {{-- Payment Failed --}} +
+
+
+
+
+ + + +
+
+

Payment Failed

+

Transaction declined

+
+
+ +

Payment failure with helpful guidance for resolving the issue.

+ + + +
+
PHP
+
flash()->error('Payment declined by your bank.');
+flash()->warning('Please try a different payment method.');
+flash()->info('Your cart has been saved.');
+
+
+
+ + {{-- Delete Confirmation --}} +
+
+
+
+
+ + + +
+
+

Delete Confirmation

+

SweetAlert dialog

+
+
+ +

Uses SweetAlert for a confirmation dialog before deleting.

+ + + +
+
PHP
+
sweetalert()
+    ->showCancelButton()
+    ->confirmButtonText('Yes, delete it!')
+    ->cancelButtonText('Cancel')
+    ->warning('Are you sure? This cannot be undone.');
+
+
+
+ + {{-- Session Expiring --}} +
+
+
+
+
+ + + +
+
+

Session Expiring

+

Timeout warning

+
+
+ +

Alerts user when their session is about to expire.

+ + + +
+
PHP
+
flash()->warning('Your session will expire in 5 minutes.');
+flash()->info('Click anywhere to stay logged in.');
+
+
+
+
+@endsection diff --git a/demo/laravel/resources/views/home.blade.php b/demo/laravel/resources/views/home.blade.php new file mode 100644 index 00000000..249b4ccd --- /dev/null +++ b/demo/laravel/resources/views/home.blade.php @@ -0,0 +1,197 @@ +@extends('layouts.app') + +@section('title', 'Home') + +@section('content') +{{-- Hero Section --}} +
+

+ Beautiful Flash Notifications +

+

+ PHPFlasher makes it easy to add elegant notifications to your Laravel application. + Try the quick demos below! +

+ + {{-- Quick Demo Buttons --}} +
+ + + + +
+
+ +{{-- Features Grid --}} +
+ {{-- Feature 1: Types --}} + +
+
+
+
+ + + +
+

Notification Types

+
+

Success, error, warning, and info notifications for every use case.

+
+
+ + {{-- Feature 2: Themes --}} + +
+
+
+
+ + + +
+

17+ Themes

+
+

Material, iOS, Slack, Amazon, and many more beautiful themes.

+
+
+ + {{-- Feature 3: Adapters --}} + +
+
+
+
+ + + +
+

Multiple Adapters

+
+

Toastr, SweetAlert, Noty, and Notyf adapters included.

+
+
+ + {{-- Feature 4: Positions --}} + +
+
+
+
+ + + +
+

Flexible Positions

+
+

Place notifications anywhere on the screen.

+
+
+ + {{-- Feature 5: Examples --}} + +
+
+
+
+ + + +
+

Real Examples

+
+

User registration, shopping cart, payments, and more.

+
+
+ + {{-- Feature 6: Playground --}} + +
+
+
+
+ + + + +
+

Interactive Playground

+
+

Build and customize notifications in real-time.

+
+
+
+ +{{-- Quick Start Code --}} +
+
+

Quick Start

+
+
+

Get started with PHPFlasher in seconds. Just install and use!

+ +
+
+ Installation +
+
composer require php-flasher/flasher-laravel
+
+ +
+
+ Usage +
+
// In your controller
+flash()->success('Profile updated successfully!');
+
+// With options
+flash()->success('Welcome back!', [
+    'position' => 'top-right',
+    'timeout' => 5000,
+]);
+
+// Using themes
+flash()->use('theme.material')->info('New feature available!');
+
+
+
+ +{{-- CTA Section --}} +
+

Ready to try PHPFlasher?

+

+ Explore the interactive playground to customize notifications and see the generated code. +

+ + + + + + Open Playground + +
+@endsection diff --git a/demo/laravel/resources/views/layouts/app.blade.php b/demo/laravel/resources/views/layouts/app.blade.php new file mode 100644 index 00000000..b533e95f --- /dev/null +++ b/demo/laravel/resources/views/layouts/app.blade.php @@ -0,0 +1,206 @@ + + + + + + + @yield('title', 'PHPFlasher Demo') - Laravel + + {{-- Tailwind CSS v4 CDN --}} + + + {{-- Prism.js for syntax highlighting --}} + + + + {{-- Custom Tailwind components --}} + + + @stack('styles') + + + {{-- Header --}} +
+
+
+ {{-- Logo --}} + + + + + PHPFlasher + + + + {{-- Desktop Navigation --}} + + + {{-- External Links --}} + + + {{-- Mobile menu button --}} + +
+
+ + {{-- Mobile Navigation --}} + +
+ + {{-- Main Content --}} +
+
+ @yield('content') +
+
+ + {{-- Footer --}} + + + {{-- Scripts --}} + + + + + + + + @stack('scripts') + + diff --git a/demo/laravel/resources/views/livewire.blade.php b/demo/laravel/resources/views/livewire.blade.php new file mode 100644 index 00000000..e034d72d --- /dev/null +++ b/demo/laravel/resources/views/livewire.blade.php @@ -0,0 +1,220 @@ +@extends('layouts.app') + +@section('title', 'Livewire Integration') + +@section('content') +
+

Livewire Integration

+

PHPFlasher works seamlessly with Laravel Livewire. See live examples below.

+
+ +
+ {{-- Counter Component --}} +
+
+
+
+
+ + + +
+
+

Counter Component

+

Simple state management

+
+
+ + @livewire('counter') + +
+
+ app/Livewire/Counter.php +
+
class Counter extends Component
+{
+    public int $count = 0;
+
+    public function increment(): void
+    {
+        $this->count++;
+        flash()->success("Count increased to {$this->count}!");
+    }
+
+    public function decrement(): void
+    {
+        $this->count--;
+        flash()->warning("Count decreased to {$this->count}");
+    }
+
+    public function reset(): void
+    {
+        $this->count = 0;
+        flash()->info('Counter has been reset.');
+    }
+}
+
+
+
+ + {{-- Contact Form Component --}} +
+
+
+
+
+ + + +
+
+

Contact Form

+

Form validation example

+
+
+ + @livewire('contact-form') + +
+
+ app/Livewire/ContactForm.php +
+
class ContactForm extends Component
+{
+    public string $name = '';
+    public string $email = '';
+    public string $message = '';
+
+    protected $rules = [
+        'name' => 'required|min:2',
+        'email' => 'required|email',
+        'message' => 'required|min:10',
+    ];
+
+    public function submit(): void
+    {
+        $this->validate();
+
+        // Process form...
+
+        flash()->success('Message sent successfully!');
+        flash()->info('We will respond within 24 hours.');
+
+        $this->reset(['name', 'email', 'message']);
+    }
+}
+
+
+
+
+ +{{-- SweetAlert Events --}} +
+
+
+
+
+ + + +
+
+

SweetAlert Confirmations

+

Handle dialog responses in Livewire

+
+
+ + @livewire('delete-item') + +
+
+
+ Component +
+
class DeleteItem extends Component
+{
+    protected $listeners = [
+        'sweetalert:confirmed' => 'onConfirmed',
+        'sweetalert:denied' => 'onDenied',
+    ];
+
+    public function confirmDelete(): void
+    {
+        sweetalert()
+            ->showDenyButton()
+            ->showCancelButton()
+            ->confirmButtonText('Yes, delete!')
+            ->denyButtonText('Keep it')
+            ->warning('Delete this item?');
+    }
+
+    public function onConfirmed(array $payload): void
+    {
+        // Delete the item...
+        flash()->success('Item deleted!');
+    }
+
+    public function onDenied(array $payload): void
+    {
+        flash()->info('Item was kept.');
+    }
+}
+
+ +
+
+ Blade Template +
+
<div>
+    <button wire:click="confirmDelete"
+            class="btn btn-danger">
+        Delete Item
+    </button>
+</div>
+
+
+
+
+ +{{-- Installation Guide --}} +
+
+

Livewire Setup

+
+
+
+
+

1. Install PHPFlasher

+
+
Terminal
+
composer require php-flasher/flasher-laravel
+
+
+ +
+

2. Use in Components

+
+
PHP
+
public function save()
+{
+    // Your logic...
+    flash()->success('Saved!');
+}
+
+
+
+ +
+
+ + + +
+

Automatic Livewire Support

+

PHPFlasher automatically detects Livewire requests and handles them appropriately. No additional configuration needed!

+
+
+
+
+
+@endsection diff --git a/demo/laravel/resources/views/livewire/contact-form.blade.php b/demo/laravel/resources/views/livewire/contact-form.blade.php new file mode 100644 index 00000000..4cf0059c --- /dev/null +++ b/demo/laravel/resources/views/livewire/contact-form.blade.php @@ -0,0 +1,41 @@ +
+
+ + + @error('name') +

{{ $message }}

+ @enderror +
+ +
+ + + @error('email') +

{{ $message }}

+ @enderror +
+ +
+ + + @error('message') +

{{ $message }}

+ @enderror +
+ + +
diff --git a/demo/laravel/resources/views/livewire/counter.blade.php b/demo/laravel/resources/views/livewire/counter.blade.php index 2107cc79..d4a69a9d 100644 --- a/demo/laravel/resources/views/livewire/counter.blade.php +++ b/demo/laravel/resources/views/livewire/counter.blade.php @@ -1,7 +1,22 @@ -
-

{{ $count }}

+
+ - +
+ {{ $count }} +
- + +
+ +
+
diff --git a/demo/laravel/resources/views/livewire/delete-item.blade.php b/demo/laravel/resources/views/livewire/delete-item.blade.php new file mode 100644 index 00000000..edcc0c14 --- /dev/null +++ b/demo/laravel/resources/views/livewire/delete-item.blade.php @@ -0,0 +1,21 @@ +
+
+
+ + + +
+
+

Important Document.pdf

+

2.4 MB - Modified today

+
+
+ + +
diff --git a/demo/laravel/resources/views/playground.blade.php b/demo/laravel/resources/views/playground.blade.php new file mode 100644 index 00000000..949e11b5 --- /dev/null +++ b/demo/laravel/resources/views/playground.blade.php @@ -0,0 +1,390 @@ +@extends('layouts.app') + +@section('title', 'Playground') + +@section('content') +
+

Interactive Playground

+

Build and customize notifications in real-time. See the generated PHP code instantly.

+
+ +
+ {{-- Configuration Panel --}} +
+
+

Configuration

+
+
+ {{-- Type --}} +
+ +
+ + + + +
+
+ + {{-- Title --}} +
+ + +
+ + {{-- Message --}} +
+ + +
+ + {{-- Position --}} +
+ + +
+ + {{-- Theme --}} +
+ + +
+ + {{-- Adapter --}} +
+ + +
+ + {{-- Timeout --}} +
+ + +
+ + {{-- Show Button --}} + +
+
+ + {{-- Code Preview --}} +
+
+
+

Generated Code

+ +
+
+
+
+ PHP +
+
flash()->success('Operation completed successfully!');
+
+
+
+ + {{-- Preview Card --}} +
+
+

Preview

+
+
+
+
+ {{-- Preview will be rendered here --}} +
+
+ + + +
+ +

Operation completed successfully!

+
+
+
+
+
+

This is a static preview. Click "Show Notification" to see the real notification.

+
+
+ + {{-- Quick Examples --}} +
+
+

Quick Examples

+
+
+
+ + + + + +
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/demo/laravel/resources/views/positions.blade.php b/demo/laravel/resources/views/positions.blade.php new file mode 100644 index 00000000..1a30790f --- /dev/null +++ b/demo/laravel/resources/views/positions.blade.php @@ -0,0 +1,211 @@ +@extends('layouts.app') + +@section('title', 'Positions') + +@section('content') +
+

Notification Positions

+

Place your notifications anywhere on the screen. Click any position to see it in action.

+
+ +{{-- Interactive Position Grid --}} +
+
+

Click a Position

+
+
+
+ {{-- Visual Browser Frame --}} +
+ {{-- Browser Header --}} +
+
+
+
+
+
your-app.com
+
+
+ + {{-- Position Grid --}} +
+ {{-- Top Left --}} + + + {{-- Top Center --}} + + + {{-- Top Right --}} + + + {{-- Center Left --}} + + + {{-- Center --}} + + + {{-- Center Right --}} + + + {{-- Bottom Left --}} + + + {{-- Bottom Center --}} + + + {{-- Bottom Right --}} + +
+
+
+
+
+ +{{-- Quick Buttons --}} +
+
+

Quick Position Tests

+
+
+
+ + + + + + +
+
+
+ +{{-- Code Examples --}} +
+
+
+

Inline Position

+
+
+

Set the position directly when creating a notification.

+
+
+ PHP +
+
flash()
+    ->option('position', 'top-left')
+    ->success('Profile updated!');
+
+// Or use the fluent method
+flash()
+    ->position('bottom-right')
+    ->info('New message received!');
+
+
+
+ +
+
+

Global Configuration

+
+
+

Set a default position for all notifications in your config file.

+
+
+ config/flasher.php +
+
return [
+    'default' => 'flasher',
+    'options' => [
+        'position' => 'bottom-right',
+    ],
+];
+
+
+
+
+ +{{-- Position Reference --}} +
+
+

Available Positions

+
+
+
+
+

Top Positions

+
    +
  • top-left
  • +
  • top-center
  • +
  • top-right (default)
  • +
+
+
+

Center Positions

+
    +
  • center-left
  • +
  • center
  • +
  • center-right
  • +
+
+
+

Bottom Positions

+
    +
  • bottom-left
  • +
  • bottom-center
  • +
  • bottom-right
  • +
+
+
+
+
+@endsection diff --git a/demo/laravel/resources/views/themes.blade.php b/demo/laravel/resources/views/themes.blade.php new file mode 100644 index 00000000..dc89b4c7 --- /dev/null +++ b/demo/laravel/resources/views/themes.blade.php @@ -0,0 +1,75 @@ +@extends('layouts.app') + +@section('title', 'Themes') + +@section('content') +
+

Theme Gallery

+

Choose from 17+ beautiful themes to match your application's design.

+
+ +{{-- Theme Grid --}} +
+ @php + $themes = [ + ['name' => 'flasher', 'label' => 'Flasher', 'desc' => 'Default theme', 'gradient' => 'from-indigo-500 to-indigo-600'], + ['name' => 'material', 'label' => 'Material', 'desc' => 'Google Material', 'gradient' => 'from-blue-500 to-blue-600'], + ['name' => 'ios', 'label' => 'iOS', 'desc' => 'Apple style', 'gradient' => 'from-slate-600 to-slate-700'], + ['name' => 'slack', 'label' => 'Slack', 'desc' => 'Slack messaging', 'gradient' => 'from-purple-500 to-purple-600'], + ['name' => 'amazon', 'label' => 'Amazon', 'desc' => 'Amazon alerts', 'gradient' => 'from-orange-500 to-orange-600'], + ['name' => 'google', 'label' => 'Google', 'desc' => 'Google notifications', 'gradient' => 'from-red-500 to-yellow-500'], + ['name' => 'facebook', 'label' => 'Facebook', 'desc' => 'Facebook style', 'gradient' => 'from-blue-600 to-blue-700'], + ['name' => 'minimal', 'label' => 'Minimal', 'desc' => 'Ultra clean', 'gradient' => 'from-gray-400 to-gray-500'], + ['name' => 'neon', 'label' => 'Neon', 'desc' => 'Bright & bold', 'gradient' => 'from-pink-500 to-rose-500'], + ['name' => 'emerald', 'label' => 'Emerald', 'desc' => 'Green palette', 'gradient' => 'from-emerald-500 to-green-600'], + ['name' => 'sapphire', 'label' => 'Sapphire', 'desc' => 'Blue elegance', 'gradient' => 'from-blue-500 to-indigo-600'], + ['name' => 'ruby', 'label' => 'Ruby', 'desc' => 'Red accents', 'gradient' => 'from-red-500 to-rose-600'], + ['name' => 'amber', 'label' => 'Amber', 'desc' => 'Warm tones', 'gradient' => 'from-amber-400 to-orange-500'], + ['name' => 'jade', 'label' => 'Jade', 'desc' => 'Soft green', 'gradient' => 'from-teal-500 to-green-600'], + ['name' => 'onyx', 'label' => 'Onyx', 'desc' => 'Dark mode', 'gradient' => 'from-slate-700 to-slate-900'], + ['name' => 'crystal', 'label' => 'Crystal', 'desc' => 'Transparent', 'gradient' => 'from-cyan-400 to-blue-500'], + ['name' => 'aurora', 'label' => 'Aurora', 'desc' => 'Gradient effects', 'gradient' => 'from-green-400 via-blue-500 to-purple-500'], + ]; + @endphp + + @foreach($themes as $theme) +
+
+ {{ substr($theme['label'], 0, 1) }} +
+
+

{{ $theme['label'] }}

+

{{ $theme['desc'] }}

+
+
+ @endforeach +
+ +{{-- Usage Example --}} +
+
+

Using Themes

+
+
+

Apply themes to your notifications with the use() method.

+ +
+
+ PHP +
+
// Use a specific theme
+flash()->use('theme.material')->success('Material design notification!');
+
+// Different themes for different messages
+flash()->use('theme.ios')->info('iOS style notification');
+flash()->use('theme.slack')->warning('Slack style warning');
+flash()->use('theme.amazon')->success('Amazon style success');
+
+// Set default theme in config/flasher.php
+return [
+    'default' => 'theme.material',
+];
+
+
+
+@endsection diff --git a/demo/laravel/resources/views/types.blade.php b/demo/laravel/resources/views/types.blade.php new file mode 100644 index 00000000..8756ed13 --- /dev/null +++ b/demo/laravel/resources/views/types.blade.php @@ -0,0 +1,200 @@ +@extends('layouts.app') + +@section('title', 'Notification Types') + +@section('content') +
+

Notification Types

+

PHPFlasher supports four notification types for different scenarios.

+
+ +
+ {{-- Success --}} +
+
+
+
+
+
+ + + +
+
+

Success

+

Positive feedback

+
+
+
+ +

Use success notifications for completed actions, confirmations, and positive feedback.

+ +
+ + + +
+ +
+
+ PHP +
+
flash()->success('Profile updated successfully!');
+
+// With title
+flash()->success('Welcome aboard!', 'Account Created');
+
+
+
+ + {{-- Error --}} +
+
+
+
+
+
+ + + +
+
+

Error

+

Failures and issues

+
+
+
+ +

Use error notifications for validation failures, server errors, and problems.

+ +
+ + + +
+ +
+
+ PHP +
+
flash()->error('Invalid credentials.');
+
+// With title
+flash()->error('Please try again.', 'Payment Failed');
+
+
+
+ + {{-- Warning --}} +
+
+
+
+
+
+ + + +
+
+

Warning

+

Caution alerts

+
+
+
+ +

Use warning notifications to alert users about potential issues or important notices.

+ +
+ + + +
+ +
+
+ PHP +
+
flash()->warning('Session expiring soon.');
+
+// With title
+flash()->warning('Only 2 left!', 'Low Stock');
+
+
+
+ + {{-- Info --}} +
+
+
+
+
+
+ + + +
+
+

Info

+

Neutral information

+
+
+
+ +

Use info notifications for tips, updates, and general information.

+ +
+ + + +
+ +
+
+ PHP +
+
flash()->info('New version available!');
+
+// With title
+flash()->info('Use shortcuts!', 'Pro Tip');
+
+
+
+
+@endsection diff --git a/demo/laravel/routes/web.php b/demo/laravel/routes/web.php index af9b0907..58edf304 100644 --- a/demo/laravel/routes/web.php +++ b/demo/laravel/routes/web.php @@ -2,26 +2,19 @@ declare(strict_types=1); -use App\Entity\Book; +use App\Http\Controllers\DemoController; use Illuminate\Support\Facades\Route; -Route::get('/', function () { - sweetalert()->timerProgressBar()->success('Your account has been successfully created!'); - noty()->layout('topCenter')->success('Welcome back, John Doe!'); - notyf()->ripple(false)->warning('Your subscription is about to expire in 3 days.'); - toastr()->positionClass('toast-bottom-left')->error('Payment failed. Please try again.'); - flash()->use('flasher')->success('Your profile has been updated successfully.'); - flash()->created(new Book('The Great Gatsby')); - flash()->saved(new Book('1984')); - session()->flash('success', 'Your settings have been saved.'); - return view('welcome'); -})->name('app_home'); +// Main pages +Route::get('/', [DemoController::class, 'home'])->name('home'); +Route::get('/types', [DemoController::class, 'types'])->name('types'); +Route::get('/themes', [DemoController::class, 'themes'])->name('themes'); +Route::get('/adapters', [DemoController::class, 'adapters'])->name('adapters'); +Route::get('/positions', [DemoController::class, 'positions'])->name('positions'); +Route::get('/examples', [DemoController::class, 'examples'])->name('examples'); +Route::get('/playground', [DemoController::class, 'playground'])->name('playground'); +Route::get('/livewire', [DemoController::class, 'livewire'])->name('livewire'); -Route::get('/redirect', function () { - session()->flash('success', 'You have been redirected successfully.'); - return redirect('/destination'); -}); - -Route::get('/destination', function () { - return view('welcome'); -}); +// AJAX endpoints +Route::post('/notify', [DemoController::class, 'notify'])->name('notify'); +Route::post('/example/{scenario}', [DemoController::class, 'runExample'])->name('example.run'); diff --git a/demo/symfony/src/Controller/DemoController.php b/demo/symfony/src/Controller/DemoController.php new file mode 100644 index 00000000..5e795276 --- /dev/null +++ b/demo/symfony/src/Controller/DemoController.php @@ -0,0 +1,200 @@ +render('home.html.twig'); + } + + #[Route('/types', name: 'app_types')] + public function types(): Response + { + return $this->render('types.html.twig'); + } + + #[Route('/themes', name: 'app_themes')] + public function themes(): Response + { + return $this->render('themes.html.twig'); + } + + #[Route('/adapters', name: 'app_adapters')] + public function adapters(): Response + { + return $this->render('adapters.html.twig'); + } + + #[Route('/positions', name: 'app_positions')] + public function positions(): Response + { + return $this->render('positions.html.twig'); + } + + #[Route('/examples', name: 'app_examples')] + public function examples(): Response + { + return $this->render('examples.html.twig'); + } + + #[Route('/playground', name: 'app_playground')] + public function playground(): Response + { + return $this->render('playground.html.twig'); + } + + #[Route('/notify', name: 'app_notify', methods: ['POST'])] + public function notify(Request $request): JsonResponse + { + $data = json_decode($request->getContent(), true); + + $type = $data['type'] ?? 'success'; + $message = $data['message'] ?? 'Notification message'; + $title = $data['title'] ?? null; + $theme = $data['theme'] ?? 'flasher'; + $adapter = $data['adapter'] ?? 'flasher'; + $position = $data['position'] ?? 'top-right'; + $timeout = (int) ($data['timeout'] ?? 5000); + + $flasher = match ($adapter) { + 'toastr' => toastr(), + 'sweetalert' => sweetalert(), + 'noty' => noty(), + 'notyf' => notyf(), + default => flash()->use("theme.{$theme}"), + }; + + $options = [ + 'position' => $position, + 'timeout' => $timeout, + ]; + + if ('toastr' === $adapter) { + $options['positionClass'] = 'toast-'.str_replace('-', '-', $position); + $options['timeOut'] = $timeout; + } elseif ('noty' === $adapter) { + $options['layout'] = match ($position) { + 'top-right' => 'topRight', + 'top-left' => 'topLeft', + 'top-center' => 'topCenter', + 'bottom-right' => 'bottomRight', + 'bottom-left' => 'bottomLeft', + 'bottom-center' => 'bottomCenter', + default => 'topRight', + }; + $options['timeout'] = $timeout; + } elseif ('notyf' === $adapter) { + $positionParts = explode('-', $position); + $options['position'] = [ + 'y' => $positionParts[0] ?? 'top', + 'x' => $positionParts[1] ?? 'right', + ]; + $options['duration'] = $timeout; + } + + if ($title) { + $flasher->{$type}($message, $title, $options); + } else { + $flasher->{$type}($message, $options); + } + + return new JsonResponse(['success' => true]); + } + + #[Route('/example/{scenario}', name: 'app_example', methods: ['POST'])] + public function runExample(string $scenario): JsonResponse + { + match ($scenario) { + 'registration' => $this->registrationExample(), + 'login_failed' => $this->loginFailedExample(), + 'validation' => $this->validationExample(), + 'shopping_cart' => $this->shoppingCartExample(), + 'file_upload' => $this->fileUploadExample(), + 'settings' => $this->settingsExample(), + 'payment_success' => $this->paymentSuccessExample(), + 'payment_failed' => $this->paymentFailedExample(), + 'delete_confirm' => $this->deleteConfirmExample(), + 'session_expiring' => $this->sessionExpiringExample(), + default => flash()->info('Example not found'), + }; + + return new JsonResponse(['success' => true]); + } + + private function registrationExample(): void + { + flash()->success('Welcome! Your account has been created.'); + flash()->info('Please check your email to verify your account.'); + } + + private function loginFailedExample(): void + { + flash()->error('Invalid email or password.'); + flash()->info('Forgot your password? Click here to reset.'); + } + + private function validationExample(): void + { + flash()->error('The email field is required.'); + flash()->error('Password must be at least 8 characters.'); + flash()->error('Please accept the terms and conditions.'); + } + + private function shoppingCartExample(): void + { + flash()->success('iPhone 15 Pro added to cart!'); + flash()->warning('Only 2 items left in stock!'); + flash()->info('Add $20 more for free shipping!'); + } + + private function fileUploadExample(): void + { + flash()->success('document.pdf uploaded successfully!'); + flash()->info('File size: 2.4 MB'); + } + + private function settingsExample(): void + { + flash()->success('Settings saved successfully!'); + flash()->info('Some changes may require a page refresh.'); + } + + private function paymentSuccessExample(): void + { + flash()->success('Payment of $149.99 confirmed!'); + flash()->info('Order #12345 - Receipt sent to your email.'); + } + + private function paymentFailedExample(): void + { + flash()->error('Payment declined by your bank.'); + flash()->warning('Please try a different payment method.'); + flash()->info('Your cart has been saved.'); + } + + private function deleteConfirmExample(): void + { + sweetalert() + ->showCancelButton() + ->confirmButtonText('Yes, delete it!') + ->cancelButtonText('Cancel') + ->warning('Are you sure? This cannot be undone.'); + } + + private function sessionExpiringExample(): void + { + flash()->warning('Your session will expire in 5 minutes.'); + flash()->info('Click anywhere to stay logged in.'); + } +} diff --git a/demo/symfony/src/Controller/ExamplesController.php b/demo/symfony/src/Controller/ExamplesController.php deleted file mode 100644 index 51adfb46..00000000 --- a/demo/symfony/src/Controller/ExamplesController.php +++ /dev/null @@ -1,147 +0,0 @@ -info('Browse through our examples to see PHPFlasher in action!'); - - return $this->render('examples/index.html.twig'); - } - - #[Route('/examples/form', name: 'app_form_example')] - public function formExample(Request $request): Response - { - if ($request->isMethod('POST')) { - $name = $request->request->get('name'); - $email = $request->request->get('email'); - - // Simulate validation - $errors = []; - - if (empty($name)) { - $errors['name'] = 'Name is required'; - } - - if (empty($email)) { - $errors['email'] = 'Email is required'; - } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { - $errors['email'] = 'Invalid email format'; - } - - // Display appropriate notifications - if (empty($errors)) { - flash()->success('Form submitted successfully! Thank you, ' . $name); - } else { - foreach ($errors as $field => $message) { - flash()->error($message); - } - } - } - - return $this->render('examples/form.html.twig'); - } - - #[Route('/examples/ajax', name: 'app_ajax_example')] - public function ajaxExample(): Response - { - return $this->render('examples/ajax.html.twig'); - } - - #[Route('/examples/ajax/process', name: 'app_ajax_process', methods: ['POST'])] - public function ajaxProcess(Request $request): JsonResponse - { - if (!$request->isXmlHttpRequest()) { - return new JsonResponse(['error' => 'AJAX requests only'], 400); - } - - $action = $request->request->get('action'); - $success = mt_rand(0, 10) > 2; // 80% success rate for demo - - if ($success) { - switch ($action) { - case 'save': - flash()->success('Data saved successfully!'); - break; - case 'update': - flash()->success('Record updated successfully!'); - break; - case 'delete': - flash()->info('Item has been deleted.'); - break; - default: - flash()->success('Operation completed successfully!'); - } - - return new JsonResponse(['success' => true]); - } else { - // Simulate errors - flash()->error('An error occurred while processing your request. Please try again.'); - return new JsonResponse(['success' => false], 500); - } - } - - #[Route('/examples/real-world', name: 'app_real_world')] - public function realWorldExamples(): Response - { - return $this->render('examples/real-world.html.twig'); - } - - #[Route('/examples/real-world/user-registration', name: 'app_example_user_registration')] - public function userRegistration(Request $request): Response - { - if ($request->isMethod('POST')) { - // Simulate user registration - $username = $request->request->get('username'); - - if (!empty($username)) { - flash()->option('timeout', 5000) - ->option('showProgressbar', true) - ->success('Registration successful! Welcome, ' . $username . '!'); - - // Send additional notification about email verification - flash()->option('timeout', 8000) - ->info('A verification email has been sent to your inbox.'); - } else { - flash()->error('Username is required.'); - } - } - - return $this->render('examples/user-registration.html.twig'); - } - - #[Route('/examples/real-world/shopping-cart', name: 'app_example_shopping_cart')] - public function shoppingCart(): Response - { - return $this->render('examples/shopping-cart.html.twig'); - } - - #[Route('/examples/real-world/add-to-cart', name: 'app_add_to_cart', methods: ['POST'])] - public function addToCart(Request $request): JsonResponse - { - if (!$request->isXmlHttpRequest()) { - return new JsonResponse(['error' => 'AJAX requests only'], 400); - } - - $productId = $request->request->get('product_id'); - $productName = $request->request->get('product_name', 'Product'); - - // Simulate adding to cart - flash()->option('position', 'bottom-right') - ->option('showCloseButton', true) - ->success($productName . ' added to your cart!'); - - return new JsonResponse(['success' => true]); - } -} diff --git a/demo/symfony/src/Controller/FeaturesController.php b/demo/symfony/src/Controller/FeaturesController.php deleted file mode 100644 index 47c6bb8d..00000000 --- a/demo/symfony/src/Controller/FeaturesController.php +++ /dev/null @@ -1,78 +0,0 @@ -success('Explore the features of PHPFlasher!'); - flash()->option('timeout', 8000) - ->info('Click on the links to see each feature in action.'); - - return $this->render('features/index.html.twig'); - } - - #[Route('/features/types', name: 'app_types')] - public function types(): Response - { - // Demonstrate different notification types - flash()->success('This is a success notification!'); - flash()->info('This is an info notification!'); - flash()->warning('This is a warning notification!'); - flash()->error('This is an error notification!'); - - return $this->render('features/types.html.twig'); - } - - #[Route('/features/positions', name: 'app_positions')] - public function positions(): Response - { - // Notifications with different positions - flash()->option('position', 'top-right')->success('This notification appears in the top-right corner!'); - - return $this->render('features/positions.html.twig'); - } - - #[Route('/features/options', name: 'app_options')] - public function options(): Response - { - // Notification with custom options - flash()->option('timeout', 8000) - ->option('position', 'bottom-center') - ->option('showProgressbar', true) - ->success('This notification has custom options!'); - - return $this->render('features/options.html.twig'); - } - - #[Route('/features/plugins', name: 'app_plugins')] - public function plugins(): Response - { - // Plugin examples - flash()->addSuccess('This shows how PHPFlasher can be extended with plugins!'); - - return $this->render('features/plugins.html.twig'); - } - - #[Route('/features/presets', name: 'app_presets')] - public function presets(): Response - { - // Example of using presets - flash()->preset('profile.updated') - ->success('Your profile has been updated successfully!'); - - flash()->preset('item.deleted') - ->info('The item has been deleted.'); - - return $this->render('features/presets.html.twig'); - } -} diff --git a/demo/symfony/src/Controller/HomeController.php b/demo/symfony/src/Controller/HomeController.php deleted file mode 100644 index 19ee0646..00000000 --- a/demo/symfony/src/Controller/HomeController.php +++ /dev/null @@ -1,82 +0,0 @@ -option('timeout', 10000) - ->info('Welcome to the PHPFlasher Demo! 👋 Explore different features using the navigation.'); - - return $this->render('home/index.html.twig'); - } - - #[Route('/installation', name: 'app_installation')] - public function installation(): Response - { - return $this->render('home/installation.html.twig'); - } - - #[Route('/basic-usage', name: 'app_basic_usage')] - public function basicUsage(): Response - { - // Basic success notification - flash()->success('This is a success notification!'); - - return $this->render('home/basic-usage.html.twig'); - } - - #[Route('/playground', name: 'app_playground')] - public function playground(): Response - { - return $this->render('home/playground.html.twig'); - } - - #[Route('/theme-builder', name: 'app_theme_builder')] - public function themeBuilder(): Response - { - return $this->render('home/theme-builder.html.twig'); - } - - #[Route('/show-notification', name: 'app_show_notification', methods: ['POST'])] - public function showNotification(Request $request): JsonResponse - { - if (!$request->isXmlHttpRequest()) { - return new JsonResponse(['error' => 'AJAX requests only'], 400); - } - - $data = json_decode($request->getContent(), true); - $type = $data['type'] ?? 'info'; - $message = $data['message'] ?? 'This is a notification!'; - - // Create notification based on type - switch ($type) { - case 'success': - flash()->success($message); - break; - case 'error': - flash()->error($message); - break; - case 'warning': - flash()->warning($message); - break; - case 'info': - default: - flash()->info($message); - break; - } - - return new JsonResponse(['status' => 'success']); - } -} diff --git a/demo/symfony/src/Controller/IntegrationController.php b/demo/symfony/src/Controller/IntegrationController.php deleted file mode 100644 index e31bf1fa..00000000 --- a/demo/symfony/src/Controller/IntegrationController.php +++ /dev/null @@ -1,53 +0,0 @@ -option('position', 'bottom-center') - ->success('API request processed successfully!'); - - return $this->render('integration/api.html.twig'); - } - - #[Route('/integration/translation', name: 'app_integration_translation')] - public function translationIntegration(): Response - { - // Example using translation integration - flash()->option('translate', true) - ->success('messages.success.operation_completed'); - - return $this->render('integration/translation.html.twig'); - } - - #[Route('/integration/symfony-flashbag', name: 'app_integration_flashbag')] - public function symfonyFlashbag(): Response - { - // Add message to Symfony flash bag to demonstrate integration - $this->addFlash('success', 'This message was added using Symfony\'s addFlash method!'); - $this->addFlash('error', 'This error was added using Symfony\'s addFlash method!'); - $this->addFlash('warning', 'This warning was added using Symfony\'s addFlash method!'); - - return $this->render('integration/flashbag.html.twig'); - } - - #[Route('/integration/custom-templates', name: 'app_integration_templates')] - public function customTemplates(): Response - { - // Example using custom templates - flash()->option('template', 'custom_template') - ->success('This notification uses a custom template!'); - - return $this->render('integration/custom-templates.html.twig'); - } -} diff --git a/demo/symfony/src/Controller/ThemesController.php b/demo/symfony/src/Controller/ThemesController.php deleted file mode 100644 index ecd9c160..00000000 --- a/demo/symfony/src/Controller/ThemesController.php +++ /dev/null @@ -1,71 +0,0 @@ -success('This is a notification with the default theme!'); - - return $this->render('themes/index.html.twig'); - } - - #[Route('/themes/flasher', name: 'app_theme_flasher')] - public function flasherTheme(): Response - { - // Using the Flasher theme - flash()->option('theme', 'flasher') - ->success('This notification uses the Flasher theme!'); - - return $this->render('themes/flasher.html.twig'); - } - - #[Route('/themes/crystal', name: 'app_theme_crystal')] - public function crystalTheme(): Response - { - // Using the Crystal theme - flash()->option('theme', 'crystal') - ->success('This notification uses the Crystal theme!'); - - return $this->render('themes/crystal.html.twig'); - } - - #[Route('/themes/emerald', name: 'app_theme_emerald')] - public function emeraldTheme(): Response - { - // Using the Emerald theme - flash()->option('theme', 'emerald') - ->success('This notification uses the Emerald theme!'); - - return $this->render('themes/emerald.html.twig'); - } - - #[Route('/themes/sapphire', name: 'app_theme_sapphire')] - public function sapphireTheme(): Response - { - // Using the Sapphire theme - flash()->option('theme', 'sapphire') - ->success('This notification uses the Sapphire theme!'); - - return $this->render('themes/sapphire.html.twig'); - } - - #[Route('/themes/amazon', name: 'app_theme_amazon')] - public function amazonTheme(): Response - { - // Using the Amazon theme - flash()->option('theme', 'amazon') - ->success('This notification uses the Amazon theme!'); - - return $this->render('themes/amazon.html.twig'); - } -} diff --git a/demo/symfony/templates/adapters.html.twig b/demo/symfony/templates/adapters.html.twig new file mode 100644 index 00000000..2e4b639b --- /dev/null +++ b/demo/symfony/templates/adapters.html.twig @@ -0,0 +1,243 @@ +{% extends 'base.html.twig' %} + +{% block title %}Adapters{% endblock %} + +{% block content %} +
+

Notification Adapters

+

PHPFlasher supports multiple notification libraries. Choose your favorite!

+
+ +
+ {# Flasher (Default) #} +
+
+
+
+
+ + + +
+
+

Flasher

+

Default adapter with 17+ themes

+
+
+ +

The default PHPFlasher adapter with beautiful built-in themes. No additional JavaScript libraries required.

+ +
+ + + + +
+ +
+
Installation
+
composer require php-flasher/flasher-symfony
+
+ +
+
Usage
+
flash()->success('Operation completed!');
+
+
+
+ + {# Toastr #} +
+
+
+
+
+ + + +
+
+

Toastr

+

Simple, elegant toast notifications

+
+
+ +

Classic toast notifications with smooth animations. One of the most popular notification libraries.

+ +
+ + + + +
+ +
+
Installation
+
composer require php-flasher/flasher-toastr-symfony
+
+ +
+
Usage
+
toastr()->success('Data saved successfully!');
+
+// With options
+toastr()
+    ->closeButton()
+    ->progressBar()
+    ->positionClass('toast-top-right')
+    ->success('Profile updated!');
+
+
+
+ + {# SweetAlert #} +
+
+
+
+
+ + + +
+
+

SweetAlert 2

+

Beautiful, responsive, customizable alerts

+
+
+ +

Feature-rich modal dialogs with confirmations, inputs, and beautiful animations. Perfect for important user interactions.

+ +
+ + + + +
+ +
+
Installation
+
composer require php-flasher/flasher-sweetalert-symfony
+
+ +
+
Usage
+
sweetalert()->success('Great job!', 'Success');
+
+// Confirmation dialog
+sweetalert()
+    ->showDenyButton()
+    ->showCancelButton()
+    ->confirmButtonText('Save')
+    ->denyButtonText("Don't save")
+    ->warning('Do you want to save the changes?');
+
+
+
+ + {# Noty #} +
+
+
+
+
+ + + +
+
+

Noty

+

Dependency-free notification library

+
+
+ +

A flexible, dependency-free notification library with multiple layouts and themes.

+ +
+ + + + +
+ +
+
Installation
+
composer require php-flasher/flasher-noty-symfony
+
+ +
+
Usage
+
noty()->success('Data saved!');
+
+// With layout options
+noty()
+    ->layout('topCenter')
+    ->timeout(3000)
+    ->progressBar()
+    ->info('Processing your request...');
+
+
+
+ + {# Notyf #} +
+
+
+
+
+ + + +
+
+

Notyf

+

Minimalist, responsive notifications

+
+
+ +

A minimalist JavaScript library for toast notifications. Tiny footprint with smooth animations.

+ +
+ + +
+ +
+
Installation
+
composer require php-flasher/flasher-notyf-symfony
+
+ +
+
Usage
+
notyf()->success('Minimal and clean!');
+
+// With options
+notyf()
+    ->position('x', 'right')
+    ->position('y', 'top')
+    ->dismissible(true)
+    ->ripple(true)
+    ->success('File uploaded successfully!');
+
+
+
+
+{% endblock %} diff --git a/demo/symfony/templates/base.html.twig b/demo/symfony/templates/base.html.twig index a8253e89..2ddbc34d 100644 --- a/demo/symfony/templates/base.html.twig +++ b/demo/symfony/templates/base.html.twig @@ -3,7 +3,7 @@ - {% block title %}PHPFlasher Demo{% endblock %} + {% block title %}PHPFlasher Demo{% endblock %} - Symfony {# Tailwind CSS v4 CDN #} @@ -12,11 +12,11 @@ - {# Custom styles using Tailwind #} + {# Custom Tailwind components #} @@ -54,176 +72,127 @@ {% block stylesheets %}{% endblock %} -
+ {# Header #} +
-
-
-
- - - - PHPFlasher -
- -
- + + {# Mobile Navigation #} +
-