Installation
Run composer require dywee/ticket-bundle in your Laravel project (note: this is a Symfony bundle, but can be adapted via Symfony Bridge or standalone usage).
Add the bundle to config/app.php under providers:
Dywee\TicketBundle\DyweeTicketBundle::class,
Routing
Publish the bundle’s routes by adding to routes/web.php:
Route::prefix('/')->group(function () {
require __DIR__.'/vendor/dywee/ticket-bundle/Resources/config/routing.yml';
});
(Note: Laravel uses PHP routing; adapt the YAML routes to Laravel syntax if needed.)
First Use Case
Create a ticket via the bundle’s controller (e.g., TicketController):
use Dywee\TicketBundle\Entity\Ticket;
$ticket = new Ticket();
$ticket->setTitle('Test Issue');
$ticket->setDescription('Debugging help needed');
$ticket->setUser($this->getUser()); // Assuming user auth is integrated
$em = $this->getDoctrine()->getManager();
$em->persist($ticket);
$em->flush();
Ticket Creation
Use the Ticket entity (likely in Dywee\TicketBundle\Entity\Ticket) to model support requests:
$ticket = new Ticket();
$ticket->setStatus(Ticket::STATUS_OPEN); // Define constants in the entity
$ticket->setPriority(Ticket::PRIORITY_HIGH);
$ticket->setAssignee($assigneeUser); // Assign to a support agent
CRUD Operations
Leverage the bundle’s controllers (e.g., TicketController) for:
GET /ticketGET /ticket/{id}PATCH /ticket/{id}Integration with DyweeCoreBundle
If using DyweeCoreBundle, extend its admin features:
// Example: Add a ticket admin section
$builder->add('tickets', EntityType::class, [
'class' => Ticket::class,
'choice_label' => 'title',
]);
Event-Driven Extensions
Listen for ticket events (e.g., ticket.created) to trigger notifications:
// In a service provider
$dispatcher->addListener('ticket.created', function ($event) {
// Send email/Slack alert
});
Custom Fields
Extend the Ticket entity to add domain-specific fields:
/**
* @ORM\Column(type="string", nullable=true)
*/
private $customField;
Symfony-Laravel Mismatch
Doctrine and EventDispatcher. For Laravel:
symfony/doctrine-bridge and symfony/event-dispatcher as dependencies.Container if needed (e.g., via Symfony\Bridge\Laravel\ContainerAwareTrait).Routing Conflicts
routes/web.php:
Route::get('/tickets', [TicketController::class, 'index'])->name('ticket.index');
Authentication
symfony/security-bundle or adapt auth logic manually.setUser() method.Entity Manager
EntityManager. In Laravel:
EntityManager to Laravel’s container:
$this->app->singleton('doctrine.orm.entity_manager', function ($app) {
return Doctrine::getManager();
});
Check for Missing Services If controllers fail, ensure the bundle’s services are registered:
php artisan config:clear
composer dump-autoload
Doctrine Events Debug event listeners with:
$dispatcher->addListener('ticket.created', function ($event) {
\Log::debug('Ticket created:', [$event->getTicket()->getId()]);
});
Database Schema
Verify the Ticket entity’s mappings match your database:
php artisan doctrine:schema:validate
Custom Controllers Override bundle controllers by publishing assets:
php artisan vendor:publish --tag=dywee-ticket-views
Then extend src/TicketBundle/Controller/TicketController.php.
API Integration Create a Laravel API resource for tickets:
Route::apiResource('api/tickets', TicketApiController::class);
Search Functionality Add full-text search via Laravel Scout or Algolia:
use Dywee\TicketBundle\Entity\Ticket;
class Ticket extends Model implements ShouldBeSearchable {
public function toSearchableArray() {
return ['title', 'description'];
}
}
How can I help you explore Laravel packages today?