Download the PHP package waynestate/parse-menu without Composer

On this page you can find all versions of the php package waynestate/parse-menu. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package parse-menu

ParseMenu Class

Parse menus from the Wayne State University API

Latest Stable Version Build Status Total Downloads License

Installation

To install this library, run the command below and you will get the latest version

composer require waynestate/parse-menu

Usage

Create the object

# start.php

use Waynestate\Menuitems\ParseMenu;

...

$parseMenu = new ParseMenu;

Make an API call for the menu

# controller.php

try {
    // Pull a specific menu from the API for a site
    $params = array(
        'site_id' => 1,
        'menu_id' => 2,
        'ttl' => TTL,
    );
    $menus = $api->sendRequest('cms.menuitems.listing', $params);

    // Menu config
    $menu_config = array(
        'page_selected' => 1,
    );

    // Get a final array to display the main menu
    $main_menu = $parseMenu->parse($menus[2], $menu_config);

    // Get the breadcrumbs from the parsed menu $main_menu
    $breadcrumbs = array();
    if(count($site_menu['meta']['path']) > 0) {
        $breadcrumbs = $parseMenu->getBreadCrumbs($main_menu);

        // Add the site root crumb
        $root_crumb = [
            'display_name' => 'Home',
            'relative_url' => '/',
        ];
        $breadcrumbs = $parseMenu->prependBreadCrumb($breadcrumbs, $root_crumb);
    }

    // Just display the first level in the header
    $top_menu_config = array(
        'display_levels' => 1,
    );

    // Parse the existing menu with the specific top_menu config
    $top_menu = $parseMenu->parse($main_menu, $top_menu_config);

} catch (Exception $e) {

    echo 'Caught exception: '.  $e->getMessage(). "\n";
}

Return values

$main_menu['meta'] = [
    'has_selected' => boolean, // default: false
    'has_submenu' => boolean, // default: false
    'depth' => integer, // default: 0
    'path' => array, // default: array()
]

$main_menu['menu'] = [
    // Array of the menu
]

$breadcrumbs = [
    // Sequential array of individual breadcrumbs in order based on the $main_menu['meta']['path']
]

Config Options

'page_selected' = Page ID for selection path (optional)
'skip_levels' = Number of levels to skip from the root (requires page_selected)
'display_levels' = Number of levels to display from the root (requires page_selected, if > 1)
'full_menu' = Return the full menu regardless if there is a page selected (boolean, default: false)
TODO: 'show_levels' = Number of levels to display from the leaf (requires page_selected)
TODO: 'add_home' = Add 'Home' as the first menu item (this may not be needed)

Exceptions

InvalidDisplayLevelsException = If 'display_levels' > 1 and no 'page_selected' found

Tests

phpunit

Code Coverage

phpunit --coverage-html ./coverage

All versions of parse-menu with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package waynestate/parse-menu contains the following files

Loading the files please wait ....