Installation
composer require caseboxdev/core-bundle
Ensure Symfony CMF is installed (symfony/cmf and its dependencies).
Enable Bundle
Add to config/bundles.php:
Casebox\CoreBundle\CaseboxCoreBundle::class => ['all' => true],
First Use Case
config/routes.yaml:
casebox_core:
resource: "@CaseboxCoreBundle/Resources/config/routing.yml"
prefix: /casebox
Casebox\CoreBundle\Service\CaseboxService in a controller:
use Casebox\CoreBundle\Service\CaseboxService;
class MyController extends AbstractController {
public function __construct(private CaseboxService $casebox) {}
public function handleCase(Request $request) {
$result = $this->casebox->processCase($request->get('case_data'));
return new JsonResponse($result);
}
}
Documentation Refer to Casebox.org for CMF-specific setup (e.g., routing, configuration).
Case Processing Pipeline
CaseboxService to orchestrate workflows:
$this->casebox->validate($data)
->enrich($metadata)
->dispatch($event);
CaseboxEvents::CASE_VALIDATED).Controller Integration
#[Route('/api/cases', methods: ['POST'])]
public function createCase(Request $request, CaseboxService $casebox) {
return $casebox->createCase($request->toArray());
}
Casebox\CoreBundle\Controller\CaseController for custom logic.Service Layer Abstraction
// services.yaml
App\Service\CaseHandler:
arguments:
$casebox: '@casebox.core.service'
Exception Handling
Casebox\CoreBundle\Exception\CaseboxException globally:
// config/packages/exception_listener.yaml
services:
App\EventListener\CaseboxExceptionListener:
tags:
- { name: kernel.event_listener, event: kernel.exception, method: onCaseboxException }
RouteObject for dynamic casebox routes.return $this->render('casebox/template.html.twig', ['case' => $caseData]);
Validator with Casebox\CoreBundle\Validator\Constraints\Casebox.Deprecation Warnings
License Conflicts
Undocumented Dependencies
cmf_routing bundle). Missing setup leads to:
No route found for "GET /casebox"
cmf_routing is enabled and routes are properly loaded.Service Autowiring
# config/services.yaml
Casebox\CoreBundle\Service\CaseboxService: ~
config/packages/dev/debug.yaml:
services:
Casebox\CoreBundle\Debug\CaseboxDebugListener:
tags: ['kernel.event_listener', { event: kernel.request, method: onRequest }]
CaseboxEvents:
// config/packages/monolog.yaml
handlers:
casebox:
type: stream
path: "%kernel.logs_dir%/casebox.log"
level: debug
channels: ["casebox"]
Custom Controllers
Extend Casebox\CoreBundle\Controller\AbstractCaseController:
class CustomCaseController extends AbstractCaseController {
protected function configureRoutes(RouteCollection $collection) {
$collection->add('custom_case', $this->createRoute('/custom'));
}
}
Event Subscribers
Listen to CaseboxEvents::CASE_CREATED:
class CaseCreatedSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return [CaseboxEvents::CASE_CREATED => 'onCaseCreated'];
}
public function onCaseCreated(CaseCreatedEvent $event) {
// Custom logic (e.g., send notification)
}
}
Override Services
Replace CaseboxService with a decorator:
# config/services.yaml
App\Service\DecoratedCaseboxService:
decorates: 'casebox.core.service'
arguments: ['@App\Service\DecoratedCaseboxService.inner']
/casebox as default. Override in routing.yml:
casebox_core:
prefix: /my-custom-prefix
casebox.core.service. Use this alias in DI containers.How can I help you explore Laravel packages today?