Weave 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

Snazzy Twig Laravel Package

torann/snazzy-twig

Snazzy Twig brings the Twig templating engine to Laravel, letting you build views with Twig's clean, expressive syntax alongside Blade. Configure template paths, share data, and render Twig views through Laravel's familiar view system, so you can mix Twig and Blade in the same application.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package with Composer and let Laravel's package discovery register the service provider. If the package ships a config file, publish it first:

composer require <vendor>/<package>
php artisan vendor:publish --provider="<Vendor>\<Package>\<PackageServiceProvider>"

Where to look first: the package's helper file (usually src/helpers.php or src/Support/helpers.php) is the fastest way to understand what the url()-style function does, since that is the public entry point. Then skim the service provider to see what gets bound into the container and whether a config file drives defaults.

First use case: generate a URL through the package helper and confirm it behaves like Laravel's native url() before you start passing arguments to it. As of 0.1.4, the URL function accepts arguments, so a smoke test looks like:

// no-arg call still works (backwards compatible)
$base = package_url();

// new in 0.1.4: pass arguments through the helper
$link = package_url('/users', ['page' => 2]);

Run a quick php artisan tinker check to confirm the signature matches what the release notes imply, since the notes only say "allow arguments" without documenting the exact shape.

Implementation Patterns

Call it where you would call url(). The helper is a drop-in for the normal URL flow, so the cleanest pattern is to use it in Blade views, controllers, and form requests exactly where you currently reach for url(). Keep it behind a thin wrapper in your own code if you want to swap it later:

// app/Support/Url.php
public static function to(string $path, array $args = []): string
{
    return package_url($path, $args);
}

Passing arguments in views and controllers. Because 0.1.4 adds argument support, prefer passing parameters as an array rather than concatenating query strings by hand:

// Controller
return redirect(package_url('/dashboard', ['tab' => 'billing']));

// Blade
<a href="{{ package_url('/orders', ['status' => 'open']) }}">Open orders</a>

This keeps escaping and encoding consistent — let the helper build the query string instead of gluing ? and & yourself.

Testing. Assert on generated URLs rather than hitting the route, so the helper stays cheap to test:

public function test_url_helper_accepts_arguments(): void
{
    $this->assertStringContainsString(
        'page=2',
        package_url('/users', ['page' => 2])
    );
}

Add a regression test for the zero-argument call too — the release note implies arguments were added, not that the old behaviour changed, but confirming that protects you on future bumps.

Integration tips.

  • If your app already has a conflicting url()-style helper (see Gotchas), alias the import and call it explicitly.
  • For locale-aware or signed URLs, pass the relevant parameters through the arguments array so the helper does the encoding once.
  • Wire the helper into route generation helpers (e.g. route() replacements) only after verifying it produces identical output to Laravel's native helper for a sample of routes.

Gotchas and Tips

Helper name collisions. Packages that add a url()-adjacent helper often clash with Laravel's own url() or with other packages. If you see "cannot redeclare function" or unexpected output, check composer show for other packages shipping a same-named helper and use the fully-qualified name or a wrapper.

Undocumented argument shape. The 0.1.4 note only says "allow arguments for the URL function" — it does not state whether arguments are a query array, positional route params, or both. Verify empirically with a couple of Tinker calls rather than assuming it mirrors route() semantics. Mixing an absolute path with a query array can behave differently than passing a named route.

Encoding and double-escaping. Passing pre-encoded values into the arguments array can produce double-encoded query strings. Pass raw values and let the helper handle encoding; if you must pre-encode, test the output with a value containing &, =, and spaces.

Backwards compatibility. Minor patch releases that widen a signature usually keep old calls working, but pin the version in composer.json with a caret constraint and run your URL-generating tests after upgrading to catch signature drift early.

Debugging. When a generated URL looks wrong, dump the inputs at the call site and compare against url() output. If the helper is behind a facade or container binding, use app()->make(...) in Tinker to inspect the resolved instance and any config defaults it reads.

Extension points. If the package exposes a config file or a bindable interface, prefer configuring defaults there over post-processing the returned string. Post-processing defeats the helper's encoding guarantees and is the usual cause of "the URL is almost right" bugs.

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.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin