Laravel?? ??? ??? ?? ??? ???? ??
Mar 07, 2024 am 08:45 AMLaravel?? ??? ??? ?? ??? ???? ?? ?? ???? ?? ????, ?? ?? ???? ????? ??? ? ?? ?????. ????? Laravel? ??? ?? ??? ??? ?? ???, ??? ? ???? ???? ?? ??? ?? ??? ?? ??? ???? ?? ??? ???? ??? ? ????. ?? ??? ??? ???? ??? ??? ???? ????.
- ??? ?? ??? ??? ???
??, ??? ??? ?? ??? ???? ?? ??? ?? ??? ???? ???? ???. Laravel??? Artisan ??? ???? ??? ?? ??? ???? ??? ? ????:
php artisan make:validator CustomValidator
??? ?? app/Validators ????? CustomValidator.php ??? ???? ? ??? ??? ??? ?? ??? ?????.
- ??? ??? ?? ?? ??
CustomValidator.php ???? ??? ?? ??? ??? ?? ??? ??? ? ????.
namespace AppValidators; use IlluminateValidationValidator; class CustomValidator extends Validator { protected $customMessages = [ 'required' => '必填項(xiàng)', 'email' => '郵箱格式不正確', 'numeric' => '必須為數(shù)字', // 可根據(jù)需要添加更多中文驗(yàn)證規(guī)則 ]; }
????? $customMessages ??? ???? ??? ??? ?? ??? ?????. ?? ?? ' ??'? '?? ??'?? ????, '???'? '??? ??? ???? ????.'? ?????.
- ??? ?? ??? ??? ??
???? AppServiceProvider? ?? ??? ??? ?? ??? ???? ???? Laravel? ? ??? ?? ??? ???? ???? ??? ??? ??? ???. AppServiceProvider.php ????:
namespace AppProviders; use IlluminateSupportServiceProvider; use AppValidatorsCustomValidator; class AppServiceProvider extends ServiceProvider { public function boot() { $this->app['validator']->resolver(function($translator, $data, $rules, $messages) { return new CustomValidator($translator, $data, $rules, $messages); }); } public function register() { // } }
? ??? ??? ?? ? ??? ??? ??? ???? ?? CustomValidator? Laravel? ?????.
- ??? ??? ?? ?? ??
????? ???? ?? ?? ???? ?? ??? ??? ?? ??? ??? ? ????.
$request->validate([ 'email' => 'required|email', 'password' => 'required|min:6', ], [ 'email.required' => '郵箱為必填項(xiàng)', 'password.required' => '密碼為必填項(xiàng)', 'password.min' => '密碼長(zhǎng)度不能少于6個(gè)字符', ]);
? ??? ?? Laravel?? ??? ??? ?? ??? ????? ??????. ?? ?? ??? ? ?? ?? ???? ?? ?? ? ???, ??? ????? ??? ?? ???? ?? ? ????. ??? ???? ????!
? ??? Laravel?? ??? ??? ?? ??? ???? ??? ?? ?????. ??? ??? 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 ????? ?? ??? ??? ? ??? ??? CI (Continuous Integration) ????? ???? ? ????. 1. DockerFile? ???? ?? ???, ?? ??, ??? ?? ? ?? ??? ???? PHP ??? ?????. 2. Gitlabci? ?? CI/CD ??? ???? .gitlab-ci.yml ??? ?? ??, ??? ? ?? ??? ???? ?? ??, ??? ? ??? ?????. 3. PHPUNIT? ?? ??? ??? ??? ???? ?? ?? ? ???? ???? ????????. 4. Kubernetes? ?? ?? ?? ??? ???? ?? .yaml ??? ?? ?? ??? ?????. 5. Dockerfile ??? ? ??? ??? ??????

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

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

CreateAhelpers.phpfileInapp/helperswithCustOmFunctionsikeFormatPrice, isactiveroute, andisAdmin.2.addTheFileTothe "??"sectionOfcomposer.jsonUnderAutoLoad.3.runcomposerDump-AUTOLOADTOMAKETHINGTICTIONSGLOBELYAVAILABLE.4.USETHEHELPERFUNCUNTION

?? ?? ?? : ?? ????? PHP? ?? Error_Log ()? ??? ? ????. ????? ???? ??? ?? ??? ?????? ???? ?? ??? ? ?? ??? ???? ??? ?? ???, ??, ?? ? ?? ? ?? ?? ??? ???? ??? ??????. 2. ??? ?? ?? : ??? ??? ??? ??? ? ??? ?? ??? ??? ?? ??? ??? ??????? ??????. MySQL/PostgreSQL? ???? ??? ? ???? ??????. Elasticsearch Kibana? ? ???/? ???? ?????. ???, ??? ?? ? ??? ? ?? ??? ?? ??????. 3. ?? ? ?? ????? : ??, ???, ?? ? ??? ??? ??????. Kibana? ?? ????? PHP ??? ?? ?? ?????? ???? ???? ?????? ???? ??? ? ?? ??? ??? ? ????.

USEMOCKERYFORCUSTOMDENCENTICESBYSETEXPINTIONSWITHSHOULDRECEIVE ()
