jeffersongoncalves/laravel-brazil-holidays
Laravel package for working with Brazilian holidays. Determine national holidays, check if a given date is a holiday, and use the data in your PHP applications with a simple, framework-friendly API.
composer require (package name per Packagist listing) and, if a config file ships, publish it with php artisan vendor:publish --tag=config (or the package's published tag) so the state/municipal holiday lists and the Carnival/Corpus Christi toggles live in config/. Commit that file.config/*.php file and the package's facade/service entry point. That pair tells you everything you need: which municipality/state is active, whether Carnival and Corpus Christi count as holidays, and which methods (isHoliday, isBusinessDay, addBusinessDays) are exposed.isBusinessDay($date) for the current timestamp, and use it to decide whether to dispatch a notification or queue it for the next working day. This is the fastest "did it do what I expect?" smoke test against a known date.addBusinessDays($date, $n) rather than chaining ->addWeekdays() on Carbon. The package knows about national holidays (and any state/municipal ones you configured), so ticket due dates, delivery estimates, and invoice cutoffs stay correct across holidays. Wrap this in a small BusinessDays helper or a custom cast so the logic is reused instead of sprinkled across controllers.[year, state, municipality, carnival/corpus flags] key. This makes expensive calls cheap and keeps the results consistent for the whole request.Carbon instances to the start of day in the app timezone (typically America/Sao_Paulo) before calling isHoliday/isBusinessDay, and keep the original time when you need to display it. Store business-date computations as date columns, not datetime.if ($this->holidays->isBusinessDay(now())) { ... }), and reporting queries for working-day counts.Carbon::setTestNow() against known dates (e.g. a fixed Carnival year, 1 Jan, 7 Sep) so your assertions don't drift. Add a small fixture test that confirms Consciência Negra is treated as a holiday only from 2024 onward — that's the edge most likely to bite in historical reporting.addBusinessDays semantics. Confirm whether the start date is counted and what happens when it lands on a holiday or weekend. Write one test that pins the behaviour, then build your SLA helper on top of it — do not re-derive the rule elsewhere.isBusinessDay(now()) depends on the app timezone. If you run jobs in UTC but serve Brazilian users, convert to local time first; otherwise late-evening UTC timestamps will resolve to the wrong calendar day.php artisan config:clear (and re-cache). A stale cached config is the usual cause of "the package says today isn't a holiday" in production while it's correct locally.ext-calendar dependency, which is good for portability, but validate it once against a few known Easter dates and rely on the package's own holiday derivation rather than reimplementing it. If you need movable feasts beyond Carnival/Corpus Christi, that's your extension point.How can I help you explore Laravel packages today?