-
Notifications
You must be signed in to change notification settings - Fork 0
Helpers
Laureano F. Lamonega edited this page Jul 17, 2026
·
1 revision
Global helper functions available anywhere in your application.
Render a view and return a Response with text/html content type.
return view('users/index', ['users' => $users]);
return view('users/index', $data, 'layouts/main');Create a redirect response.
return redirect('/login');
return redirect('/dashboard', 301);Escape HTML to prevent XSS.
echo e($userInput);
echo e($user->name); // Used in native PHP viewsGet an environment variable with type-casting support.
$debug = env('APP_DEBUG', false); // bool
$name = env('DB_NAME', 'myapp'); // string
$host = env('DB_HOST'); // null if not setValues are type-cast: 'true'/'yes'/'1' → true, 'false'/'no'/'0' → false, 'null'/'' → null.
Generate a URL from a named route.
route('posts.show', ['slug' => 'hello-world']); // /posts/hello-worldThrows RuntimeException if the route name is not defined.
Get a config value using dot notation.
$timezone = config('app.timezone', 'UTC');
$dbHost = config('database.connections.mysql.host');Dump variables and die. Outputs formatted var_dump() with syntax highlighting.
dd($user, $request->all());Dump variables as JSON and die.
ddj($user); // Single variable
ddj($users, $request); // Multiple variables as array