PHPackages                             neemzy/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. neemzy/stylus

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

neemzy/stylus
=============

Stylus preprocessor for PHP

492.8k17[3 issues](https://github.com/AustP/Stylus.php/issues)PHP

Since May 10Pushed 10y ago10 watchersCompare

[ Source](https://github.com/AustP/Stylus.php)[ Packagist](https://packagist.org/packages/neemzy/stylus)[ RSS](/packages/neemzy-stylus/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#stylusphp)

A Stylus parser for PHP

---

### CSS needs a hero... again

[](#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
----------------

[](#current-features)

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

Using Stylus.php
----------------

[](#using-stylusphp)

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 or strings

[](#parse-a-single-file-or-strings)

Instead of compiling all the files in the read directory, you can choose exactly what to do using the following syntax.

```
// From string to string
$css = $stylus->fromString("body\n  color black")->toString();

// From string to file
$stylus->fromString("body\n color black")->toFile("out.css");

// From file to string
$css = $stylus->fromFile("in.styl")->toString();

// From file to file
$stylus->fromFile("in.styl")->toFile("out.css");
```

`toFile($file, $overwrite)` takes two parameter, both of them optional.

- `$file`: The filename to write to, if ommited or null it will take the input filename and change `.styl` to `.css`.
- `$overwrite`: Specifies wheter or not to parse and write the file if a file with the same name is found.

Assigning Variables
-------------------

[](#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

29

—

LowBetter than 57% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.2% 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/fe93bd0e4a53d8e1a9ed853202416277320675c57f34c4f5961019cb8bb0095d?d=identicon)[neemzy](/maintainers/neemzy)

---

Top Contributors

[![AustP](https://avatars.githubusercontent.com/u/2007045?v=4)](https://github.com/AustP "AustP (23 commits)")[![LinusU](https://avatars.githubusercontent.com/u/189580?v=4)](https://github.com/LinusU "LinusU (11 commits)")[![kylekatarnls](https://avatars.githubusercontent.com/u/5966783?v=4)](https://github.com/kylekatarnls "kylekatarnls (3 commits)")

### Embed Badge

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

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

###  Alternatives

[careship/functional-php

A monad-like set of utilities for PHP, type-checked by Psalm.

108.4k](/packages/careship-functional-php)

PHPackages © 2026

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