Download the PHP package chh/jazz without Composer

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

Jazz

When you absolutely, positively have to generate HTML within PHP Code.

Jazz is a very tiny library which turns a nested Array into HTML. You could call it a "DSL" if you want. It works well with PHP later than 5.3.3 but looks best with 5.4's new short array syntax.

I wrote Jazz, because there are always places where you have to generate a bit of HTML and don't want to use a template, for the sake of performance or simplicity.

At first you need only one tag, you think "Fine I'm using a String", and then you need to add an attribute, then a second one, maybe a third one. Then you find yourself in a big mess.

I've written plenty of those code bits, and I'm tired of it:

$html  = '<div class="widget '.join(" ", $classes).'" id="'.$id.'" style="display: none;" data-widget-name="' . $widgetName . '">';
$html .= '<ul>' . $this->getSomeListItems() . '</ul>';
$html .= '</div>';

It's not only hard to grasp, but also plain ugly and also adding attributes, or adding other sub elements is cumbersome.

Now relax with some Jazz:

array_unshift($classes, "widget");

$attrs = [
    "class" => $classes, 
    "id" => $id, 
    "style" => "display: none;", 
    "data-widget-name" => $widgetName
];

$html = Jazz::render(
    ["#div", $attrs, [
        ["#ul", $this->getSomeListItems()]
    ]]
);

It's in this case not shorter, but it's easily extendable, and the intent is clear.

Hello World

<?php

use Jazz;

$html = [
    # What a funky Headline!
    ["#h1", "Hello World"],

    # This is PHP Code, so comments work as expected.
    ["#p", ["class" => "intro"], [
        "Jazz turns a nested, \"lispy\" array into HTML using a simple syntax.",

        ["#a", ["href" => "https://github.com/CHH/Jazz"], [
            "Jazz is awesome."
        ]]
    ]]
];

echo Jazz::render($html);
# <h1>Hello World</h1>
# <p class="intro">Jazz turns a nested, "lispy" array into HTML using a simple syntax.
# <a href="https://github.com/CHH/Jazz">Jazz is awesome.</a>
# </p>

Syntax

Tags

A tag is an array of up to three elements (where $attributes and $body are optional):

Synopsis

["#$tagName", $attributes, $body]

When attributes are left out, the second element in the tag is treated as body.

Tags can be written in different forms, just like in HTML:

Install

Get composer:

% wget http://getcomposer.org/composer.phar

Require chh/jazz in your application's composer.json:

{
    "require": {
        "chh/jazz": "*"
    }
}

Then install the defined dependencies:

% php composer.phar install

Load composer's class loader:

<?php

require_once("vendor/.composer/autoload.php");

Not using composer? The lib/Jazz.php file has no dependencies, so you can grab this file, copy it to your project directory and require it in your application (though you should at least consider using composer in your application anyway).

License

Jazz is licensed under the MIT license, bundled with the Source Code in the file LICENSE.txt.


All versions of jazz with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 chh/jazz contains the following files

Loading the files please wait ....