- Can I use sylius/calendar in Laravel for managing recurring events like appointments or subscriptions?
- Yes, the package is designed for recurring events with RFC 5545-compliant recurrence rules. It integrates seamlessly with Laravel’s Eloquent for storage and can trigger events or queue jobs when recurrences occur. Just ensure your database schema supports serialized Period or RecurrenceRule objects.
- How do I install sylius/calendar in a Laravel project?
- Run `composer require sylius/calendar` in your project root. The package is framework-agnostic, so no Laravel-specific setup is required. You’ll need to manually bind the Calendar, Period, and RecurrenceRule services in your Laravel container if you’re using dependency injection.
- Does sylius/calendar support time zones, and how does it interact with Laravel’s app.timezone config?
- The package handles time zones natively, but you must explicitly configure them when creating Calendar or Period instances. It doesn’t automatically sync with Laravel’s `app.timezone`—you’ll need to pass the correct timezone string (e.g., `DateTimeZone::createTimeZone('America/New_York')`) to avoid conflicts.
- Will sylius/calendar work with Laravel 10 and PHP 8.1+?
- Yes, the package has no breaking changes for PHP 8.0+ or Laravel 9/10. It’s tested against modern PHP versions, but always verify compatibility by checking the package’s `composer.json` constraints and running tests in your Laravel environment.
- How do I store RecurrenceRule or Period objects in a Laravel database?
- You can serialize these objects to JSON and store them in a `TEXT` or `JSON` column. Alternatively, normalize the data into separate tables (e.g., `recurrence_rules`, `periods`) for complex queries. The package doesn’t enforce a storage strategy, so choose based on your query needs.
- Can I trigger Laravel events or queue jobs when a recurrence rule fires?
- Absolutely. The package’s recurrence logic is event-agnostic, so you can manually check for active recurrences in Laravel’s `scheduler:run` or `queue:work` commands. For example, loop through stored RecurrenceRule objects and dispatch events or dispatch jobs when a recurrence matches the current time.
- What alternatives exist if sylius/calendar feels too complex for my project?
- For simpler use cases, consider Carbon (built into Laravel) for basic date manipulation or Spatie’s Calendar package for event scheduling with a Laravel-friendly API. If you need iCalendar compatibility, sylius/calendar is still the most robust option, but it requires more setup.
- Does sylius/calendar include Laravel-specific documentation or examples?
- No, the package is framework-agnostic, so documentation focuses on PHP/PSR standards. However, the core concepts (Calendar, Period, RecurrenceRule) translate directly to Laravel. Check the GitHub repo for basic usage examples and adapt them to your Laravel services or models.
- How do I test time zone edge cases like Daylight Saving Time (DST) with sylius/calendar?
- Manually test DST transitions by creating Period or RecurrenceRule instances with timezone-aware DateTime objects. Use PHP’s `DateTimeZone` to simulate edge cases (e.g., `America/New_York` during March or November). Mock the current time in tests to verify recurrence calculations across DST boundaries.
- My project uses Behat for testing. Will the recent move of Behat dependencies to a separate test app break my CI/CD pipeline?
- Only if your pipeline or local environment relies on Behat being directly included in the main package. Update your `composer.json` to require the new test app package (`sylius/calendar-test`) or adjust your CI/CD scripts to install Behat separately. This change is non-breaking for end users.