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

ActiveProject[Templating &amp; Views](/categories/templating)

conedevelopment/blade-filters
=============================

Use filters easily in your blade templates.

v1.2.0(1y ago)493150.9k↓28.3%28[1 PRs](https://github.com/conedevelopment/blade-filters/pulls)1MITPHPPHP ^7.3 || ^8.0

Since Mar 23Pushed 1y ago7 watchersCompare

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

READMEChangelog (9)Dependencies (4)Versions (16)Used By (1)

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

53

—

FairBetter than 97% of packages

Maintenance48

Moderate activity, may be stable

Popularity53

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity72

Established project with proven stability

 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 ~159 days

Recently: every ~423 days

Total

15

Last Release

380d ago

Major Versions

v0.8.0 → v1.0.02022-02-19

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

v0.3.2PHP ^7.0

v0.6.0PHP ^7.2.5

v0.8.0PHP ^7.2.5 | ^8.0

v1.0.0PHP ^7.3 || ^8.0

### 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/conedevelopment-blade-filters/health.svg)

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

###  Alternatives

[rcrowe/twigbridge

Adds the power of Twig to Laravel

9105.9M50](/packages/rcrowe-twigbridge)[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[moonshine/moonshine

Laravel administration panel

1.3k217.1k59](/packages/moonshine-moonshine)[livewire/blaze

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

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

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

703141.0k7](/packages/tallstackui-tallstackui)

PHPackages © 2026

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