Search by

tereta / application-menu

tereta

The menu package for the tereta/application framework.It stores per-site menu trees as JSON in the database, exposes them as a block for the layout and manages them with the menu:edit, menu:show and menu:remove console commands.

Package info

gitlab.com/tereta/application/menu

Homepage

Issues

pkg:composer/tereta/application-menu

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

Stars: 0

0.0.8 2026-10-11 18:53 UTC

This package is not auto-updated.

Last update: 2026-10-11 15:53:26 UTC


README

🌐 English | Русский | Π£ΠΊΡ€Π°Ρ—Π½ΡΡŒΠΊΠ°

Menu package for the tereta/application framework. It keeps the menus of each site in the database and shows them on the pages of the site.

Requirements

PHP 8.2+, tereta/application.

Installation

composer require tereta/application-menu

After installation, run the database migration of the application, so the menu table is created.

Menu tree

A menu is a list of items. Each item has a label and a link. An item can have its own list of items in menu, so menus can be nested:

[
    {"label": "Home", "link": "/"},
    {"label": "Catalog", "link": "/catalog", "menu": [
        {"label": "Phones", "link": "/catalog/phones"},
        {"label": "Laptops", "link": "/catalog/laptops"}
    ]},
    {"label": "Contacts", "link": "/contacts", "icon": "contacts.svg"}
]

Manage menus

Menus are managed from the console. Each menu belongs to a site and has its own name.

Create a menu or replace an existing one:

php bin/console.php menu:edit base main '[{"label":"Home","link":"/"}]'

Here base is the site and main is the menu name.

Show all menus of a site:

php bin/console.php menu:show base

Show one menu:

php bin/console.php menu:show base main

Remove a menu:

php bin/console.php menu:remove base main

Menus on the page

The package gives three menus to the page: main, footer and footer:middle. In a template they are available in $meta['blocks']:

<ul>
    <?php $include('blocks/menu', $meta['blocks']['main']) ?>
</ul>

Each site shows its own menus. If a menu is not created yet, the page gets an empty list.

License

Apache License 2.0