- Can I use eschmar/time-ago-bundle in a Laravel application?
- Not directly. It is a Symfony bundle that registers EschmarTimeAgoBundle and exposes a Twig |ago filter; Laravel has no bundle kernel and uses Blade by default. You can port the formatting logic or use Carbon's diffForHumans instead.
- How do I install TimeAgoBundle in Symfony?
- Install with composer require eschmar/time-ago-bundle ^v2.0.0 for Symfony ^5.0, or use ^v1.1.0 for Symfony ^4.x and older tags for 2.8 and 3.4. On Symfony below 4, register new Eschmar\TimeAgoBundle\EschmarTimeAgoBundle() in AppKernel; on 4 and newer, auto-discovery should handle it. Smoke-test bundle registration on your exact Symfony minor.
- What does the |ago Twig filter do?
- It renders a time difference in words within a plus or minus seven day window, for example 3 minutes ago or in 4 hours. Beyond that window it returns a formatted date, defaulting to Y-m-d H:i:s or using the format passed to the filter or config. The filter is the whole integration surface in Twig.
- How do I configure the date format for TimeAgoBundle?
- Set eschmar_time_ago.format in your Symfony YAML configuration; the default is Y-m-d H:i:s. You can also pass a PHP date format directly to the filter, such as |ago('r'), for dates outside the relative window. Keep the same format in config and templates if you need consistent output.
- Does TimeAgoBundle support future dates?
- Yes. The filter is direction-aware and renders values such as in 4 hours for future timestamps, as well as 3 minutes ago for past ones. Outside the plus or minus seven day range it falls back to the configured absolute date format.
- Which Symfony versions does TimeAgoBundle support?
- The README advertises Symfony 2.8 through 5.x using version tags: v2.0.0 targets Symfony ^5.0, v1.1.0 targets ^4.x, and older tags cover 2.8 and 3.4. There is no v3 line and no Symfony 6 or 7 support according to the technical assessment. The latest release is dated 2022-03-04.
- Is TimeAgoBundle maintained and safe for production?
- Treat it as unvetted for production: the package has 17 stars, 0 dependents, a single maintainer, no CI, and no advertised test suite. The last release was 2022-03-04, and the assessment calls it effectively abandoned upstream. The MIT license keeps legal risk low, but you should own tests or vendor/fork the code if you adopt it.
- What are alternatives to TimeAgoBundle for Laravel relative dates?
- For Laravel, Carbon's diffForHumans() is the natural alternative and is already available through the framework. It handles past and future values and respects the application locale. Wrap it in a Blade directive or a small formatter service rather than adding a Symfony Twig bundle.
- How can I implement the same plus or minus seven day time-ago behavior in Laravel?
- Use Carbon::parse($value)->locale(app()->getLocale())->diffForHumans() for the relative branch. Branch on abs(now()->diffInDays($value)) <= 7 and otherwise call format($configFormat) for the absolute fallback. Add unit tests for past, future, inside-week, and outside-week cases so you own the contract.
- Does TimeAgoBundle include translations for many languages?
- Yes, it ships 26 locale translation catalogs including English, French, German, Spanish, Russian, and many others. The package does not document a fallback contract or pluralization strategy, so edge cases such as 1 minutes ago need verification in your target locale. If the catalogs are the main value, vendor the translation resources under MIT with attribution and wire them into Laravel's lang files.