A fluent PHP interface to build HTML menus with strong control over output and infinite nesting.
Spatie Menu is a PHP package that provides a fluent interface for building HTML menus programmatically. It solves the problem of generating complex navigation structures with clean, maintainable code while offering fine-grained control over the resulting HTML output.
PHP developers, especially those using Laravel, who need to generate dynamic HTML menus in their applications with a clean, object-oriented API.
Developers choose Spatie Menu for its expressive fluent interface, strong control over HTML attributes and nesting, and seamless Laravel integration, making menu generation more maintainable and less error-prone than manual HTML or array-based configurations.
Html menu generator
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Offers chainable methods like ->link() and ->add() for readable and maintainable menu construction without array configurations, as shown in the human-readable examples.
Allows precise addition of classes, IDs, and attributes to menus and items using methods such as ->addClass() and ->id(), demonstrated in the 'Strong Control Over the Html Output' section.
Provides Laravel-specific features like ->action() for controller methods and ->setActiveFromRequest() for automatic active state management, enhancing productivity in Laravel apps.
Supports building menus from arrays with Menu::build() and ->fill(), enabling dynamic creation from databases or other data sources, as illustrated in the programmatic approach.
Version 2.0 removed methods like void and prefixLinks without direct replacements, requiring code changes and migration efforts, as admitted in the upgrading guide.
Spatie recommends Laravel Navigation for more flexible needs, indicating this package may not be the future focus for advanced or renderless navigation features.
Core functionality is PHP-only, and full feature set depends on Laravel, limiting use in other tech stacks or non-Laravel PHP applications.