1. 創(chuàng)建數(shù)據(jù)庫(kù)遷移文件,使用命令行
php artisan make:migration create_users_table
2. 在數(shù)據(jù)遷移文件中添加所需要的字段
database/migrations/..
3. 生成控制器
php artisan make:controller UserController
生成資源控制器
php artisan make:controller UserController --resource
4. 生成模型
php artisan make:model Models/User
5. 生成模型并創(chuàng)建數(shù)據(jù)庫(kù)遷移文件
php artisan make:model Models/Article -m
6. 模型類創(chuàng)建一個(gè)模型工廠:
php artisan make:factory ArticleFactory --model=Article
7. 生成數(shù)據(jù)庫(kù)填充文件
php artisan make:seeder UsersTableSeeder
8. 通過(guò)命令填充數(shù)據(jù)
php artisan db:seed
php artisan db:seed --class=UsersTableSeeder
9. 回滾并重新運(yùn)行所有遷移
php artisan migrate:refresh --seed
10. 復(fù)制.env.example 文件生成.env配置文件
cp .env.example .env
11. 生成中間件
php artisan make:middlware CheckEmail
12. 生成APP_KEY
php artsian key:generate
13. 生成factory填充假數(shù)據(jù)
art make:factory ArticleFactory
14. 生成監(jiān)聽事件
php artisan event:generate
15. 生成一條artisan命令
php artisan make:command HelloMessage --command=hello:message
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。