0712-2888027 189-8648-0214
微信公眾號(hào)

孝感風(fēng)信網(wǎng)絡(luò)科技有限公司微信公眾號(hào)

當(dāng)前位置:主頁(yè) > 技術(shù)支持 > PHP > laravel框架常用artisan常用命令集合

laravel框架常用artisan常用命令集合

時(shí)間:2024-09-18來(lái)源:風(fēng)信官網(wǎng) 點(diǎn)擊: 1289次
以下記錄為laravel框架常用artisan常用命令集合,日常開發(fā)過(guò)程中會(huì)經(jīng)常使用到。
 
1、控制器 or Model
 
// 5.2版本創(chuàng)建一個(gè)空控制器
php artisan make:controller BlogController
 
// 創(chuàng)建Rest風(fēng)格資源控制器
php artisan make:controller PhotoController --resource
 
// 指定創(chuàng)建位置 在app目錄下創(chuàng)建TestController
php artisan make:controller App\TestController
 
// 指定路徑創(chuàng)建
php artisan make:Model App\\Models\\User(linux or macOs 加上轉(zhuǎn)義符)
 
// 數(shù)據(jù)遷移
php artisan migrate
 
2、數(shù)據(jù)遷移(Migration)
 
// 創(chuàng)建遷移
php artisan make:migration create_users_table
 
// 指定路徑
php artisan make:migration --path=app\providers create_users_table
 
// 一次性創(chuàng)建
// 下述命令會(huì)做兩件事情:
// 在 app 目錄下創(chuàng)建模型類 App\Post
// 創(chuàng)建用于創(chuàng)建 posts 表的遷移,該遷移文件位于 database/migrations 目錄下。
php artisan make:model --migration Post
 
3、數(shù)據(jù)填充(Seeder)
 
// 創(chuàng)建要填充的數(shù)據(jù)類
php artisan make:seeder UsersTableSeeder
 
// 數(shù)據(jù)填充(全部表)
php artisan db:seed
 
// 指定要填充的表
php artisan db:seed --class=UsersTableSeeder
 
4、路由
 
// 查看所有路由
php artisan route:list
 
5、其他
 
配置Composer中國(guó)鏡像(CDN加速):composer config -g repo.packagist composer https://packagist.phpcomposer.com
 
更新Laravel依賴庫(kù):composer install || composer update
 
自動(dòng)生成事件和監(jiān)聽器:php artisan event:generate
 
自動(dòng)生成Laravel密鑰:php artisan key:generate
 
清除Laravel配置緩存:php artisan config:clear || php artisan config:cache
 
查詢Laravel 版本及Laravel Intaller的版本:php artisan --version/laravel --version
 
Laravel PHP內(nèi)建服務(wù)器:cd learnlaravel5/public php -S 0.0.0.0:1024 || php artisan serve
 
Auth 系統(tǒng):php artisan make:auth
熱門關(guān)鍵詞: laravel 框架 artisan 常用命令
欄目列表
推薦內(nèi)容
熱點(diǎn)內(nèi)容
展開