Laravel Livewire with WinNMP
-
winnmp for windows
a. create project livewire (Database and user auto create livewire)
b. https://winnmp.wtriple.com/tutorial/laravel -
update composer
a. mkdir new directory "t"
b. cd t
c. https://getcomposer.org/download/
c1. php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
c2. php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
c3. php composer-setup.php
c4. php -r "unlink('composer-setup.php');"
c5. mv composer.phar to C:\WinNMP\bin\composer
- cd \WinNMP\WWW\livewire
a. delete index.php
b. composer create-project --prefer-dist laravel/laravel .
c. composer require laravel/ui
d. composer install
e. edit .env
e1. DB_DATABASE=livewire
DB_USERNAME=livewire
f. php artisan ui bootstrap --auth
g. php artisan migrate
h. developer tools
composer require doctrine/dbal
composer require --dev barryvdh/laravel-ide-helper
composer require --dev beyondcode/laravel-dump-server
composer require --dev barryvdh/laravel-debugbar
composer require --dev roave/security-advisories:dev-master
php artisan vendor:publish --provider="BeyondCode\DumpServer\DumpServerServiceProvider"
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
I. php artisan key:generate
-
install node.js for windows
a. https://nodejs.org/zh-tw/download
b. npm install
c. npm run dev -
nginx setting
a. https://laravel.com/docs/10.x/deployment#nginx
b. WinNMP Projects -> project Setup -> Edit Nginx Virtual Server -
http://livewire.test
a. register
b. check db livewire table users have new reocd -
install livewire
a. use other cmd
b. cd \WinNMP\WWW\livewire
c. composer dump-autoload
php artisan package:discover
php artisan vendor:publish --tag=livewire:config
composer require livewire/livewire
d. https://laravel-livewire.com/docs/2.x/quickstart
d1. edit resources\views\layouts\app.blade.php
put content
d2. php artisan make:livewire counter
edit resources\views\layouts\app.blade.php
put <livewire:counter /> in <main class="py-4"> </main>
d3. edit app\Http\Livewire\Counter.php
public $count = 0;
public function increment()
{
$this->count++;
}
public function render()
{
return view('livewire.counter');
}
d4. edit resources\views\livewire\counter.blade.php
<div style="text-align: center">
<button wire:click="increment">+</button>
<h1>{{ $count }}</h1>
</div>