FAQ

laravel-rust-format Alpha Laravel for Rust

Used in production across multiple projects.

Do I need PHP to use this?

PHP generates the reference fixtures when contributing. The Rust formatting code runs without PHP, Composer or a system ICU library.

Which crate should I add?

Use laravel-rust-format-core for the Rust functions. Use laravel-rust-format for the provider and MiniJinja filters in a Laravel for Rust app. Installation

Which number formatter matches my Blade expression?

Use php::number_format for PHP’s number_format() and number::format for Laravel’s Number::format(). Their defaults and rounding differ. For plain numeric interpolation, use php::echo in Rust or php_echo in MiniJinja. PHP functions

Why did my slug or truncated string change?

The framework’s native Str trait and PHP Laravel’s Str use different rules. Use the crate’s str::slug to preserve Laravel transliteration and str::limit to keep its width budget. Keep custom slug language, dictionary and separator options with any persisted slug contract. Strings

Can I reuse my PHP date pattern?

Pass it to carbon::format or carbon_format in a template. The framework’s built-in date filter uses strftime patterns. Dates

Why is my relative time different in a test?

Pass a fixed instant to the core. Choose Relative::Now for clock wording or Relative::To for comparison wording. In an application template, freeze the Laravel clock or pass an explicit other date. Laravel integration

Are currencies localized?

Pass a number::Locale in Rust or a locale argument to number_currency in a template. The currency code selects the unit, and the locale selects how to write it. Numbers · Parity

Can I disable Markdown or random generation?

Set default-features = false on the core dependency. Add back markdown or random individually when needed. PCRE2 is required for string matching. Cargo features

Why does my Markdown appear as text in a view?

MiniJinja escapes the generated tags. Use safe only for HTML you trust. For the Markdown options and the escapes used by PHP and MiniJinja, see Templates.

Where should I look for a byte difference?

Check the formatter family first. Then compare the raw string, including non-breaking spaces, minus signs and any trailing bytes. Check PHP, ICU, Unicode and tzdata versions against the fixture header. If the formatter matches and the rendered page differs, check template escaping. Parity

How do I port Blade’s @js directive?

Use js_from to produce the Laravel JavaScript expression in a script element. Use php_json_encode with HTML autoescaping to store JSON in an HTML attribute. Template encoder options

How do I parse month-only input?

Use carbon::create_from_format("!Y-m", "2024-02", &zone) or pipe the text to carbon_create_from_format("!Y-m") in MiniJinja. The reset modifier fills in the first day of the month at midnight. Dates

Community package, not affiliated with Laravel.