自從接觸PHP以來一直使用Yii,感覺Yii實現功能比較簡單,是一個很不錯的框架。最近由於工作的原因開始研究Laravel5,不得不說我在第一步安裝就被坑著了,下面就是我痛苦的學習成果。Laravel對我來說完全是新東西,如果內容有誤,煩請留言或QQ我,幫我糾正錯誤,感激不盡!!!
1.首先安裝php,最好5.6以上版本 (1)windows安裝composer過程中需要指定php.exe的路徑 (2)linux安裝composer過程中需要利用php-cli功能 2.安裝composer (1)windows安裝composer a.windows下載composer軟件,然後next直到完成 b.win+R => 輸入cmd => 輸入composer, 如果出現composer字體表示安裝成功 (2)linux安裝composer a.$ curl -sS https://getcomposer.org/installer | php b.此時在~/.composer下應該會產生composer.phar 這個文件 c.$ mv composer.phar /usr/local/bin/composer d.將composer.phar移動成/usr/local/bin/composer全局下,以後可以直接使用composer,而不需要php composer.phar
e.$ composer
3.修改composer鏡像源(建議第一種)
(1)將配置信息添加到 composer 的配置文件config.json
中(系統全局配置)
$composer config -g repositories.packagist composer http://packagist.phpcomposer.com
(2)將配置信息添加到單個項目的composer.json
文件中(單個項目配置) 注意最後幾行repositories
{
name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"repositories": [
{"type": "composer", "url": "http://packagist.phpcomposer.com"},
{"packagist": false}
]
}
4.安裝laravel
$ composer create-project laravel/laravel learnlaravel5
浏覽器訪問localhost/learnlaravel5/public,出現Laravel5表示laravel5安裝成功