Tutorial Laravel 5 for beginners : How to pass data to all views in Laravel 5? How to Understanding Views in Laravel 5?
Laravel 5 Tutorial - Model View Controller in MVC PHP Framework that the 'V' letter mean a Views. In Laravel Php Framework Views are stored under the resources folder resources/views.
Please Read :
Views will display data and various additional interface elements as needed.
we can pass all data from the database and show to the Views file.
resources\views\helloworld.blade.php
After that, we will add new route at the app\Http\routes.php
app\Http\routes.php
The routes file will get route from helloController at the index method, just create 'helloController.php' at app\Http\Controllers. you can create the Controller using 'Artisan' CLI.
app\Http\Controllers\helloController.php
now, open in your browser by following the url 'http://localhost:8080/hello', the result is "Hello World!"
You can passing data or some arrays data to the views.
in the Views resources/views you can make A blade template contains extension (.blade.php), at the next lessons, we will tech you about templating in Laravel.
Please Read :
Views will display data and various additional interface elements as needed.
we can pass all data from the database and show to the Views file.
Understanding Views in Laravel
To understand the Views in Laravel, we will create new project that showing a string "Hello World!" to the "helloworld.php" in Views folder.
resources\views\helloworld.blade.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
After that, we will add new route at the app\Http\routes.php
app\Http\routes.php
Route::get('/hello', 'helloController@index');
The routes file will get route from helloController at the index method, just create 'helloController.php' at app\Http\Controllers. you can create the Controller using 'Artisan' CLI.
app\Http\Controllers\helloController.php
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppHttpRequests;
class helloController extends Controller
{
public function index(){
return view('helloworld');
}
}
now, open in your browser by following the url 'http://localhost:8080/hello', the result is "Hello World!"
You can passing data or some arrays data to the views.
in the Views resources/views you can make A blade template contains extension (.blade.php), at the next lessons, we will tech you about templating in Laravel.
COMMENTS