crodas/simple-view-engine
A simple, fast PHP view engine with a lightweight template syntax. It compiles templates to plain PHP for speed, supports template inheritance and output escaping, and drops into existing PHP projects without heavy dependencies or framework lock-in.
Architecture fit. SimpleView is a standalone extraction of Laravel 4's Blade compiler, repurposed from HTML rendering to code generation. That gives it one genuine architectural virtue: the template dialect is immediately legible to any Laravel developer, so authoring generators for models, migrations, DTOs, or config scaffolding requires no new syntax training. The fit degrades sharply beyond that. It is not a Laravel package in the modern sense — no service provider, no facade, no container bindings, no integration with Illuminate\View. Adopting it means running a second, parallel rendering path beside the framework's own view layer, with its own cache directory, its own compiler lifecycle, and its own escaping rules. For a team already on Laravel, this is architectural duplication rather than extension. The package is best positioned as an isolated build-time tool — a make: command or CI generation step — never as a runtime dependency serving user-facing output.
Integration feasibility. Composer installation is straightforward in principle, but the package dates to the Laravel 4 era (PHP 5.3/5.4 constraints, pre-PSR-4 conventions in places, no type declarations). On a modern PHP 8.x runtime it will almost certainly require patching before it autoloads cleanly, and the compiler's use of deprecated constructs (dynamic properties, old each()-style patterns, string interpolation quirks) should be assumed until proven otherwise. The critical semantic gap is escaping: Laravel 4 Blade used {{ }} for HTML-escaped output and {{{ }}} for raw. Code generation almost always wants raw output, so a template author's modern-Blade muscle memory will silently HTML-encode generated code (<, >, &, quotes) and produce corrupt files. That single behavior is the highest-probability integration defect and must be validated in a spike before any commitment.
Technical risk. The dominant risk is abandonment, not malice. Five stars, zero dependents, and a last-release horizon measured in years mean there is no upstream patch path, no CVE response, no PHP-version compatibility work. Supply-chain risk is low precisely because nobody maintains it; bus-factor risk is total. Secondary risks: compiled-template caching (write permissions, stale cache in CI, concurrency during parallel test runs), non-deterministic whitespace/indentation in generated output that pollutes diffs, and opaque compiler errors that surface as PHP parse failures in generated artifacts rather than template diagnostics. License (MIT-family) is permissive, so forking is legally clean.
Key questions. What exactly are we generating, and is it build-time only? Can we achieve the same result with illuminate/view used standalone (Container + Filesystem + EngineResolver + BladeCompiler), which is maintained, PHP 8-native, and already in our dependency tree? Do we need full template inheritance and directives, or would nette/php-generator (AST-based, syntax-safe) or plain stub substitution suffice? Which PHP versions must the generator support? Who owns the fork, and what is the exit criterion?
Stack fit. Treat SimpleView as a dev-only, build-time dependency in a require-dev block, isolated behind an internal CodeGenerator interface so the rendering engine is swappable. If the team is on Laravel 8+, the honest baseline comparison is Laravel's own Blade compiler invoked standalone — same syntax familiarity, active maintenance, PHP 8 support, and no new vendor. SimpleView only wins if its code-generation-specific affordances (whatever whitespace or directive handling it added atop L4 Blade) are demonstrably better, which is unlikely at this maturity level.
Migration path. Recommended sequence: (1) spike — install in a scratch branch, generate three representative artifacts, diff against expected output, confirm raw-vs-escaped semantics; (2) decide — if the spike shows friction, fall back to standalone illuminate/view or nette/php-generator; (3) if adopting, fork to an internal namespace, add PHP 8 compatibility patches, pin to a commit SHA (never a floating version), and publish to a private registry; (4) wrap behind the internal interface and add golden-file tests. Migration away later is cheap if the interface is in place from day one — that optionality is the main architectural deliverable here.
Compatibility. Pin the PHP constraint explicitly, run the generator under the same PHP version as CI, and add a PHPStan/Psalm pass over the fork. Verify the compile-cache directory is configurable and git-ignored, and that generated output is byte-stable across runs (sort any iterated collections in templates). Confirm the escaping contract with a dedicated test asserting raw output for every interpolation form used.
Sequencing. Land the interface and golden-file tests first, then the engine behind it. Keep generated artifacts committed to version control so the generator is never on the critical path for runtime deploys. Only after the generator has run cleanly in CI for a release cycle should it be considered stable enough to expand beyond the initial artifact types.
Maintenance. Upstream maintenance is effectively zero; the fork becomes our code. Budget a modest but real ongoing cost: PHP-version bumps, dependency audits, and bug fixes we author ourselves. This is the single largest total-cost-of-ownership line item and should be weighed against the near-zero cost of using the framework's own Blade compiler.
Support. No community, no issue triage, no documentation beyond the README and the Laravel 4 Blade docs it descends from. Internal documentation and a short style guide covering the L4 dialect differences (especially escaping and any directive gaps) are mandatory onboarding artifacts, not optional.
Scaling. Build-time code generation scales trivially — it runs per CI job, not per request. The scaling concerns are organizational: template count growth, cache-directory contention under parallel test execution, and diff noise from non-deterministic output. Address the latter two with per-job cache isolation and sorted iteration.
Failure modes. Ranked by likelihood: HTML-escaped code silently corrupting generated files; PHP version incompatibility breaking the toolchain on upgrade; stale compiled templates producing misleading output in CI; whitespace/indentation drift inflating review diffs; and compiler errors manifesting as downstream syntax errors with poor stack traces. Each maps to a specific guardrail — escaping tests, pinned PHP matrix, cache isolation, golden files, and wrapping the compiler to surface template-level errors.
Ramp-up. Low for anyone who has written Blade templates; the syntax is familiar and the mental model simple. The trap is false familiarity — developers will assume modern Blade semantics and be surprised by the L4 dialect. A one-page internal cheat sheet plus the golden-file suite mitigates most of this within a sprint.
Recommendation. Do not adopt as a production dependency. Evaluate standalone illuminate/view first; reserve SimpleView for a time-boxed spike, and only fork it if it demonstrably outperforms the maintained alternative on a specific, documented code-generation requirement.
How can I help you explore Laravel packages today?