Download the PHP package vynatu/menu without Composer

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

Find the API documentation here

Introduction

This package is yet another menu library. This library is different than the others because:

This structure makes it perfect to modularize and extend your menus through the usage of different module libraries the laravel framework can support.

Installation

Vynatu/Menu only uses a single service provider.

First, install with composer:

Then, add the service provider to app.php:

Vynatu/Menu does not require an alias. You can call the menu manager directly using app('menu').

Creating a Menu

Setup the Service Provider

You can register menus in any service provider you use, but I prefer making a new service provider called MenuServiceProvider.

This allows you to better separate what the AppServiceProvider does and the new MenuServiceProvider that is solely used to register and extend menus.

Create a new service provider (using Artisan):

Don’t forget to register it in the providers!:

Create the New Menu

Vynatu/Menu comes with a console command that lets you create menu classes very easily.

We suggest you put your Menus in a sub-folder (app/Menus).

Or you can make the class yourself:

After creating your menu class, an instance of \Vynatu\Menu\RootMenuItem will automatically be injected in your MenuInstance.

Add items to the menu

You can add items to the menu by using the $this->menu instance.

Method Number What does add() return Additional Info
1 A new MenuItem Sets the url to Dashboard
2 The $this->menu instance The route is set already by the second argument using an absolute URL. Useful for quick url assignment
3 The $this->menu instance The route is associated using the route: prefix. Useful for quick route assignment
4 A new MenuItem Useful to create a section. URLs or routes don't have to be set. When a function with no argument is called, a variable with the function's name is set to true.
5 The $this->menu instance The route is associated with arguments, useful to create a quick route with parameters.
6 A new MenuItem The route is assigned using the fluent interface, which makes the code look cleaner. You can also add an array of route parameters as the second argument.
7 The $this->menu instance You can pass an array as the second argument to immediately issue all the variables to the menu item, when you don't want to use the fluent interface.

Registering the menu

In the menu service provider you have previously created, add this to the boot method:

You don't have to use dependency injection. You can use app('menu')->register(...) instead.

Extending a menu

Do the same steps as creating and registering a menu, but instead of using the register method:

Accessing menu items in a menu instance

You can access any menu items in a menu instance this way:

The management variable is created automatically when a new menu item is added. snake_case is used to create the variable name.

This means that if you created an item like $this->menu->add('Management'), a new variable called management will exist and can be accessed by the local menu instance or any menu extender.

If you use _t to create menu names (which means the slug name will always change), you can set the slug name statically:

This allow your other extenders to access the management menu item and, for example, change its icon:

Setting variables to a menu item

There are two ways to do this.

The first one, using a function. It is useful to conserve the fluent API:

The second one, using a direct variable assignment:

Everything can be changed in an extender, including the route and URL.

Views

Item iteration in views

Here is an example using bootstrap navbar:

File Name: menus.main_menu

File Name: menu_elements (Also available under view('menu::bootstrap.default'))

This should achieve a menu looking like the default bootstrap navbar

Tips


All versions of menu with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
illuminate/support Version ^5.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 vynatu/menu contains the following files

Loading the files please wait ....