Laravel ??: Laravel Event Sourcing? ???? ??? ?? ??????? ???? ??? ??????
Jun 14, 2023 pm 02:31 PMLaravel ??: Laravel Event Sourcing? ???? ??? ?? ??????? ???? ??? ??????
???? ??? ??? ??? ?????? ????? ???? ???? ?? ??? ?? ??????? ?? ??? ?? ????? ?? ? ??? ???? ?? ??? ?????. Laravel Event Sourcing? ??? ?? ??????? ???? ?? ????????. ? ????? Laravel Event Sourcing? ???? ??? ?? ??????? ???? ??? ?????.
1. ??? ??? ?????
Laravel Event Sourcing? ??? ?? ? CQRS(Command Query Responsibility Separation) ????? ???? ?? Laravel ????, ??? ?? ??????? ??? ???? ? ??? ???.
??? ??? Laravel Event Sourcing? ?? ???? ??? ???? ???? ??? ???? ??? ???? ?????. ???? ??? ? ?, ?? ??? ?? ?? ???? ???? ???? ?????? ?? ???.
2. Laravel Event Sourcing? ??
- ?? ??? ???
Laravel Event Sourcing? ???? ??? ???? ????? ?? ??? ???? ??? ??? ???? ?? ? ??? ?? ??? ? ????.
- ?? ?????? ???
?? ???? ???? ??? ???? ??? ???? ???? ???? ???? ????? ??????? ???? ??? ? ????.
- ? ?? ??? ??
Laravel Event Sourcing? ??? ???? ???? ???? ??? ??? ???? ???? ??? ??? ???? ? ????.
3. Laravel Event Sourcing? ???? ??? ?? ?????? ??
- Laravel Event Sourcing ??
Composer? ???? Laravel Event Sourcing? ??? ? ????.
composer?? spatie/laravel-event-sourcing? ?????
- ??? ??
???????? ?? ???? ???? ???. ?? ??, ???? ??? ???? ???? ???.
class UserRegistered { public string $userId; public string $name; public string $email; public function __construct(string $userId, string $name, string $email) { $this->userId = $userId; $this->name = $name; $this->email = $email; } }
- ??? ??? ??
?? ??? ??? ???? ??? ???? ???? ???. ?? ??, ??? ?? ???? ???? ??? ???? ???? ???.
class UserRegisteredEventHandler { public function __invoke(UserRegistered $event) { User::create([ 'id' => $event->userId, 'name' => $event->name, 'email' => $event->email, ]); } }
- ?? ?? ??
?? ??? ??? ?? ??????? ?? ????, ??????? ?? ???? ?????. ?? ??? ???? ?? ??? ?? ??? ???? ???. ?? ??, ??? ?? ??? ???? ???:
class UserAggregateRoot extends AggregateRoot { public function register(string $userId, string $name, string $email) { $this->recordThat(new UserRegistered($userId, $name, $email)); } protected function applyUserRegistered(UserRegistered $event) { // 用戶注冊的狀態(tài)變化 } }
- ??? ???
???? ???? ???? ?? ???? ? ????. ?:
$userAggregateRoot = new UserAggregateRoot(); $userAggregateRoot->register('123', 'Tom', 'tom@example.com');
- ??? ??
???? ????, ??? ?? ???? ???? ???? ???? ???? ? ????. ?? ??, ?? ??? ???? ???? ?? ??? ? ????:
class UserRepository { public function getById(string $userId): User { $user = new User(); $userAggregateRoot = new UserAggregateRoot(); $eventStream = event()->getStreamById($userId); foreach ($eventStream as $event) { $userAggregateRoot->replay([$event]); $user = $userAggregateRoot->get(); } return $user; } }
???? Laravel Event Sourcing? ???? ??? ?? ??????? ??? ? ????. ?? ???? ??? ???? ???? ?? ?????? ??? ?? ??????? ?? ????? ??? ? ????.
? ??? Laravel ??: Laravel Event Sourcing? ???? ??? ?? ??????? ???? ??? ??????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

PHP?? ?? ??? ???? ? ?? ?? ??? ????. 1. php.ini? ?? ??? ??; 2. ? ?? (? : Apache? Setenv ?? nginx? FastCGI_Param)? ??????. 3. PHP ?????? putenv () ??? ??????. ? ??? Php.ini? ????? ??? ???? ??? ???? ? ?? ??? ?? ???? ????? ???? Putenv ()? ?? ??? ?????. ?? ???? ?? ?? (? : php.ini ?? ? ?? ??)? ???? ????. ?? ?? ??? ??? ?? ??? ????? ???? ?? ????.

Laravel? ?? ??? ?? ?? ??? ?? ?? ??? ???? ??? ??????. ?? ???? ?? ??? ????? ? ???? I/O ?? ? ?? ?? ??? ???? ???? ??? ?? ? ????. 1. ?? ????? ?? ? ? ???????? ??? ????? ?? ???? ??????. 2. ??? ? ??? ?? ? ? PhPartisAnconfig? ?? ???????. 3. ?? ??? ??? ??? ???? ?? ?? ?? ???? ???? ????. 4. ?? ?? ??? ???? ?? ??? ??? .env ??? ???? ?? ???????.

??? PHP ??? ??? ??? ?? ???? ??? ?? ????? ???????. Laravel? ?? ??? ???? ??? ? ? ???? ??? ??? ???? ?????? ?? ? ?? ?? ???? ?????. Symfony? ? ???? ??? ???? ?????. Codeigniter? ??? ??? ?? ??? ?? ??? ?? ????? ?????. 2. AI ??? ???? ????? ??? ??? ??, ???? ?? ?? (? : ???, ??, F1 ?), ??? ? ?? ?? ? ?? ??? ?? ???? ?? ??? ???? ???? ?? ??? ? ?? ???? ?? ?? ??? ????? ?? ???? ????? ?????? ??? ????? ???????. 3. ??? ?? ?? ????? ?? ??? ?????. AES? ?? ??? ???? ????? ?????.

PHP ????? ?? ??? ??? ? ??? ??? CI (Continuous Integration) ????? ???? ? ????. 1. DockerFile? ???? ?? ???, ?? ??, ??? ?? ? ?? ??? ???? PHP ??? ?????. 2. Gitlabci? ?? CI/CD ??? ???? .gitlab-ci.yml ??? ?? ??, ??? ? ?? ??? ???? ?? ??, ??? ? ??? ?????. 3. PHPUNIT? ?? ??? ??? ??? ???? ?? ?? ? ???? ???? ????????. 4. Kubernetes? ?? ?? ?? ??? ???? ?? .yaml ??? ?? ?? ??? ?????. 5. Dockerfile ??? ? ??? ??? ??????

Laravel? eloquentscopes? ?? ??? ??? ??? ?????? ?? ?? ??? ????? ?????. 1. ?? ??? ???? ???? ???? ???? Post :: published (); 2. ??? ??? ?? ??? ???? ???? ?? ??? ?? ?? ?? ??? ???? ???? ??? ?????? ??? ???? ???????. 3. ????? ?? ?? ?? ??? ??? ?? ?? ??? ?? ? ? ??? ?? ? ? ?? ?? ??? ?????. 4. ?? ??? ? ??? ?? ???? ? ??? ? ?? ??, ?? ??, ?? ???? ? ?? ?????????.

??? ?? ??? PHP ???? ?? ?? ??? ???? ?? ???????. RBAC (Role-Based Access Control) ??? ?? ???, ?? ? ??? ???? ??? ?? ?? ? ??? ?????. ?? ???? ??? ?????. 1. ???, ?? ? ??? ? ???? user_roles ? role_permissions? 3 ?? ?? ???; 2. $ user-> can ( 'edit_post')? ?? ???? ?? ?? ??? ?????. 3. ??? ???? ??? ??????. 4. ?? ??? ???? ?? ?? ?? ? ??? ? ???? ???? ?? ??? ? ?? ??? ?????. 5. ??? ??? ?? ?? ???? ?? ???? "??"? ??????.

??? ??? ??? ?? AI? ??? PHP? ?? ????? PHP? ??? "???"?????, ?? ???? ????? ???? ??? ? ??, ASYNCHRONOUS ??? ?? AI ??? (? : Google CloudVideoAi ?)? ??????? ????. 2. PHP? JSON ??? ?? ????, ??, ??, ??, ?? ? ?? ??? ???? ??? ??? ???? ??????? ?????. 3. ??? PHP? ??? ? ???? ???? ?? PHP ?????? ????? ????? ???? ? ??? AI ??? ???? ???? ????. 4. ???? ???? ??? ?? ?? (?? ?? ? URL??? ???? ????? ?? ??), ??? ?? (??? ??? ??), ?? ?? (??? ??, ?? ????) ? ?? ??? (?? ???)? ?????. 5. ??? ??? ????? ?? ?????

PHP ??? ?? ???? ????? ??? ??, ??? ??, ?? ? ?? ?? ???? ???????. ??, ??? ?? ???? ???? JWT? ???? ??? ??? ??????. ??, ??? ?? ????? ? ?????? ??? ???? ?? ???? ?????. ??, Alipay ?? WeChat ??? ???? ???? ??? ?????. ??, ?? ?? ??? ?? ??? ??? ??? ?????. Laravel ??? ??? ???? ?? ???? ?????, ?? ?? ? ??? ??? ???? ??? ??? ????, ??? ????? ??, ??????, ?? ? ?? ??? ?????? ??? ??? ??????? ??? ? ??? ???????.
