npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

teal-php

v0.14.9

Published

PHP runtime for Teal

Readme

Use teal-php to compile your .tl files to PHP.

Getting started

In the follwing guide we'll create four files to get the first Teal-PHP Hello World app running.

1. package.json

Create an empty directory for your project and call:

npm init

This will create an empty package.json file. In order to add teal-php run:

npm i -S teal-php

Create a directory called site in your project root where you put your PHP files.

Inside this directory create a folder called _tl. This is where the Teal templates will be placed.

/
├── build.js
├── package.json
└─┬ site/
  ├─┬ _tl/
  │ └── page.tl
  └── index.php

2. /site/index.php

In order to render a Teal template in PHP you have to include /_tl/init.php and call the tl() function:

<?php

require '_tl/init.php';

echo tl('/page',
  [ 'title' => 'Hello' ],
  'Hello World!'
);

Note: Don't worry that the init.php doesn't exist yet. Teal will create for you in the next step.

3. /site/_tl/page.tl

html {
  head {
    title { $title }
    stylesheet()
  }
  body {
    background: teal;
    color: #fff;
    $children
  }
}

4. /build.js

Now create a file called build.js in your project's root directory (not the site folder). This is the place where you can configure Teal and set up additional plugins like teal-autoprefixer or teal-browserify.

var teal = require('teal-php');

var tl = teal({
  docroot: './site'
});

// add the autoprefixer plugin:
// tl.use(require('teal-autoprefixer'));

You can now build your project by running:

node build

This will create a folder called .site. All php sources will be copied there and all .tl will be compiled to .tl.php files. After this step your directory should look like this:

/
├─┬ .site/
│ ├─┬ _tl/
│ │ ├── init.php
│ │ └── page.tl.php
│ └─ index.php
├── build.json
├── package.json
└─┬ site/
  ...

Starting a development server

Teal-php comes with a built-in development server. If you pass the dev:true option, teal will watch your source files and start a PHP server.

Modify your build.js file to read some command line arguments:

var teal = require('teal-php')

var dev = process.argv[2] == 'dev'
var port = process.argv[3]

var tl = teal({
  docroot: __dirname + '/site',
  dev: dev,
  port: port
})

Then run node build dev 3000 to start a server. If you omit the port, teal-php will choose a free random and automatically open a browser window.

Options

  • docroot – Specifies where the PHP sources are located. Relative paths are resolved against the current working directory. Defaults to "./site"

  • dest – Where the build process will put all files. If not specified, a directory right next to the docroot will be created (prefixed with a dot). Letting this point to same directory as as docroot is a valid option, too. In this case no copy operations will be performed. Defaults to undefined

  • asseturl – The URL prefix under which assets will be exposed. Defaults to "/assets"

  • assetdest Where the assets will be stored. Relative paths are resolved against dest. Defaults to dest + asseturl

  • tlroot – Specifies where the .tl are located. Relative paths are resolved against the docroot. Defaults to "_tl"

  • tldest – Where within dest the compiled .tl.php files will be stored. Defaults to "_tl"

  • ext – File extension to use for the compiled templates. Defaults to ".tl.php"

  • lib – Filename under which the Teal PHP library will be stored. Relative paths are resolved against tldest. Defaults to init.php

  • php – Options to be passed to the php-proxy-middleware.