GithubHelp home page GithubHelp logo

oportier / knpmenu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from knplabs/knpmenu

0.0 0.0 0.0 660 KB

Menu Library for PHP

Home Page: https://knplabs.com

License: MIT License

PHP 97.82% Twig 2.18%

knpmenu's Introduction

KnpMenu

The KnpMenu library provides object oriented menus for PHP. It is used by the KnpMenuBundle for Symfony but can now be used stand-alone.

Build Status Latest Stable Version Latest Unstable Version Gitter chat

Installation

KnpMenu uses Composer, please checkout the composer website for more information.

The simple following command will install knp-menu into your project. It also add a new entry in your composer.json and update the composer.lock as well.

$ composer require knplabs/knp-menu

KnpMenu follows the PSR-4 convention names for its classes, which means you can easily integrate knp-menu classes loading in your own autoloader.

Getting Started

<?php

// Include dependencies installed with composer
require 'vendor/autoload.php';

use Knp\Menu\MenuFactory;
use Knp\Menu\Renderer\ListRenderer;

$factory = new MenuFactory();
$menu = $factory->createItem('My menu');
$menu->addChild('Home', ['uri' => '/']);
$menu->addChild('Comments', ['uri' => '#comments']);
$menu->addChild('Symfony', ['uri' => 'http://symfony.com/']);
$menu->addChild('Happy Awesome Developers');

$renderer = new ListRenderer(new \Knp\Menu\Matcher\Matcher());
echo $renderer->render($menu);

The above menu would render the following HTML:

<ul>
  <li class="first">
    <a href="/">Home</a>
  </li>
  <li class="current">
    <a href="#comments">Comments</a>
  </li>
  <li>
    <a href="http://symfony.com/">Symfony</a>
  </li>
  <li class="last">
    <span>Happy Awesome Developers</span>
  </li>
</ul>

This way you can finally avoid writing an ugly template to show the selected item, the first and last items, submenus, ...

The bulk of the documentation can be found in the doc directory.

What now?

Follow the tutorial in doc/01-Basic-Menus.md and doc/02-Twig-Integration.md to discover how KnpMenu will rock your world!

Find all available documentation at doc/.

Maintainers

This library is maintained by the following people (alphabetically sorted) :

  • @derrabus
  • @garak
  • @stof

Credits

This bundle was originally ported from ioMenuPlugin, a menu plugin for symfony1. It has since been developed by KnpLabs and the Symfony community.

knpmenu's People

Contributors

stof avatar nek- avatar garak avatar dbu avatar sebastianljunggren avatar pzaloznyi avatar derrabus avatar bamarni avatar wouterj avatar doncallisto avatar weaverryan avatar oskarstark avatar hason avatar jfsimon avatar bchoquet-heliopsis avatar seferov avatar u01jmg3 avatar preimers avatar b4rb4ross4 avatar havvg avatar burki avatar ndm2 avatar naderman avatar nicolasmure avatar sagikazarmark avatar mbontemps avatar althaus avatar leokolln avatar krymen avatar korstiaan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.