Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

View Laravel Package

illuminate/view

Illuminate View is Laravel’s templating and view rendering component. It compiles and renders Blade templates, manages view composers and shared data, supports view discovery, caching, and engines, and integrates cleanly with the rest of the Illuminate framework.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing via Composer: composer require illuminate/view. As a standalone package, it provides Laravel’s view rendering engine outside a full Laravel app. First use case: rendering Blade templates in a microservice or console app by bootstrapping a ViewFactory with a FileViewFinder and FileCompilerEngine. Configure views path and cache path explicitly using the ViewFactory constructor. Begin with a simple Blade template (e.g., resources/views/hello.blade.php) and render it using factory->make('hello', ['name' => 'Taylor']).

Implementation Patterns

  • Use ViewFactory::make() for single renders, ViewFactory::share() to inject shared data across all views (e.g., site title, auth user).
  • Chain ViewFactory::composer() to bind view composers (closure or class-based) for dynamic data population per view or namespace.
  • Leverage ViewFactory::addLocation() to register multiple view directories—useful for modular apps or bundling views in packages.
  • Integrate with Laravel’s config and event system: bind app() container manually to support @auth, @dump, or custom directives that depend on core services.
  • In CLI or custom scripts, wrap rendering in a service that lazily initializes ViewFactory to avoid overhead unless needed.

Gotchas and Tips

  • Manual dependency injection required: Unlike full Laravel, view() helper is absent—you must resolve ViewFactory from container or instantiate directly.
  • Blade directives requiring Laravel services (e.g., @vite, @csrf) won’t work out-of-the-box; implement custom placeholders or stubs.
  • Caching: Set config('view.compiled.path') (via env var or direct config array) to avoid runtime errors—Blade compiles templates to PHP and stores them there.
  • Namespace conflicts: Avoid calling view() as a global function; use Illuminate\Support\Facades\View facade only if container is booted properly.
  • Debug tip: Call $factory->getEngine()->getCompiler()->getExpressionTags() to verify Blade is configured correctly—especially if {{ }} or @ tags behave unexpectedly.
  • Extension point: Override BladeCompiler to add custom directives (e.g., @humanTime) by extending BladeCompiler and registering via ViewFactory::setBladeCompiler().
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation