您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關PHP中如何使用Laravel框架,文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。
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框架就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。