Download the PHP package elmdash/menu without Composer

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

ElmDash Menu

Menus are but a simple tree structure. You can implement them a million ways, but this is a clean and minimal menu structure that handles the basic chores of setting active states and toggling menu items depending on a user's authorization within Laravel apps.

In your provider's boot method add something like:

Then in your view:

Labels are set in lang/menu.php:

Notice that the translation keys are the menu items' route names but with dashes instead of periods. Also, notice that the top-level name of the menu is used to group the translations.

Features

Root Menus

Top-level (root) menu objects will usually not be rendered and won't have a route to reference. You can give these routes names for convenience.

Adding items

The menu tree is made up of only Menu objects so every item in the tree has the same methods as every other item. That is, there is not "MenuRoot", "MenuGroup", or "MenuItem" differentiation.

Adding an item can be as simple as adding the name of a route. (At this time, you can't add any routes that aren't named.)

This returns the newly created Menu child. You can use this for chaining.

It may be easier for several reasons, however, to use a callback to create your tree structures. First, it's more visually appealing and second, the functions are called once needed. This is handy for delaying menu initialization code until everything else has been initialized.

There are other means of adding items:

Routes

The route name is typically specified when adding the menu item.

If your route takes parameters, you should add them to the menu. They will be used to render the correct href value and for determining the active menu item.

The params used to find a match are just the params defined on the route. To add finer control, you can extract these params yourself. The result is cached so it will only get called once. For example, you may need to get a param value from a different route parameter (like during an edit route).

Getting the URL to render in your view is simply like this:

Or if you need absolute URLs

Active menu items

When a child item is active, all parents will be considered active. To find out which menu item matches the currently active URL, we compare the current route's name with each menu item's route name. For example, the "users.account" menu item will be active when the "users.account" route is active. It's just a strict name (and possibly parameters) comparison.

However, you may have more than one view per your lowest level of menu items. You'll need a way to specify other named routes that should mark a menu item as active. For that we have globbing:

Again, we're only working with named routes, so make sure your routes are all named.

As shown above, to find out if an item is active in your view just call item.isActive.

For submenus, you may also need to get the currently active item of some root menu object.

Access

Menu items can be hidden for users who don't have permission. This just uses Laravel's authorization policies.

Menu items that are not visible to the current user will not be returned by the menu.children function. If a parent item is not visible, then the children will also not be marked as visible. In submenus, you may need to check for visibility directly (like, if you are not looping directly over the results of menu.children.

By default, all menu items require authentication. To create menu items for anonymous users:

Flags

You can add flags to a menu item for inquiring about menu items later.

Labels

Labels are just taken from the Laravel's translation infrastructure.

By default, the translation key is just the route name provided when adding the menu item, but with the dots converted to dashes

If the top-level menu object has a name, then that will be prefixed to the translation key: i.e. 'top-left' and 'my.route.name' => 'top-left.my-route-name'.

Group names are also prefixed

At any place up the menu tree, you may specify a translation namespace.

You can override the language key to use:

Or you can override the label directly


All versions of menu with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
laravel/framework Version ~5.3
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 elmdash/menu contains the following files

Loading the files please wait ....