Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Events Bundle Laravel Package

c975l/events-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require c975l/events-bundle
    

    Verify c975L/EventsBundle appears in composer.json under require.

  2. Enable the Bundle Add to config/bundles.php (Laravel 5.5+):

    return [
        // ...
        c975L\EventsBundle\c975LEventsBundle::class => ['all' => true],
    ];
    
  3. 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).
    • Assets in public/bundles/c975levents/.
  4. Database Migration Run:

    php artisan migrate
    

    The bundle creates an events table (check database/migrations/ for schema).

  5. 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();
    
  6. Display an Event In a Twig template (if using Laravel Mix with Twig bridge):

    {% include '@c975LEvents/event/show.html.twig' with {
        'event': event
    } %}
    

Implementation Patterns

Core Workflows

1. Event Management CRUD

  • Controllers: Extend 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
        }
    }
    
  • Forms: Use the provided EventType (Symfony Form) in Laravel via collective/html or manually:
    use c975L\EventsBundle\Form\EventType;
    
    $form = $this->createForm(EventType::class, $event);
    

2. Carousel Integration

  • Twig Template:
    {% block events_carousel %}
        {{ render(controller('c975LEventsBundle:Event:carousel')) }}
    {% endblock %}
    
  • Configuration: Adjust carousel settings in config/events.php:
    'carousel' => [
        'items' => 3,
        'interval' => 5000,
        'slide_by' => 'click', // or 'auto'
    ],
    

3. Calendar Integration (ICS)

  • Generate ICS Link:
    $icsUrl = $this->generateUrl('c975levents_event_ics', [
        'id' => $event->getId()
    ]);
    
  • Twig:
    <a href="{{ path('c975levents_event_ics', {'id': event.id}) }}">Add to Calendar</a>
    

4. Localization

  • Ensure Twig/Extensions for dates are loaded. In Laravel, use:
    // config/app.php
    'providers' => [
        // ...
        Twig_Extensions_Extension_Date::class,
    ],
    
  • Format dates in Twig:
    {{ event.startDate|date('Y-m-d H:i') }}
    

5. API Endpoints

  • The bundle provides RESTful routes (if enabled in config). Extend with Laravel’s API resources:
    Route::resource('api/events', 'EventApiController');
    

Integration Tips

Laravel-Specific Adjustments

  1. 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']
            );
        });
    }
    
  2. 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',
                    ],
                ],
            ],
        ],
    ],
    
  3. Asset Compilation: Add bundle CSS/JS to webpack.mix.js:

    mix.copy('vendor/c975l/events-bundle/Resources/public', 'public/bundles/c975levents');
    
  4. Routing: Override routes in routes/web.php:

    Route::prefix('events')->group(function() {
        include __DIR__.'/../vendor/c975l/events-bundle/Resources/config/routing.yml';
    });
    

Gotchas and Tips

Pitfalls

  1. Dependency Conflicts:

    • TinyMCE/Bootstrap: Ensure versions match the bundle’s requirements (check composer.json).
      • Fix: Lock versions in composer.json:
        "require": {
            "tinymce/tinymce": "5.10.*",
            "uxsolutions/bootstrap-datepicker": "1.9.*"
        }
        
    • jQuery: Bundle expects jQuery 3.x. Use:
      <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
      
  2. Doctrine Migrations:

    • If migrating an existing DB, manually create the events table or reset migrations:
      php artisan migrate:fresh --env=testing
      
  3. Twig Integration:

    • Error: Twig_Extension_Date not found.
      • Fix: Install twig/extensions:
        composer require twig/extensions
        
      • Or manually register in AppServiceProvider:
        $this->app->make('twig')->addExtension(new \Twig_Extensions_Extension_Date());
        
  4. ICS Generation:

    • Issue: Blank ICS file or malformed dates.
      • Debug: Check config/events.php for timezone setting:
        'default_timezone' => 'UTC', // or 'America/New_York'
        
      • Validate dates in Event entity before ICS generation.
  5. Carousel Not Loading:

    • Cause: Missing Bootstrap JS or jQuery.
      • Fix: Ensure 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>
        
  6. Form Validation:

    • Problem: CSRF token errors in forms.
      • Fix: Use Laravel’s @csrf directive in Twig:
        {{ csrf_field() }}
        

Debugging Tips

  1. Log Events: Enable Doctrine logging in config/events.php:

    'debug' => [
        'doctrine_events' => true,
    ],
    

    Check storage/logs/laravel.log for ORM events.

  2. Dump Event Data: Use Laravel’s dd() or Symfony’s dump():

    use Symfony\Component\VarDumper\VarDumper;
    
    VarDumper\Cloner\Data::ensureInitialized();
    VarDumper\ Dumper::dump($event);
    
  3. Check Routes: Run:

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware