- How do I install florianv/business in a Laravel project?
- Run `composer require florianv/business` in your project directory. The package integrates via Laravel’s service container, so no additional configuration is needed unless you’re using custom business-hour rules. Register the service provider in `config/app.php` if required, though most basic use cases work out-of-the-box.
- Does this package support business-hour calculations for scheduling or time-tracking?
- Yes, the package is designed for business-hour-aware datetime calculations, making it ideal for scheduling, time-tracking, or compliance systems. It handles fixed business hours (e.g., 9 AM–5 PM) but lacks built-in support for holidays or dynamic rules, which may require custom extensions.
- Will this package work with Laravel’s Carbon library?
- The package is compatible with Carbon but may introduce ambiguity if both are used for datetime logic. Audit your existing Carbon usage and standardize on one library to avoid conflicts. The package’s methods can be wrapped around Carbon for consistency.
- What Laravel and PHP versions does florianv/business support?
- The package is tested on PHP 7.4–8.1 and likely works with Laravel 8.x, 9.x, and 10.x LTS releases. PHP 8.2+ may require adjustments due to inactivity since 2022, so test thoroughly if targeting newer versions.
- Can I use this for validating VAT or SIRET numbers across multiple countries?
- No, this package focuses on **business-hour-aware datetime calculations**, not business identifier validation (VAT, SIRET, etc.). For tax number validation, consider packages like `spatie/laravel-business-hours` or `mollie/php-vat-validation` instead.
- How do I handle holidays or custom business-hour rules (e.g., seasonal adjustments)?
- The package assumes static business-hour configurations. For holidays or dynamic rules, you’ll need to extend the package or build a wrapper layer. Example: Override the `BusinessHour` class to include custom logic for holidays or time-zone adjustments.
- Is this package actively maintained? Should I use it in production?
- The package was last updated in 2022 and has no active maintenance. While it’s lightweight and MIT-licensed, evaluate risks for long-term use. Test thoroughly in staging, and consider forking if critical features (e.g., PHP 8.2+ support) are needed.
- How do I integrate this with Laravel’s Queues or Scheduling?
- Use the package’s datetime methods (e.g., `BusinessHour::addHours()`) in your queue jobs or scheduled tasks. For example, delay a job by business hours with `$job->delay(BusinessHour::addHours(2))`. Ensure consistency with your existing Carbon or DateTime usage.
- Are there alternatives to florianv/business for business-hour calculations?
- Yes. For Laravel, consider `spatie/laravel-business-hours` (more feature-rich) or `nesbot/carbon` extensions. For custom needs, a lightweight wrapper around Carbon’s `BusinessHours` extension may suffice if your requirements are simple (e.g., fixed hours).
- How do I test this package in a Laravel application?
- Write integration tests for critical paths (e.g., scheduling logic) using Laravel’s testing tools. Mock the `BusinessHour` service and verify edge cases like weekends, DST transitions, or custom hour ranges. Example: `BusinessHour::shouldReceive('addHours')->andReturn($expectedDateTime);`.