PHPackages                             thepinecode/blade-filters - 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. thepinecode/blade-filters

Abandoned → [conedevelopment/blade-filters](/?search=conedevelopment%2Fblade-filters)Project[Templating &amp; Views](/categories/templating)

thepinecode/blade-filters
=========================

Use filters easily in your blade templates.

v0.7.0(5y ago)49367.5k↓33.3%28[1 PRs](https://github.com/thepinecode/blade-filters/pulls)MITPHPPHP ^7.2.5

Since Mar 23Pushed 1y ago7 watchersCompare

[ Source](https://github.com/thepinecode/blade-filters)[ Packagist](https://packagist.org/packages/thepinecode/blade-filters)[ RSS](/packages/thepinecode-blade-filters/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (12)Used By (0)

Blade Filters
=============

[](#blade-filters)

Use string filters easily in Laravel Blade.

If you have any question how the package works, we suggest to read this post: [Laravel Blade Filters](https://pineco.de/laravel-blade-filters/).

Getting started
---------------

[](#getting-started)

You can install the package with composer, running the `composer require conedevelopment/blade-filters` command.

Using the filters
-----------------

[](#using-the-filters)

You can use the filters in any of your blade templates.

#### Regular usage:

[](#regular-usage)

```
{{ 'john' | ucfirst }} // John
```

#### Chained usage:

[](#chained-usage)

```
{{ 'john' | ucfirst | substr:0,1 }} // J

{{ '1999-12-31' | date:'Y/m/d' }} // 1999/12/31
```

#### Passing non-static values:

[](#passing-non-static-values)

```
{{ $name | ucfirst | substr:0,1 }}

{{ $user['name'] | ucfirst | substr:0,1 }}

{{ $currentUser->name | ucfirst | substr:0,1 }}

{{ getName() | ucfirst | substr:0,1 }}
```

#### Passing variables as filter parameters:

[](#passing-variables-as-filter-parameters)

```
$currency = 'HUF'

{{ '12.75' | currency:$currency }} // HUF 12.75
```

#### Built-in Laravel functionality:

[](#built-in-laravel-functionality)

```
{{ 'This is a title' | slug }} // this-is-a-title

{{ 'This is a title' | title }} // This Is A Title

{{ 'foo_bar' | studly }} // FooBar
```

### Limitations

[](#limitations)

#### Echos

[](#echos)

Laravel supports three types of echos. Raw – `{!!  !!}`, regular – `{{ }}` and escaped (legacy) – `{{{ }}}`. Filters can be used **only with regular** echos. Also, filters **cannot be used in blade directives directly**.

> Why? Raw should be as it is. Forced escaping should be escaped only, without modification.

#### Bitwise operators

[](#bitwise-operators)

Bitwise operators are allowed, but they must be wrapped in parentheses, since they are using the same "pipe operator".

```
{{ ('a' | 'b') | upper }} // C
```

The Filters
-----------

[](#the-filters)

### About the filters

[](#about-the-filters)

Filters are string functions, that are defined in the `Pine\BladeFilters\BladeFilters` facade. It has several reasons, that are discussed in the [Create custom filters](#create-custom-filters) section.

### The available filters

[](#the-available-filters)

The package comes with a few built-in filters, also the default Laravel string methods can be used.

#### Currency

[](#currency)

```
{{ '17.99' | currency:'CHF' }} // CHF 17.99

{{ '17.99' | currency:'€',false }} // 17.99 €
```

> Passing `false` as the second parameter will align the symbol to the right.

#### Date

[](#date)

```
{{ '1999/12/31' | date }} // 1999-12-31

{{ '1999/12/31' | date:'F j, Y' }} // December 31, 1999
```

#### Lcfirst

[](#lcfirst)

```
{{ 'Árpamaláta' | lcfirst }} // árpamaláta
```

> Unlike PHP's default `lcfirst()`, this filter works with multi-byte strings as well.

#### Reverse

[](#reverse)

```
{{ 'ABCDEF' | reverse }} //FEDCBA
```

#### Substr

[](#substr)

```
{{ 'My name is' | substr:0,2 }} // My

{{ 'My name is' | substr:3 }} // name is
```

#### Trim

[](#trim)

```
{{ '   trim me    ' | trim }} // trim me
```

#### Ucfirst

[](#ucfirst)

```
{{ 'árpamaláta' | ucfirst }} // Árpamaláta
```

> Unlike PHP's default `ucfirst()`, this filter works with multi-byte strings as well.

### Supported built-in Str functions

[](#supported-built-in-str-functions)

- [Str::after()](https://laravel.com/docs/5.8/helpers#method-str-after)
- [Str::before()](https://laravel.com/docs/5.8/helpers#method-str-before)
- [Str::camel()](https://laravel.com/docs/5.8/helpers#method-str-camel)
- [Str::finish()](https://laravel.com/docs/5.8/helpers#method-str-finish)
- [Str::kebab()](https://laravel.com/docs/5.8/helpers#method-str-kebab)
- [Str::limit()](https://laravel.com/docs/5.8/helpers#method-str-limit)
- [Str::plural()](https://laravel.com/docs/5.8/helpers#method-str-plural)
- [Str::singular()](https://laravel.com/docs/5.8/helpers#method-str-singular)
- [Str::slug()](https://laravel.com/docs/5.8/helpers#method-str-slug)
- [Str::snake()](https://laravel.com/docs/5.8/helpers#method-str-snake)
- [Str::start()](https://laravel.com/docs/5.8/helpers#method-str-start)
- [Str::studly()](https://laravel.com/docs/5.8/helpers#method-str-studly)
- [Str::title()](https://laravel.com/docs/5.8/helpers#method-str-title)

Create custom filters
---------------------

[](#create-custom-filters)

As it was mentioned before, every filter is a method that can be called through the `Pine\BladeFilters\BladeFilters` facade. It has several reasons why is this approach better, but let's take the most important ones:

- It's easy to define custom filters by extending the facade with the `BladeFilters::macro()`,
- No extra files, autoloading or class mapping, it's enough to use any service provider to define filters,
- By default Laravel provides a bunch of handy methods that we can use as filters.

### Parameter ordering

[](#parameter-ordering)

PHP is not very strict regarding to function's parameter ordering and this way it's easier to coordiante or override them. Also, sometimes it happens with Laravel's string functions. It's important that only those functions can be used, that accept the parameters in the following order:

1. The value to be transformed
2. Any other parameter if needed

For example:

```
BladeFilters::macro('filterName', function ($value, $param1 = 'default', $param2 = null) {
    return ...;
});

{{ 'string' | filterName:1,2 }}
```

### Defining custom filters

[](#defining-custom-filters)

Since the filters are only methods that are defined in the `Str` facade and the `BladeFilters` class, to create filters, you need to create a macro in a service provider's `boot()` method.

```
class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        BladeFilters::macro('substr', function ($value, $start, $length = null) {
            return mb_substr($value, $start, $length);
        });
    }
}
```

Contribute
----------

[](#contribute)

If you found a bug or you have an idea connecting the package, feel free to open an issue.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

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

###  Release Activity

Cadence

Every ~54 days

Recently: every ~89 days

Total

11

Last Release

2071d ago

PHP version history (3 changes)v0.1.0PHP ^7.1

v0.3.2PHP ^7.0

v0.6.0PHP ^7.2.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/71387432?v=4)[Cone](/maintainers/conedevelopment)[@conedevelopment](https://github.com/conedevelopment)

---

Top Contributors

[![iamgergo](https://avatars.githubusercontent.com/u/6567179?v=4)](https://github.com/iamgergo "iamgergo (56 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![jpscharf](https://avatars.githubusercontent.com/u/1039984?v=4)](https://github.com/jpscharf "jpscharf (1 commits)")[![SeanJA](https://avatars.githubusercontent.com/u/102889?v=4)](https://github.com/SeanJA "SeanJA (1 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (1 commits)")[![tomsix](https://avatars.githubusercontent.com/u/60874146?v=4)](https://github.com/tomsix "tomsix (1 commits)")[![baukevdw](https://avatars.githubusercontent.com/u/6784391?v=4)](https://github.com/baukevdw "baukevdw (1 commits)")[![vaedasti](https://avatars.githubusercontent.com/u/21108028?v=4)](https://github.com/vaedasti "vaedasti (1 commits)")[![Gymnasiast](https://avatars.githubusercontent.com/u/1478678?v=4)](https://github.com/Gymnasiast "Gymnasiast (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thepinecode-blade-filters/health.svg)

```
[![Health](https://phpackages.com/badges/thepinecode-blade-filters/health.svg)](https://phpackages.com/packages/thepinecode-blade-filters)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k454.7k15](/packages/robsontenorio-mary)[livewire/blaze

A tool for optimizing Blade component performance by folding them into parent templates

688221.3k17](/packages/livewire-blaze)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)[konekt/html

HTML and Form Builders for the Laravel Framework

24403.2k5](/packages/konekt-html)

PHPackages © 2026

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