Installation
composer require c975l/events-bundle
Verify c975L/EventsBundle appears in composer.json under require.
Enable the Bundle
Add to config/bundles.php (Laravel 5.5+):
return [
// ...
c975L\EventsBundle\c975LEventsBundle::class => ['all' => true],
];
Publish Assets & Config Run:
php artisan vendor:publish --provider="c975L\EventsBundle\c975LEventsBundle" --tag=config
php artisan vendor:publish --provider="c975L\EventsBundle\c975LEventsBundle" --tag=assets
This generates:
config/events.php (adjust dependencies like TinyMCE, Bootstrap DatePicker).public/bundles/c975levents/.Database Migration Run:
php artisan migrate
The bundle creates an events table (check database/migrations/ for schema).
First Event Use Tinker or a controller to create an event:
use c975L\EventsBundle\Entity\Event;
$event = new Event();
$event->setTitle('Laravel Meetup')
->setDescription('Join us for Laravel tips!')
->setStartDate(new \DateTime('2023-12-15 18:00:00'))
->setEndDate(new \DateTime('2023-12-15 20:00:00'))
->setLocation('City Hall');
$entityManager->persist($event);
$entityManager->flush();
Display an Event In a Twig template (if using Laravel Mix with Twig bridge):
{% include '@c975LEvents/event/show.html.twig' with {
'event': event
} %}
c975L\EventsBundle\Controller\EventController or use its methods directly.
Example:
use c975L\EventsBundle\Controller\EventController;
class MyEventController extends EventController {
public function index() {
return $this->listAction(); // Uses KnpPaginatorBundle
}
}
EventType (Symfony Form) in Laravel via collective/html or manually:
use c975L\EventsBundle\Form\EventType;
$form = $this->createForm(EventType::class, $event);
{% block events_carousel %}
{{ render(controller('c975LEventsBundle:Event:carousel')) }}
{% endblock %}
config/events.php:
'carousel' => [
'items' => 3,
'interval' => 5000,
'slide_by' => 'click', // or 'auto'
],
$icsUrl = $this->generateUrl('c975levents_event_ics', [
'id' => $event->getId()
]);
<a href="{{ path('c975levents_event_ics', {'id': event.id}) }}">Add to Calendar</a>
Twig/Extensions for dates are loaded. In Laravel, use:
// config/app.php
'providers' => [
// ...
Twig_Extensions_Extension_Date::class,
],
{{ event.startDate|date('Y-m-d H:i') }}
Route::resource('api/events', 'EventApiController');
Service Providers:
Bind the bundle’s services in AppServiceProvider:
public function register() {
$this->app->bind('c975levents.manager', function($app) {
return new \c975L\EventsBundle\Manager\EventManager(
$app['doctrine.orm.entity_manager']
);
});
}
Doctrine ORM:
Configure in config/database.php:
'orm' => [
'entity_managers' => [
'default' => [
'mappings' => [
'c975LEventsBundle' => [
'type' => 'annotation',
'dir' => __DIR__.'/../vendor/c975l/events-bundle/Resources/config/doctrine',
'prefix' => 'c975L\EventsBundle\Entity',
'alias' => 'c975LEventsBundle',
],
],
],
],
],
Asset Compilation:
Add bundle CSS/JS to webpack.mix.js:
mix.copy('vendor/c975l/events-bundle/Resources/public', 'public/bundles/c975levents');
Routing:
Override routes in routes/web.php:
Route::prefix('events')->group(function() {
include __DIR__.'/../vendor/c975l/events-bundle/Resources/config/routing.yml';
});
Dependency Conflicts:
composer.json).
composer.json:
"require": {
"tinymce/tinymce": "5.10.*",
"uxsolutions/bootstrap-datepicker": "1.9.*"
}
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
Doctrine Migrations:
events table or reset migrations:
php artisan migrate:fresh --env=testing
Twig Integration:
Twig_Extension_Date not found.
twig/extensions:
composer require twig/extensions
AppServiceProvider:
$this->app->make('twig')->addExtension(new \Twig_Extensions_Extension_Date());
ICS Generation:
config/events.php for timezone setting:
'default_timezone' => 'UTC', // or 'America/New_York'
Event entity before ICS generation.Carousel Not Loading:
bootstrap.js and jquery.js are loaded before bundle JS:
<!-- Order matters! -->
<script src="path/to/jquery.js"></script>
<script src="path/to/bootstrap.js"></script>
<script src="{{ asset('bundles/c975levents/js/carousel.js') }}"></script>
Form Validation:
@csrf directive in Twig:
{{ csrf_field() }}
Log Events:
Enable Doctrine logging in config/events.php:
'debug' => [
'doctrine_events' => true,
],
Check storage/logs/laravel.log for ORM events.
Dump Event Data:
Use Laravel’s dd() or Symfony’s dump():
use Symfony\Component\VarDumper\VarDumper;
VarDumper\Cloner\Data::ensureInitialized();
VarDumper\ Dumper::dump($event);
Check Routes: Run:
How can I help you explore Laravel packages today?