In this video we are going to learn about Livewire Components.
Components are the building blocks of any Livewire application and a typical Livewire application will have many of these.
Alright, now lets see how can we create component in livewire.
For that switch to the command prompt and just type here the command.


php artisan make:livewire Post


This command will create two file first is class and second is view file.
Class file which is created inside the app\\https\\Livewire
And Here you can see the Post.php class file
Inside this class file there is render function which return view which is created inside the Resources\\views\\livewire\\post.blade.php.
Inside this view file add text here.


<h1>Post Component</h1>


Now lets add the route for this component.
So go to the web.php file and here just type here.

Route::get(‘/post’,Post::class);


Make sure you have imported Post Component on top as following


use App\\Http\\Livewire\\Post;


Now save the file and lets check this.
First of all run the application.
So switch to the command prompt and just type here.


Php artisan serve


Now switch to the browser and go to the url http://localhost:8000/post
And here you can see the comopoent.
Now lets see how can we create inline components.
Components without view (.blade.php) file is called inline components.
So for creating inline components just type the command.


php artisan make:livewire User --inline


Alright inline component created.
Now switch to the project and inside the app\\http\\livewire.
You can see the the user component.
Just open this.
Inside this render function you can see here.
Template code are written inside this blade.
Now lets add some text here.

<h1>User Inline Component</h1>

Now lets create the route for this
So go to the web.php file and just write here


Route::get('/user',User::class);


Now lets check it.
So switch to the browser just go to the url http://localhost:8000/user
And you can see the component.
alright Now let see how can we render component inside the laravel blade file.
So just go to any blade file lets open welcome.blade php file add @livewireStyles in head tag and @livewireScripts just befor the closing body tag.
Now for rendering the component inside the body just write as following.
@livewire('post')
@livewire('user')
Now lets check and you can see the component.
So in this way we can create and render Components in Livewire.