国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

新版1.6版本控制器參數(shù)錯誤類型如何自定義

wangsq

新版1.6版本控制器參數(shù)錯誤類型如何自定義

請教各大佬,控制器參數(shù)類型出錯后,大家是如何自定義錯誤的,之前我是通過Respect\Validation進(jìn)行參數(shù)驗(yàn)證,然后將數(shù)據(jù)類型手動轉(zhuǎn)換.

現(xiàn)在如果參數(shù)有問題報錯 InputTypeException 異常,Input age must be of type int, string given Missing input parameter :parameter'這種



565 2 0
2個回答

wangsq

之前手動校驗(yàn),可以方便設(shè)置提示內(nèi)容.但是需要手動轉(zhuǎn)換數(shù)據(jù)類型.
感覺新版本自動根據(jù)參數(shù)類型轉(zhuǎn)換數(shù)據(jù)類型很方便
但是不知道如何自定義錯誤InputTypeException提示

  • 暫無評論
walkor 打賞

用多語言, 參考下面命令

composer require symfony/translation
mkdir resource/translations/zh_CN/ -p
echo "<?php
return [
    'Input :parameter must be of type :exceptType, :actualType given' => '輸入?yún)?shù) :parameter 必須是 :exceptType 類型,傳遞的類型是 :actualType',
    'Missing input parameter :parameter' => '缺少輸入?yún)?shù) :parameter',
];" > resource/translations/zh_CN/messages.php
php start.php restart
??