- How do I install the maherelgamil/arabicdatetime package in a Laravel app?
- Install it with composer require maherelgamil/arabicdatetime. The package is Laravel-native, so its service provider and facade should be registered automatically through package discovery. Publish the configuration file with php artisan vendor:publish and select the package's provider tag, then call the facade or Blade directive in your views. Confirm the exact facade alias and config keys in the README or the package source, since the documentation is thin.
- Is maherelgamil/arabicdatetime compatible with Laravel 10, 11, and PHP 8.2?
- The last tagged release is from June 2021, so its illuminate/support and nesbot/carbon constraints were written for the Laravel 8 and Carbon 2 era. Resolving it on Laravel 10 or 11 with PHP 8.1+ may require --ignore-platform-reqs or a fork. Run composer why-not maherelgamil/arabicdatetime against your actual lockfile to see the concrete conflict before committing. Treat a maintain-your-own fork or an isolated adapter as the default plan.
- How do I display a Hijri date in Laravel using this package?
- Pass a Carbon instance to the package's formatter and it returns an Arabic-labelled, optionally Hijri, date string suitable for output in Blade or an API response. Exact method names vary between versions, so check the source or README for the current facade calls. Because Arabic output is a presentation concern, keep the call in your view or presenter layer rather than in models or repositories.
- Which Hijri conversion algorithm does this package use?
- The package does not clearly document which Hijri algorithm or reference tables it uses, and that is the biggest correctness risk. Umm al-Qura (astronomical tables, used in Saudi Arabia), tabular Islamic arithmetic, and sighting-based observance disagree by one to two days. Verify by running known golden dates against the Umm al-Qura reference your business requires. If any downstream logic depends on the Hijri date rather than just displaying it, do not trust this package's output unchecked.
- Can I choose between Eastern Arabic numerals and Western digits?
- Configuration should let you control the digit system, month naming style, and locale, but you must publish and inspect the config file to confirm what is actually available. Eastern Arabic numerals and Western digits are typically a locale or config switch. Test mixed RTL and LTR strings in your real layout, because naive digit mapping often produces visual bugs that unit tests miss. If the config surface is insufficient, wrap the package and normalise digits yourself.
- Does this package mutate the global Carbon locale or PHP setlocale?
- Some Arabic date libraries set the global Carbon locale or call PHP setlocale, which can leak into later formatting in the same process. That is a real hazard under Octane, Swoole, and long-lived queue workers that reuse the container across requests and jobs. Check the source for whether prior locale state is captured and restored. If it is not, isolate the calls or reset the locale in a middleware or job wrapper.
- How do I show relative Arabic time expressions like 5 minutes ago?
- The package advertises Arabic time expressions alongside date formatting, so relative strings should be available through its facade or a dedicated method. Arabic has dual and plural forms that a naive substitution map gets wrong, so test the full range of counts rather than a single example. Compare output with intl-based formatting if you need guaranteed grammatical correctness.
- Does the package return a Carbon date or a formatted string, and how does timezone affect Hijri conversion?
- It is a formatter: it takes a Carbon instance and returns a pre-rendered string, so you generally cannot get a Hijri date object back out of it. That matters because timezone adjustment and Hijri rollover happen at different instants, and the conversion order changes the resulting day. Decide whether conversion happens before or after shifting to the display timezone, and document the choice. If you need arithmetic on Hijri dates, use a dedicated conversion library instead.
- Is maherelgamil/arabicdatetime still maintained, and what are the alternatives?
- Effectively no: around 41 stars, a single maintainer, and no release in roughly three and a half years mean you should assume no upstream fixes and budget for fork-and-own. Alternatives include Carbon's own locale and isoFormat support, the PHP intl extension with an Arabic locale, or a dedicated Hijri conversion library. Whichever you choose, hide it behind your own formatter interface so it stays replaceable.
- How should I test Arabic date formatting in my Laravel application?
- Write golden-date tests in your own suite that assert specific Gregorian to Arabic and Hijri outputs, covering month boundaries, leap years, and the rollover hour in your timezone. Run them under your real runtime, including Octane or a queue worker, to catch locale state leaking between calls. Pin the exact version and serve it from a private mirror, since the package is unmaintained. Also add rendering tests for mixed RTL and LTR strings and for both digit systems.