PHPackages                             michalhisim/stylus - 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. michalhisim/stylus

ActiveLibrary

michalhisim/stylus
==================

Stylus preprocessor for PHP

0201PHP

Since Jan 29Pushed 12y ago1 watchersCompare

[ Source](https://github.com/michalhisim/Stylus.php)[ Packagist](https://packagist.org/packages/michalhisim/stylus)[ RSS](/packages/michalhisim-stylus/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Stylus.php
==========

[](#stylusphp)

A Stylus parser for PHP

---

\###CSS needs a hero... again When I first saw [Stylus](http://learnboost.github.com/stylus/) I thought it was amazing and I implemented it into my nodejs application. When I started my next project, which was a PHP project, I liked Stylus so much that I wanted to implement it into my PHP project as well. Surprisingly, I couldn't find any Stylus parser for PHP. So I did as any developer would do and created my own. And I want to share it.

\##Current Features

- Omit braces
- Omit colons
- Omit semi-colons
- Custom functions
- Importing other files
- '&amp;' parent reference
- Mixins
- Interpolation
- Variables

\##Using Stylus.php Using Stylus.php is really easy! Just include the following code:

```
require('Stylus.php');

$stylus = new Stylus();
$stylus->setReadDir('read');
$stylus->setWriteDir('write');
$stylus->setImportDir('import'); //if you import a file without setting this, it will import from the read directory
$stylus->parseFiles();

```

And that's all there is to it! Now a quick note about the `parseFiles()` function. It has one parameter called `overwite` which defaults to `false`. It is a flag indicating whether or not you want to overwrite your already parsed Stylus files.

This means that you could include this code on every page and you won't be parsing your Stylus files every time. But make sure that you set `overwrite` to `true` when you are developing or updating your Stylus files so the changes will be reflected in your site.

\###Parse a Single File It is possible to only parse one file. Instead of calling `parseFiles()` you simply just call `parseFile('my_styl')`. `parseFile()`'s second parameter is the `overwrite` flag. If you wanted to parse a file on every page load but didn't want to parse every file you could use this to do so.

```
$stylus->parseFile('my_file', true);
$stylus->parseFiles();

```

\##Assigning Variables Assigning variables is done the same way as in regular Stylus. But you now have the option of adding variables from PHP before parsing the stylus files by calling the `assign` function. Here is an example:

**PHP**

```
$stylus->assign('px_size', '30px');
$stylus->parseFiles();

```

**Stylus**

```
div
 font-size px_size

```

**Yields**

```
div {
    font-size: 30px;
}

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2785aa4a56bf2572d717480cc37dcba144cfad9e9f97cdb33dcb0929824d3749?d=identicon)[michalhisim](/maintainers/michalhisim)

---

Top Contributors

[![AustP](https://avatars.githubusercontent.com/u/2007045?v=4)](https://github.com/AustP "AustP (17 commits)")[![michalhisim](https://avatars.githubusercontent.com/u/764249?v=4)](https://github.com/michalhisim "michalhisim (2 commits)")

### Embed Badge

![Health badge](/badges/michalhisim-stylus/health.svg)

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

PHPackages © 2026

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