zendframework/zend-navigation
Abandoned Zend Framework navigation component for building and managing navigation trees (menus, breadcrumbs, links, sitemaps). Repository moved to laminas/laminas-navigation; see Laminas docs for current usage.
This is the legacy Zend Framework zend-navigation component—now archived and unmaintained since 2019. It provides simple, configurational navigation (e.g., menus, breadcrumbs) driven by Zend\Navigation\Page objects. If you're starting a new Laravel project, do not use this—use Laravel’s built-in pagination, or modern packages like spatie/laravel-menu. However, if you’re maintaining a legacy ZF2/Laminas port or PHP 5.x/7.0–7.3 app, here’s how to get going:
composer require zendframework/zend-navigation:^2.9
Zend\Navigation\Page\Mvc or Zend\Navigation\Page\Uri:
use Zend\Navigation\Page\Mvc;
$pages = [
Mvc::factory([
'label' => 'Home',
'route' => 'home',
'active' => true,
]),
// more pages...
];
// In a service or controller
$container = new Zend\Navigation\Navigation($pages);
echo $view->navigation($container)->menu();
Check data/README.md or Laminas’ archived docs—the component was migrated to laminas/laminas-navigation, but Laravel doesn’t integrate it natively.
Config-driven navigation: Store navigation structure in config (config/navigation.php) as an array of pages—then build the container from config:
$pages = Zend\Navigation\Page\Page::factory(config('navigation.main'));
$navigation = new Zend\Navigation\Navigation($pages);
Dynamic page generation: Build pages conditionally based on user permissions, e.g., in a middleware or view composer:
if ($user->isAdmin()) {
$pages[] = Zend\Navigation\Page\Uri::factory(['label' => 'Admin', 'uri' => '/admin']);
}
Blade integration workaround: Since Laravel lacks view helpers, create a service class to expose Zend\Navigation methods:
// App\Services\NavigationRenderer
public function renderMenu(Zend\Navigation\Navigation $nav, $ulClass = 'nav'): string
{
$menu = new \Zend\View\Helper\Navigation\Menu;
$menu->setUlClass($ulClass);
return $menu->render($nav);
}
Then inject into Blade views: @inject('navRenderer', 'App\Services\NavigationRenderer').
Breadcrumb integration: Use Zend\View\Helper\Navigation\Breadcrumbs similarly.
PHP version support: Now supports PHP 7.3 (release 2.9.1), but still incompatible with PHP ≥7.4. If upgrading PHP, you must migrate away or backport patches—Laminas' fork may be a better short-term migration target.
No Laravel container resolution: Navigation relies on manual setup. Avoid relying on service location patterns it uses internally—inject dependencies explicitly.
Missing route resolution: Mvc pages need Zend\Mvc\Router (not available in Laravel). To bridge this:
Uri pages with url() helper via config('app.url') . '/path'Mvc::factory() to resolve route via Laravel’s Route::url()—but this risks desync.No Laravel events: Navigation doesn’t integrate with Laravel’s event/model bindings. You’ll need custom logic to update pages when models change.
Deprecated but still used: Some older Laminas-based apps still depend on it. If migrating to Laravel, consider:
config/breadcrumbs.phpspatie/laravel-breadcrumbs or custom Blade components instead.Autoloading quirk: Since it’s Zend\* (not PSR-4), ensure vendor/composer/autoload_classmap.php includes it—or use zendframework/zend-servicemanager to bootstrap helper classes correctly.
Last stable version: 2.9.1 (2023-XX-XX) is the final—no CVEs reported, but security patches won’t be issued. Audit carefully for legacy usage.
How can I help you explore Laravel packages today?