使用Composer
中國(guó)鏡像地址
pkg.phpcomposer.com
查看當(dāng)前的鏡像地址
composer config -g repo.packagist
啟用本地鏡像服務(wù)
有兩種方式啟用本鏡像服務(wù):
- 系統(tǒng)全局配置: 即將配置信息添加到 Composer 的全局配置文件 config.json 中铜涉。見“例1”
- 單個(gè)項(xiàng)目配置: 將配置信息添加到某個(gè)項(xiàng)目的 composer.json 文件中。見“例2”
例1:修改 composer 的全局配置文件(推薦方式)
打開命令行窗口(windows用戶)或控制臺(tái)(Linux沉填、Mac 用戶)并執(zhí)行如下命令:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
例2:修改當(dāng)前項(xiàng)目的 composer.json 配置文件:
打開命令行窗口(windows用戶)或控制臺(tái)(Linux市框、Mac 用戶)霞扬,進(jìn)入你的項(xiàng)目的根目錄(也就是 composer.json 文件所在目錄),執(zhí)行如下命令:
composer config repo.packagist composer https://packagist.phpcomposer.com
上述命令將會(huì)在當(dāng)前項(xiàng)目中的 composer.json 文件的末尾自動(dòng)添加鏡像的配置信息(你也可以自己手工添加):
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
}
以 laravel 項(xiàng)目的 composer.json 配置文件為例枫振,執(zhí)行上述命令后如下所示(注意最后幾行):
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
},
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
}
}
OK喻圃,一切搞定!試一下 composer install 來體驗(yàn)飛一般的速度吧粪滤!
Artusan控制器臺(tái)
Artisan簡(jiǎn)介
- Artisan 是 Laravel 中自帶的命令行工具的名稱
- 由強(qiáng)大的Symfony Console 組件驅(qū)動(dòng)的
- 提供了一些對(duì)應(yīng)用開發(fā)有幫助的命令
Artisan基本用法
查看所有可用的Artisan的命令(list)
php artisan
php artisan list
查看命令的幫助信息(help)
php artisan help migrate
Artisan 基本使用用
創(chuàng)建控制器
php artisan make:controller StudentController
創(chuàng)建模型
php artisan make:model Student
創(chuàng)建中間件
php artisan make:middleware Acitvity
Laravel中生成Auth所需文件(用戶認(rèn)證) 數(shù)據(jù)遷移和填充
生成Auth所需文件
使用artisan
php artisan make:auth
未完待續(xù)斧拍。。杖小。