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 🙏

© 2024 – Pkg Stats / Ryan Hefner

phazor

v0.3.1

Published

A quicker PHP syntax similar to Razor Web Pages.

Downloads

13

Readme

Phazor

A quicker PHP syntax similar to Razor Web Pages.

<head>
    ${
        $title = "I love fruit";
        $isFruit = true;
    }
    <title>$(ucwords($title))</title>
</head>
<body>
    <h1>$title.</h1>
    $if ($isFruit) {
        <p>It sure is great!</p>
    }
</body>

Install Phazor with NPM npm i phazor -g.

Run the compiler "phazor sourceFolder destinationFolder" from the parent directory.

Links

NPM Package

Visual Studio Code Extension

Github Repository

Overview

Add PHP code using the $ symbol.

Code Blocks - ${ -php- }

${ $message = "I like fruit."; }

Compiles to:

<?php $message = "I like fruit."; ?>

Inline Expressions - $variable

<p>$message</p>

Compiles to:

<p><?php echo $message; ?></p>

For complex expressions use parenthesis - $().

<p>$($cost * 2)</p>

Compiles to:

<p><?php echo $cost * 2; ?></p>

Statements - $statement ( -parameters- ) { -php- }

$if ($condition == true) {
    <p>$message</p>
}

Compiles to:

<?php if ($condition == true) { ?>
    <p><?php echo $message; ?></p>
<?php } ?>

Comments - /* -comment- */

Comments work the same as multiline php comments.

${
    /* Set the price */
    $cost = "$1.99";
}
<h1>Buy Fruit</h1>
/* How much the fruit will cost */
<p>That fruit will cost you $cost each.</p>

Escape Entity - $$

Escape "$" in HTML.

<p>That fruit will cost you $$1.99 each.</p>

Compiles to:

<p>That fruit will cost you $1.99 each.</p>

Basic Example

Install Phazor with NPM npm i phazor -g.

Create a folder.

Create a .ph file inside the folder:

<!DOCTYPE html>
<html>
<head>
    ${
        $title = 'Fruit for Sale';
        $fruits = array('strawberries' => 'red',
            'oranges' => 'orange',
            'pineapples' => 'yellow',
            'kiwis' => 'green',
            'blueberries' => 'blue',
            'grapes' => 'purple');
    }
    <title>$title.</title>
    <link rel="stylesheet" type="text/css" href="main.css" />
    <script src="main.js"></script>
</head>
<body>
    <div id="page">
        <h1>$title</h1>
        <ul>
            $foreach ($fruits as $fruit => $color) {
                <li style="color: $color;">
                    $(ucwords($fruit))
                    $if ($color == "green") {
                        <strong>- Meh.</strong>
                    } else if($color == "orange") {
                        <strong>- Yum!</strong>
                    }
                </li>
            }
        </ul>
        <p>All these fruits together will cost $$100.</p>
    </div>
</body>
</html>

Run the compiler "phazor sourceFolder destinationFolder" from the parent directory.

Phazor outputs the following .php file into the destination folder:

<!DOCTYPE html>
<html>
<head>
    <?php 
        $title = 'Fruit for Sale';
        $fruits = array('strawberries' => 'red',
            'oranges' => 'orange',
            'pineapples' => 'yellow',
            'kiwis' => 'green',
            'blueberries' => 'blue',
            'grapes' => 'purple');
    ?>
    <title><?php echo $title; ?>.</title>
    <link rel="stylesheet" type="text/css" href="main.css" />
    <script src="main.js"></script>
</head>
<body>
    <div id="page">
        <h1><?php echo $title; ?></h1>
        <ul>
            <?php foreach ($fruits as $fruit => $color) { ?>
                <li style="color: <?php echo $color; ?>;">
                    <?php echo ucwords($fruit); ?>
                    <?php if ($color == "green") { ?>
                        <strong>- Meh.</strong>
                    <?php } else if($color == "orange") { ?>
                        <strong>- Yum!</strong>
                    <?php } ?>
                </li>
            <?php } ?>
        </ul>
        <p>All these fruits together will cost $100.</p>
    </div>
</body>
</html>

Which renders in the browser:

Fruit for Sale

  • Strawberries
  • Oranges - Yum!
  • Pineapples
  • Kiwis - Meh.
  • Blueberries
  • Grapes

All these fruits together will cost $100.