DEV Community

Cover image for Unlock Dynamic String Processing in PHP with Risma
Hadi Akbarzadeh
Hadi Akbarzadeh

Posted on

Unlock Dynamic String Processing in PHP with Risma

If you've ever wanted a lightweight, flexible way to handle dynamic content in PHP, Risma might be exactly what you need. Risma is a high-performance string processing and template engine that supports intuitive function chaining.

Why Risma?

Risma shines when you need to transform raw text into dynamic content. It's perfect for:

  • Template engines
  • Dynamic notifications
  • Content sanitization

Its key features include:

  • Variable Injection: Replace placeholders with dynamic data.
  • Function Chaining: Pipe data through multiple functions effortlessly.
  • Nested Placeholders: Resolve placeholders recursively.
  • Global & Custom Functions: Use PHP functions or your own.
  • Class Integration: Map class methods directly to your pipeline.
  • Clean Syntax: {var.func1.func2} style, intuitive and readable.

Getting Started

Install via Composer:

composer require nabeghe/risma
Enter fullscreen mode Exit fullscreen mode

Basic usage:

use Nabeghe\Risma\Risma;
$risma = new Risma();
echo $risma->render("Hello {name}!", ['name' => 'Hadi']); 
// Output: Hello Hadi!
Enter fullscreen mode Exit fullscreen mode

Function Chaining Example

$text = "Welcome, {user.strtoupper}!";
echo $risma->render($text, ['user' => 'alice']);
// Output: Welcome, ALICE!
Enter fullscreen mode Exit fullscreen mode

Direct Function Calls

$text = "Current Year: {@date('Y')}";
echo $risma->render($text, []);
// Output: Current Year: 2026
Enter fullscreen mode Exit fullscreen mode

Risma lets you write PHP-driven templates without the heavy boilerplate, keeping your code clean, dynamic, and readable.


Github & Docs

Top comments (0)