Navigate to Inertia.js page files directly from your PHP controllers in VS Code.
Inertia::render or $this->page calls to open the corresponding file.resources/js for files with extensions: .tsx, .vue, .js, .jsx, .ts, .svelte.In your PHP controller:
public function index()
{
// Hold Cmd/Ctrl and click on the path string
return Inertia::render('Dashboard/Settings', [
'user' => Auth::user(),
]);
}
You can also use the $this->page('path/to/page', $data) method, which is a helper function that returns Inertia::render with the first argument as the page component path.
Main Base Controller
<?php
namespace App\Http\Controllers;
use Illuminate\Validation\ValidationException;
abstract class Controller
{
public function page(string $view, array $data = [], ?string $title = null)
{
if ($title) {
$data['title'] = $title;
}
$titleSeparator = config('system.title_separator');
$data['title'] = (! empty($data['title']) ? $data['title'] . ' ' . $titleSeparator . ' ' : '') . config('app.name');
return inertia($view, $data);
}
}
Controller Example
<?php
namespace App\Http\Controllers\Users;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Countries;
class UserController extends Controller
{
public function create()
{
// Hold Cmd/Ctrl and click on the path string
return $this->page('dashboard/users/create', [
'countries' => Countries::all(),
]);
}
}
.vsix file from the Releases page.git clone https://github.com/syntaxlexx/vscode-inertia-lexx.git
cd vscode-inertia-lexx
npm install
code .
F5 to open the Extension Development Host.To create the .vsix file yourself (for local installation or distribution):
Install vsce (VS Code Extensions CLI):
npm install -g @vscode/vsce
Package the extension: Run the following command in the project root:
vsce package
This will generate a file named vscode-inertia-lexx-0.0.1.vsix (version number may vary).
Install the .vsix: You can now install this file using the "Install from VSIX..." method described above.
This project includes a GitHub Action to automatically build and release the extension.
v (e.g., v0.0.1) to the repository:git tag v0.0.1
git push origin v0.0.1
# or via one line
git tag v0.0.1 && git push origin v0.0.1
.vsix file, and attach it to a new Release on GitHub. You can then download it from the Releases page.resources/js directory).Run the following to verify that the extension can find the page file:
node verify_path.js