PHPackages                             corn-wand/corn-wand - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. corn-wand/corn-wand

ActiveLibrary[Templating &amp; Views](/categories/templating)

corn-wand/corn-wand
===================

PHP functional library for generating HTML

0.5.1(11y ago)1721MITPHPPHP &gt;=5.3.0

Since Jun 9Pushed 8y ago1 watchersCompare

[ Source](https://github.com/al-codepone/corn-wand)[ Packagist](https://packagist.org/packages/corn-wand/corn-wand)[ Docs](https://github.com/al-codepone/corn-wand)[ RSS](/packages/corn-wand-corn-wand/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)DependenciesVersions (3)Used By (1)

Corn Wand
=========

[](#corn-wand)

Corn Wand is a PHP functional library for generating HTML.

Documentation
-------------

[](#documentation)

All functions have a DocBlock. So you can read the source code or generate documentation with [phpDocumentor](http://phpdoc.org/).

Requirements
------------

[](#requirements)

**PHP 5.3** or higher

Source Code
-----------

[](#source-code)

The [project](https://github.com/al-codepone/corn-wand) is on GitHub. The actual source code is in a [single file](https://github.com/al-codepone/corn-wand/blob/master/src/corn-wand.php).

Tests
-----

[](#tests)

All tests are in the [test directory](https://github.com/al-codepone/corn-wand/tree/master/test). Each test is a standalone PHP script. There is a test for each function; the name of the test script is the function name. Some tag functions don't have tests.

Installation
------------

[](#installation)

Install using composer:

```
{
    "require": {
        "corn-wand/corn-wand": "0.5.1",
    }
}
```

or you can install manually:

```
require 'corn-wand.php';
```

Tag Functions
-------------

[](#tag-functions)

There's a function for each HTML tag. Here's the list of supported tags:

`a`, `abbr`, `address`, `area`, `article`, `aside`, `audio`, `b`, `base`, `bdi`, `bdo`, `blockquote`, `body`, `br`, `button`, `canvas`, `caption`, `cite`, `code`, `col`, `colgroup`, `content`, `data`, `datalist`, `dd`, `decorator`, `del`, `details`, `dfn`, `div`, `dl`, `dt`, `element`, `em`, `embed`, `fieldset`, `figcaption`, `figure`, `footer`, `form`, `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, `head`, `header`, `hr`, `html`, `i`, `iframe`, `img`, `input`, `ins`, `kbd`, `keygen`, `label`, `legend`, `li`, `link`, `main`, `map`, `mark`, `math`, `menu`, `menuitem`, `meta`, `meter`, `nav`, `noscript`, `object`, `ol`, `optgroup`, `option`, `output`, `p`, `param`, `pre`, `progress`, `q`, `rp`, `rt`, `ruby`, `s`, `samp`, `script`, `section`, `select`, `shadow`, `small`, `source`, `span`, `strong`, `style`, `sub`, `summary`, `sup`, `svg`, `table`, `tbody`, `td`, `template`, `textarea`, `tfoot`, `th`, `thead`, `time`, `title`, `tr`, `track`, `u`, `ul`, `var`, `video`, `wbr`.

All tag function names are the name of the tag except for `var`. Use `_var()` instead. All the tag functions work the same way: if the first agrument is an array then it is the tag attributes. All other arguments are concatenated together to form the tag content. Examples:

```
echo c\br(); //
echo c\html(); //
echo c\p(); //
```

```
echo c\div('hello'); //hello
```

```
echo c\div(array('id' => 'hi')); //
```

```
echo c\div(
    array('id' => 'hi'),
    'hello');

//hello
```

```
echo c\p('red ', 'yellow ', 'blue');

//red yellow blue
```

```
echo c\p(
    array('id' => 'colors'),
    'red ',
    'yellow ',
    'blue');

//red yellow blue
```

```
echo c\input(array(
    'id' => 'agree',
    'type' => 'checkbox',
    'checked'));

//
```

```
echo c\div(c\span('ok Dad'));

/*

    ok Dad

*/
```

```
echo
c\ul(
    c\li('item 1'),
    c\li('item 2'),
    c\li('item 3'));

/*

    item 1
    item 2
    item 3

*/
```

```
echo
c\html(
    array('lang' => 'en'),
    c\head(
        c\title('My Page')),
    c\body(
        c\h1('My Page')));

/*

        My Page

        My Page

*/
```

More Functions
--------------

[](#more-functions)

There are many more functions. These functions return more intricate HTML.

### html5()

[](#html5)

`html5()` works like `html()` but has the HTML5 doctype in front:

```
echo c\html5(c\body('hi'));

/*

    hi

*/
```

### hlink()

[](#hlink)

Get a hyperlink:

```
echo c\hlink('http://github.com');

//http://github.com
```

```
echo c\hlink('http://github.com', 'GitHub');

//GitHub
```

### css() and js()

[](#css-and-js)

`css()` and `js()` work similarly:

```
echo c\css('one.css', 'two.css', 'three.css');

/*

*/
```

```
echo c\js('menu.js', 'game.js', 'slide-show.js');

/*

*/
```

You can use an array for these if you like:

```
$css = array('all.css', 'header.css', 'nav.css');
echo c\css($css);

/*

*/
```

### ulist() and olist()

[](#ulist-and-olist)

Get `` or `` with items:

```
echo c\ulist('seven', 'six', 'five');

/*

    seven
    six
    five

*/
```

```
echo c\olist(
    'salsa',
    'bbq',
    'cheese',
    array('type' => 'i'));

/*

    salsa
    bbq
    cheese

*/
```

You can use an array for the items:

```
$items = array('salsa', 'bbq', 'cheese');
echo c\olist(
    $items,
    array('type' => 'i'));

/*

    salsa
    bbq
    cheese

*/
```

Use a nested array to set item attributes:

```
echo c\olist(array(
    'salsa',
    'bbq' => array('id' => 'mid'),
    'cheese'));

/*

    salsa
    bbq
    cheese

*/
```

### focus()

[](#focus)

Call JavaScript `focus()` on a CSS id:

```
echo c\focus('username');

//document.getElementById('username').focus();
```

### linput() and dlinput()

[](#linput-and-dlinput)

`linput()` is for a label and an input:

```
echo c\linput(
    'First Name',
    array('value' => 'Fred'));

/*
First Name

*/
```

Setting `id` will set other attributes:

```
echo c\linput(
    'First Name',
    array(
        'value' => 'Fred',
        'id' => 'first'));

/*
First Name

*/
```

`dlinput()` is the same but with a container div:

```
echo c\dlinput(
    'Email',
    array('id' => 'email'));

/*

    Email

*/
```

### ltextarea() and dltextarea()

[](#ltextarea-and-dltextarea)

`ltextarea()` is for a label and a textarea:

```
echo c\ltextarea(
    'Your Message',
    array('name' => 'message'));

/*
Your Message

*/
```

Setting `id` will set other attributes:

```
echo c\ltextarea(
    'Your Message',
    array('id' => 'message'),
    'Hello there');

/*
Your Message
Hello there
*/
```

`dltextarea()` is the same but with a container div:

```
echo c\dltextarea(
    'Your Message',
    array('id' => 'message'));

/*

    Your Message

*/
```

### drop\_down(), ldrop\_down() and dldrop\_down()

[](#drop_down-ldrop_down-and-dldrop_down)

`drop_down()` is for a select tag:

```
echo c\drop_down(
    array(
        'small',
        'medium',
        'large'),
    array('id' => 'size'));

/*

    small
    medium
    large

*/
```

`ldrop_down()` adds a label:

```
echo c\ldrop_down(
    'Season',
    array(
        'f' => 'Fall',
        'w' => 'Winter',
        's' => 'Spring'),
    array('id' => 'season'));

/*
Season

    Fall
    Winter
    Spring

*/
```

`dldrop_down()` adds a div and a label:

```
echo c\dldrop_down(
    'Sports',
    array(
        1 => 'soccer',
        'basketball',
        'baseball',
        'rugby'),
    array(
        'id' => 'sports',
        'multiple'),
    array(1, 2));

/*

    Sports

        soccer
        basketball
        baseball
        rugby

*/
```

### checkboxes(), scheckboxes() and dscheckboxes()

[](#checkboxes-scheckboxes-and-dscheckboxes)

`checkboxes()` is for a group of checkboxes. Each checkbox renders using `dlinput()`:

```
echo c\checkboxes(
    'color',
    array(
        'beige',
        'cyan',
        'puce'));

/*

    beige

    cyan

    puce

*/
```

`scheckboxes()` adds a title span:

```
echo c\scheckboxes(
    'Pets',
    'pet',
    array(
        'dog' => 'Dog',
        'cat' => 'Cat',
        'fish' => 'Fish'));

/*
Pets

    Dog

    Cat

    Fish

*/
```

`dscheckboxes()` adds a container div and a title span:

```
echo c\dscheckboxes(
    'Drinks',
    'drink',
    array(
        'water',
        'OJ',
        'milk'));

/*

    Drinks

        water

        OJ

        milk

*/
```

### radio\_buttons(), sradio\_buttons() and dsradio\_buttons()

[](#radio_buttons-sradio_buttons-and-dsradio_buttons)

`radio_buttons()` is for a group of radio buttons. Each radio button renders using `dlinput()`:

```
echo c\radio_buttons(
    'bed',
    array(
        'single',
        'queen',
        'king'));

/*

    single

    queen

    king

*/
```

`sradio_buttons()` adds a title span:

```
echo c\sradio_buttons(
    'City',
    'city',
    array(
        'nyc' => 'New York',
        'queens' => 'Queens',
        'flagstaff' => 'Flagstaff'));

/*
City

    New York

    Queens

    Flagstaff

*/
```

`dsradio_buttons()` adds a container div and a title span:

```
echo c\dsradio_buttons(
    'Planet',
    'planet',
    array(
        'Venus',
        'Mars',
        'Saturn'),
    0);

/*

    Planet

        Venus

        Mars

        Saturn

*/
```

LICENSE
-------

[](#license)

MIT

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Total

2

Last Release

4333d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dde0ea39d89e43216fff0c3b80d61ffd6293e9632d5b6f2f20ca48847cba7894?d=identicon)[hadramoo](/maintainers/hadramoo)

---

Top Contributors

[![ferg1e](https://avatars.githubusercontent.com/u/2236096?v=4)](https://github.com/ferg1e "ferg1e (124 commits)")

---

Tags

htmlfunctionfunctionalfunctions

### Embed Badge

![Health badge](/badges/corn-wand-corn-wand/health.svg)

```
[![Health](https://phpackages.com/badges/corn-wand-corn-wand/health.svg)](https://phpackages.com/packages/corn-wand-corn-wand)
```

###  Alternatives

[phpoffice/phpword

PHPWord - A pure PHP library for reading and writing word processing documents (OOXML, ODF, RTF, HTML, PDF)

7.5k34.7M186](/packages/phpoffice-phpword)[latte/latte

☕ Latte: the intuitive and fast template engine for those who want the most secure PHP sites. Introduces context-sensitive escaping.

1.3k15.7M683](/packages/latte-latte)[twig/string-extra

A Twig extension for Symfony String

21946.0M133](/packages/twig-string-extra)[exercise/htmlpurifier-bundle

HTMLPurifier integration for your Symfony project

27911.3M16](/packages/exercise-htmlpurifier-bundle)[twig/markdown-extra

A Twig extension for Markdown

12114.3M83](/packages/twig-markdown-extra)[laminas/laminas-view

Fast and type safe HTML templating library with a flexible plugin system supporting multistep template composition

7526.3M230](/packages/laminas-laminas-view)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
