Download the PHP package vespakoen/menu without Composer

On this page you can find all versions of the php package vespakoen/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 menu

Menu

Build Status Total Downloads Latest Stable Version Latest Unstable Version License

API Docs

Are you the type of person that writes menus by hand in view files or do you find yourself looking for the best place to store links to pages on your website? then Menu is for you!

Quick overview example

{!! $menu !!} will output:

Key concepts

Item lists

An item list is what a menu is all about and it should be pretty self explanatory because it simply stores a list of items. there are some configurations available for an item list. You can, for example set the HMTL element that will be used to render the list, prefix every item in the list with all the parent's url segments, and a lot more. We will explore these options later.

Menu handlers

Menu handlers allow us to create and interact with item lists and act as a place to store and retrieve our menus. Because we are able to interact with multiple item lists at the same time some interesting possibilities become available to us.

Items

The Menu package has 2 types of items available out of the box.

The HTML element and attributes for the item can also be changed, more on this topic later.

Installing

Laravel 3

Install Menu via the artisan command line tool. Open the terminal and navigate to your Laravel project's root. Now type the following command :

To let Laravel know the Laravel Menu package should be started, open up application/packages.php and add the following lines to the packages array.

Laravel 4

Add this to your composer.json file's "require" :

And add the following to your app/config/app.php file :

Laravel 5

Add this to your composer.json file's "require" :

And add the following to your config/app.php file :

Lastly, run the following from your project's root dir:

Basic usage

First, let's load some pages into the menu. We will do this by utilising the hydrate method.

Now that we have loaded our pages into the menu, and even identified every menu item with a name (via Menu::items($item->as)) a lot of options are available to us.

Find a node by it's name and add a subitem.

Add some properties to the root node

Get all ItemLists at a certain depth and add a class

Get all ItemLists at a depth range and change the element

Get all Items at a certain depth and add a class

Get Items by it's content type and use the map function to walk over the results and perform actions based on gathered information

Get all ItemLists and add a class to them if they have children

Breadcrumbs

Breadcrumb hell is a thing of the past.

Bootstrap ready breadcrums are as easy as this

The breadcrumbs method searches all handlers and returns a plain old ItemList, that you can manipulate. If you call the breadcrumbs method directly on the Menu class, it will search all your handlers for breadcrumbs, and by default will return the first match. However, there might be cases where you want to choose the breadcrumbs out of the ones it found, for this you can provide a callback method as the first argument.

And example is shown below:

Diving deeper

The Laravel Menu packages consists of a couple of classes, but you can interact with all of them via the Menu class. Let's take a look at the handler method. it takes a string or an array as the only argument, the string(s) given are the names for the item lists we want to retrieve. If an itemlist we asked for didn't exist yet, it will create it for us. After the menu class has found and created the item lists we want, it will hand back a menuhandler that handles the item lists we asked for.

When we call a method on this menu handler, it will simply forward the call to all the item lists that it handles. In order to find out what we can do now that we have a handler, we need to take a look at the methods on the ItemList class.

The ItemList class has a method called add that you are probably going to use a lot. It adds an Item of type "link" to the ItemList.

Let's take a look at the raw method, for adding "anything" to the list.

Great! Now that we have learned how to add items to an item list, let's have a look at how we add children to a item. Every item can have children, the children object is just another ItemList. As we have seen before, we can create item lists via the handler method, but this method returns a MenuHandler, making it unusable for item children. So what do we use? the items method returns a fresh ItemList object. Let's have a look.

So now we know how to build menus, add items and items with children. Let's find out how to display the menus. The MenuHandler and ItemList classes implement the "__toString" method, that calls the render method. This means you can simply echo the MenuHandler or ItemList object. Here is an example to make things more clear.

Now that we have the basics under control, we are going to explore some other cool features this package provides.

Class diagram

Class diagram

Some last words

Thanks for following along and using this package. Special thanks to @Anahkiasen for refactoring this package and boosting new life into it!


All versions of menu with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
anahkiasen/underscore-php Version ^2.0
anahkiasen/html-object Version ~1.4
illuminate/http Version 6.*|^7
illuminate/config Version 6.*|^7
illuminate/container Version 6.*|^7
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 vespakoen/menu contains the following files

Loading the files please wait ....