- What is cmixin/enhanced-period and what does it do?
- cmixin/enhanced-period is a Composer package that adds practical interval operations to CarbonPeriod, including contains, overlaps, intersect, diff, merge, and split. It also provides enhanced support for converting between CarbonPeriod objects and Spatie\Period\Period. The goal is to simplify comparing, combining, and manipulating date ranges in PHP and Laravel applications while staying within existing Carbon workflows.
- How do I install cmixin/enhanced-period in a Laravel application?
- Install it with Composer by requiring cmixin/enhanced-period in your project. Because it works as a Carbon mixin, the package extends CarbonPeriod globally once enabled, so review the README for the exact registration or bootstrapping step. For Laravel, you can keep the integration isolated in a service provider or internal conversion service rather than calling the mixin methods throughout your codebase.
- Does cmixin/enhanced-period support Laravel 10 or Laravel 11?
- The package does not declare a Laravel-specific dependency; it targets Carbon and Spatie Period, so Laravel compatibility depends mainly on your Carbon version. The last release was June 2023, so Laravel 11 and newer Carbon majors should be treated as unverified until you run compatibility tests. Check Composer constraints against your PHP, Carbon, and Spatie Period versions before adopting it.
- How do I use contains, overlaps, and intersect with CarbonPeriod?
- After enabling the mixin, you can call methods such as contains, overlaps, intersect, diff, merge, and split directly on CarbonPeriod instances. These methods let you ask whether one period contains a date or another period, whether two periods overlap, and how to compute their intersection or difference. Test the results against your expected inclusive or exclusive boundary behavior before relying on them in production.
- Is cmixin/enhanced-period compatible with Spatie\Period\Period?
- Yes, the package is designed to provide enhanced Spatie Period behavior from CarbonPeriod objects and to help bridge the two representations. You can use it when your application already depends on both Carbon for date ranges and Spatie Period for period arithmetic or set operations. Validate that conversion preserves your boundary, timezone, and metadata requirements, because conversion semantics are the main integration risk.
- What are the risks of using a global Carbon mixin in a Laravel app?
- A global mixin extends CarbonPeriod everywhere, which creates hidden coupling and makes behavior harder to trace through controllers, jobs, and domain services. The package itself has low community validation, with around 19 stars, zero dependents, and a last release in June 2023. A safer approach is to wrap it in an internal PeriodConverter or similar adapter and avoid scattering mixin calls across the codebase.
- Does cmixin/enhanced-period handle timezones and DST correctly?
- The package is lightweight PHP logic layered over CarbonPeriod and Spatie Period, so timezone and DST correctness depends largely on the underlying libraries and how you construct your periods. You should add explicit tests for timezone boundaries, DST transitions, and date-only versus datetime periods before relying on conversion or comparison results. Do not assume lossless behavior for all boundary and timezone cases without verifying them.
- Is cmixin/enhanced-period actively maintained?
- The last release was June 2023, and the package has very little public validation, so it appears lightly maintained rather than actively developed. The MIT license means you can fork it if needed, but you should assume internal ownership for compatibility checks and upgrades. Keep a fallback plan because abandonment is a realistic failure mode for a small package like this.
- What are some alternatives to cmixin/enhanced-period?
- Alternatives include using Spatie Period directly for period math, relying on Carbon's native date comparison and diff methods, or writing a small internal converter between CarbonPeriod and Spatie Period. If you only need one or two operations, a focused internal helper may be safer than adding a global mixin. Consider the package when you specifically want its CarbonPeriod API and already need both Carbon and Spatie Period in your stack.
- How should I test cmixin/enhanced-period before using it in production?
- Start with focused tests for open and closed intervals, overlapping and adjacent periods, timezone boundaries, DST transitions, and date-only versus datetime ranges. Pilot the package in a non-critical path such as reporting or scheduling, and compare its results against your existing manual logic. Because the package is lightly maintained, wrap it behind an internal adapter so you can replace or fork it without rewriting call sites.