- How do I install hieu-le/active in a Laravel application?
- Run composer require hieu-le/active and let Laravel package auto-discovery register the service provider; no config file, migrations, or published assets are involved. On older Laravel versions without auto-discovery, add the provider and the Active facade alias to config/app.php manually. After that the active_class() helper and the Active facade are available in your Blade templates immediately.
- Which Laravel and PHP versions does hieu-le/active support?
- The package's composer.json is the only authority: check the illuminate/support and php constraints before committing to it. The last tagged release was March 2022, so it was built for the Laravel 5.x through 9.x era and carries no compatibility commitment beyond that. Confirm it admits the Laravel and PHP versions you plan to run for the next 18 months, especially if a Laravel 10 or 11 upgrade is on your roadmap.
- How do I add an active class to a navigation link in Blade?
- Call the active_class() helper or Active::getActiveClass() inside your nav markup and echo the returned CSS class onto the anchor or list item. You pass the route name, URI, controller, or action that should match the current request. Because the package only returns a string, it works in any Blade template and is easy to assert against in feature tests that inspect rendered markup.
- What is the difference between Active::isActive() and Active::getActiveClass()?
- Active::isActive() answers a boolean question: does the current route match the given pattern? Active::getActiveClass() returns the configured CSS class on a match and a default, usually an empty string, when there is none. Use isActive() when you need to branch in the template, for example to also set aria-current, and getActiveClass() when you simply want to echo a class attribute.
- Can I match routes by controller and action instead of route name?
- Yes, the package can match by controller and action as well as by route name and URI. That is convenient early on but degrades silently after route refactors, because a renamed controller or action simply stops matching and no exception is thrown. Prefer route-name matching, and add a test that asserts the rendered active class so a broken match fails loudly.
- Is hieu-le/active still maintained, and is it safe for production?
- The upstream repository is archived and the last release dates to March 2022, so there is no active maintainer and no commitment to fix breakage on newer Laravel releases. Security exposure is low because the package performs no I/O, deserialization, or dynamic execution; the real risk is maintenance and upgrade friction. Treat support as your own team's responsibility and plan an exit path.
- Why is my active class missing after running route:cache?
- Active-route detection compares the current request against patterns, and once routes are cached Laravel resolves them from the compiled route collection instead of re-registering them per request. Matching usually still works, but anything relying on registration-time behaviour or on artifacts that are not part of the cached routes can stop matching. Validate your navigation against a route:cache run in staging and prefer route-name matching, which survives caching.
- Does hieu-le/active work with Laravel 10 or Laravel 11?
- Probably not out of the box. The decisive factor is the illuminate/support constraint in its composer.json, and since the package has not been updated since March 2022 it most likely pins to the Laravel 5.x through 9.x range. Forcing an install with --ignore-platform-reqs is a poor trade for a dependency whose only job is adding a CSS class. A small fork or a swap to request()->routeIs() is cheaper.
- How do I replace hieu-le/active with native Laravel features?
- Laravel now covers everything this package does through request()->routeIs(), Route::is(), and the @class directive for name, URI, and pattern matching in Blade. Introduce an app-owned shim such as a small ActiveNav class or an @active Blade directive built on routeIs(), keep your existing call sites unchanged, then remove the package, its provider, and its facade alias. It is a mechanical codemod rather than a template rewrite.
- Can hieu-le/active conflict with my own helper functions or other packages?
- The package registers global helper functions through Composer's files autoload, so they are defined at autoload time rather than lazily on first call. If your application or another package declares a function with the same name, you get a fatal redeclaration error at boot instead of a recoverable failure at the call site. Grep your dependency tree for active_class and the Active alias before installing.