-
Notifications
You must be signed in to change notification settings - Fork 224
/
artisan-commands.blade.php
124 lines (86 loc) · 3.71 KB
/
artisan-commands.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
* [The `make` command](#make-command)
* [Modifying Stubs](#modifying-stubs)
* [The `move` Command](#move-command)
* [The `copy` Command](#copy-command)
* [The `delete` Command](#delete-command)
## The `make` command {#make-command}
@component('components.code', ['lang' => 'shell'])
php artisan make:livewire foo
# Creates Foo.php & foo.blade.php
php artisan make:livewire foo-bar
# Creates FooBar.php & foo-bar.blade.php
php artisan make:livewire Foo
# Creates Foo.php & foo.blade.php
php artisan make:livewire FooBar
# Creates FooBar.php & foo-bar.blade.php
php artisan make:livewire foo.bar
# Creates Foo/Bar.php & foo/bar.blade.php
php artisan make:livewire foo --inline
# Creates only Foo.php
php artisan make:livewire foo --test
# Creates Foo.php, foo.blade.php, & FooTest.php
@endcomponent
Once created, you can render your components in a Blade file with the <code>@livewire('component-name')</code> blade directive.
Think of Livewire components like Blade includes. You can insert <code>@livewire</code> anywhere in a Blade view and it will render.
@component('components.code', ['lang' => 'php'])
@verbatim
@livewire('foo')
@livewire('foo-bar')
@livewire('foo.bar')
@livewire(Package\Livewire\Foo::class)
@endverbatim
@endcomponent
If you are on Laravel 7 or greater, you can use the tag syntax.
@component('components.code', ['lang' => 'blade'])
@verbatim
<livewire:foo />
@endverbatim
@endcomponent
### Modifying Stubs {#modifying-stubs}
You can customize the stubs (templates) that Livewire uses to create new component classes and views using the `livewire:stubs` command.
@component('components.code', ['lang' => 'shell'])
php artisan livewire:stubs
@endcomponent
The above command will create three files:
* `stubs/livewire.stub`
* `stubs/livewire.view.stub`
* `stubs/livewire.inline.stub`
Now, when you run the `make:livewire` command, Livewire will use the above stub files as the template.
## The `move` Command {#move-command}
The `php artisan livewire:move` command will move/rename the component class, blade view and the component test if it exists, taking care of namespaces and paths
Here is an example of usage:
@component('components.code', ['lang' => 'shell'])
php artisan livewire:move foo bar.baz
# Foo.php|foo.blade.php|FooTest.php -> Bar/Baz.php|bar/baz.blade.php|Bar/BazTest.php
@endcomponent
@component('components.tip')
For convenience, <code>livewire:move</code> is aliased to <code>livewire:mv</code>
@endcomponent
## The `copy` Command {#copy-command}
The `php artisan livewire:copy` command will create copies of the component class and blade view, taking care of namespaces and paths
Here are a few examples of usage:
@component('components.code', ['lang' => 'shell'])
php artisan livewire:copy foo bar
# Copies Foo.php & foo.blade.php to Bar.php and bar.blade.php
php artisan livewire:copy foo bar --force
# Overwrites existing "bar" component
php artisan livewire:copy foo bar --test
# Copies Foo.php & foo.blade.php & FooTest.php to Bar.php & bar.blade.php & BarTest.php
@endcomponent
@component('components.tip')
For convenience, <code>livewire:copy</code> is aliased to <code>livewire:cp</code>
@endcomponent
## The `delete` Command {#delete-command}
The `php artisan livewire:delete` command will remove the component class and blade view.
Here are a few examples of usage:
@component('components.code', ['lang' => 'shell'])
php artisan livewire:delete foo
# Removes Foo.php & foo.blade.php
php artisan livewire:delete foo --force
# Removes without confirmation prompt
php artisan livewire:delete foo --test
# Removes Foo.php & foo.blade.php & FooTest.php
@endcomponent
@component('components.tip')
For convenience, <code>livewire:delete</code> is aliased to <code>livewire:rm</code>
@endcomponent