1. Go to this page and download the library: Download alizharb/flare 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/ */
alizharb / flare example snippets
// Simple, elegant API
Flare::success('Profile updated successfully!');
// Full control when you need it
Flare::warning(
text: 'Session expires in 5 minutes',
heading: 'Warning',
duration: 10000,
position: 'top center'
);
use AlizHarb\Flare\Facades\Flare;
class UserController extends Controller
{
public function store(Request $request)
{
User::create($request->validated());
Flare::success('User created successfully!');
return redirect()->route('users.index');
}
}
use Livewire\Component;
use AlizHarb\Flare\Concerns\WithFlare;
class CreatePost extends Component
{
use WithFlare;
public function save()
{
Post::create($this->validate());
$this->flareSuccess('Post published!', 'Success');
}
}
class ContactForm extends Component
{
use WithFlare;
public function submit()
{
$this->validate([...]);
// Send email...
$this->flareSuccess(
text: "Thank you! We'll get back to you soon.",
heading: 'Message Sent',
duration: 7000
);
}
}
public function destroy(Post $post)
{
$post->delete();
Flare::danger(
text: 'Post has been permanently deleted',
heading: 'Deleted',
duration: 4000
);
return redirect()->route('posts.index');
}