PHP code example of tahsin000 / snag
1. Go to this page and download the library: Download tahsin000/snag 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/ */
tahsin000 / snag example snippets
return [
'enabled' => env('SNAG_ENABLED', true),
'table' => env('SNAG_TABLE', 'feedback'),
'route' => [
'prefix' => '_snag',
'middleware' => ['web', 'throttle:10,1'],
],
'actor_resolver' => \Tahsin000\Snag\Resolvers\DefaultActorResolver::class,
'suggestion_provider' => \Tahsin000\Snag\Suggestions\NullSuggestionProvider::class,
'types' => [
'bug' => 'Something is broken',
'suggestion' => 'I have a suggestion',
'help' => 'I need help',
'general' => 'General feedback',
],
'validation' => [
'message_min' => 3,
'message_max' => 5000,
],
'widget' => [
'position' => 'middle-right',
'theme' => 'auto',
'color' => env('SNAG_COLOR'), // e.g. '#1d4ed8'
'screenshot' => true,
'screenshot_library_url' => null,
'button_text' => 'Feedback',
'title' => 'How can we help?',
// ...all other labels
],
'context' => [
'page_url' => true,
'page_title' => true,
'route_name' => true,
'user_agent' => true,
'viewport' => true,
],
'attachments' => [
'enabled' => true,
'disk' => env('SNAG_DISK', 'local'),
'directory' => 'feedback',
'max_size_kb' => 5120,
'allowed_mimes' => ['jpg', 'jpeg', 'png', 'webp'],
],
];
'screenshot_library_url' => asset('vendor/snag/html2canvas.min.js'),
'middleware' => ['web', 'auth', 'throttle:10,1'],
namespace App\Feedback;
use Illuminate\Http\Request;
use Tahsin000\Snag\Contracts\ActorResolver;
use Tahsin000\Snag\Data\ActorData;
final class ParticipantActorResolver implements ActorResolver
{
public function resolve(Request $request): ?ActorData
{
$participant = $request->user();
if (! $participant) {
return null;
}
return new ActorData(
type: 'participant',
id: (string) $participant->getKey(),
name: $participant->name,
email: $participant->email,
metadata: ['cohort' => $participant->cohort_id],
);
}
}
'actor_resolver' => \App\Feedback\ParticipantActorResolver::class,
$feedback->attachment_disk; // "local"
$feedback->attachment_path; // "feedback/2026/08/9f2c....png"
Storage::disk($feedback->attachment_disk)->get($feedback->attachment_path);
'attachments' => ['enabled' => false, /* ... */],
namespace App\Listeners;
use Tahsin000\Snag\Events\FeedbackSubmitted;
final class NotifyTeam
{
public function handle(FeedbackSubmitted $event): void
{
$feedback = $event->feedback;
// Send a Slack message, create a GitHub issue, send an email...
}
}
$this->app->bind(
\Tahsin000\Snag\Contracts\FeedbackRepository::class,
\App\Feedback\ApiFeedbackRepository::class,
);
bash
php artisan vendor:publish --tag=snag-migrations
php artisan migrate
bash
php artisan vendor:publish --tag=snag-config
bash
php artisan vendor:publish --tag=snag-assets
bash
php artisan vendor:publish --tag=snag-views
widget.blade.php
partials/styles.blade.php
partials/scripts.blade.php
components/form.blade.php
components/launcher.blade.php