Laravel是一套簡潔、優雅的PHP Web開發框架 (PHP Web Framework) 。在世界(不含中國)PHP框架的占有率超過40%。
自從接觸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": ">=..", "laravel/framework": "..*" }, "require-dev": { "fzaninotto/faker": "~.", "mockery/mockery": "..*", "phpunit/phpunit": "~.", "phpspec/phpspec": "~." }, "autoload": { "classmap": [ "database" ], "psr-": { "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安裝成功
以上內容是小編給大家分享的PHP框架Laravel學習心得體會,本文寫的不好,還請給位大俠給我提出寶貴意見,共同學習進步。