Skip to content

The route() helper function requires different syntax compared to traditional Laravel routes #148

@ju-gow

Description

@ju-gow

Folio Version

1.1.10

Laravel Version

12.32.5

PHP Version

8.4.5

Description

When using Laravel Folio with named routes, the route() helper function requires different syntax compared to traditional Laravel routes, creating inconsistency in the developer experience.

Steps To Reproduce

  1. Create a Folio page with a named route:

    // resources/views/pages/folio/[User].blade.php
    <?php
    use function Laravel\Folio\name;
    name('folio.user');
    ?>
    <h4>Folio Route</h4>
    <div>
        {{ $user->name }}
    </div>
  2. Create a normal named route

    // routes/web.php
    Route::get('/view/{user}', function (User $user) {
        return view('user', compact('user'));
    })->name('view.user');
  3. Try to generate URLs using the route helper in a Blade template:

    // resources/views/index.blade.php
    <a href="{{ route('view.user', $user) }}">View Route</a>
    <a href="{{ route('folio.user', $user) }}">Folio Route</a>

Expected Behavior

The route() helper should work consistently for both traditional Laravel routes and Folio routes using the same syntax.

Actual Behavior

The route() helper requires different syntax for Folio routes compared to traditional Laravel routes:

// Traditional Laravel route - works with direct parameter:
<a href="{{ route('view.user', $user) }}">View Route</a>

// Folio route - fails with direct parameter:
<a href="{{ route('folio.user', $user) }}">Folio Route</a>

// Folio route - works with array syntax:
<a href="{{ route('folio.user', ['user' => $user]) }}">Folio Route</a>

This creates inconsistency in the developer experience, as developers must remember to use different syntax patterns for different types of routes.

Request

It would be beneficial to have consistent syntax for both traditional Laravel routes and Folio routes, so developers can use the same pattern:

// Desired consistent syntax for both:
route('view.user', $user)      // Traditional Laravel route
route('folio.user', $user)     // Folio route (currently requires array syntax)

This would improve developer experience and maintain consistency with Laravel conventions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions