Laravel Blade Navigator
Navigate effortlessly between Laravel controller actions and Blade templates using the right-click context menu in Visual Studio Code.
All commands are grouped under a Laravel submenu in the editor context menu, keeping your context menu clean and organized.
Features
- Go to Blade Template — Jump from a controller action to the corresponding Blade template.
- Create Blade Template — Create a Blade template file for the current action if it does not exist yet.
- Go to Controller Action — Jump from a Blade template back to the controller action that renders it.
- Automatically resolves
view() calls on or near the cursor line.
- Falls back to inferring the template path from the controller class name and method name.
- Offers to create a missing controller or action method when navigating from a Blade file.
Requirements
- A Laravel project open as a workspace folder.
- Blade templates located under
resources/views/.
- Controller files located under
app/Http/Controllers/.
Usage
From a Controller → Blade Template
- Open any PHP controller file.
- Right-click in the editor.
- Select Laravel → Go to Blade Template to open the corresponding
.blade.php file.
- If the file does not exist, you are prompted to create it.
- Or select Laravel → Create Blade Template to create the file directly.
- If the file already exists, it is opened immediately.
From a Blade Template → Controller Action
- Open any
.blade.php file.
- Right-click in the editor.
- Select Laravel → Go to Controller Action.
- The corresponding controller file opens and the cursor jumps to the matching action method.
- If the controller file does not exist, you are prompted to create it.
- If the controller exists but the action method is missing, you are prompted to append it.
Template Name Resolution
The extension resolves Blade templates in the following order:
- Explicit
view() call on or near the cursor — detects view('folder.action') within ±5 lines.
Route::view() call — detects the second argument as the view name.
- Inferred from class and method — strips
Controller from the class name and uses the method name, producing resources/views/controllerName/actionName.blade.php.
Laravel dot-notation is fully supported: view('admin.users.index') resolves to resources/views/admin/users/index.blade.php.
Reverse Mapping (Blade → Controller)
Given a Blade path such as:
resources/views/product/index.blade.php
The extension infers:
- Controller class:
ProductController
- Action method:
index
It then searches app/Http/Controllers/ recursively for ProductController.php and jumps to the index method.
Created File Stubs
Blade template (*.blade.php):
{{-- action --}}
@extends('layouts.app')
@section('content')
@endsection
Controller (*Controller.php):
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ProductController extends Controller
{
public function index(Request $request)
{
return view('product.index');
}
}
Extension Settings
This extension does not add any configuration settings at this time.
Known Limitations
- Non-standard project structures may require manual navigation.
- Deeply nested view folders use only the deepest folder segment to infer the controller name.
- Only
.blade.php templates are detected.
Release Notes
0.0.1
Initial release.
- Right-click Laravel submenu in the editor context menu.
- Navigate from controller to Blade template (Go to / Create).
- Navigate from Blade template to controller action.
- Auto-creation of missing Blade files, controller files, and action methods.
Repository
https://github.com/TakashiHishiki/laravel-blade-navigator
License
MIT