Laravel 5.3安裝
開發(fā)環(huán)境滿足以下要求:
- PHP版本 >=
5.6.4
- PHP擴(kuò)展:
OpenSSL
- PHP擴(kuò)展:
PDO
- PHP擴(kuò)展:
Mbstring
- PHP擴(kuò)展:
Tokenizer
Laravel 使用 Composer
管理依賴橱野,因此悔详,使用 Laravel 之前待错,確保機(jī)器上已經(jīng)安裝了Composer
。
通過(guò) Laravel 安裝器
首先,通過(guò) Composer
安裝 Laravel 安裝器:
composer global require "laravel/installer"
PS:我的Composer
是window系統(tǒng)exe安裝的衣屏,執(zhí)行上面這個(gè)命令后丹皱,會(huì)在我的C:\Users\10113\AppData\Roaming\Composer
下下載一堆不明代碼。
確保 ~/.composer/vendor/bin
在系統(tǒng)路徑中览祖,否則不能在任意路徑調(diào)用 laravel 命令。
安裝完成后炊琉,通過(guò)簡(jiǎn)單的 laravel new 命令即可在當(dāng)前目錄下創(chuàng)建一個(gè)新的 Laravel 應(yīng)用展蒂,例如,laravel new blog 將會(huì)創(chuàng)建一個(gè)名為 blog 的新應(yīng)用,且包含所有 Laravel 依賴锰悼。該安裝方法比通過(guò) Composer 安裝要快很多:
laravel new blog
http://localhost/laravel5.3/blog/public/
通過(guò) Composer Create-Project
你還可以在終端中通過(guò) Composer 的 create-project 命令來(lái)安裝 Laravel 應(yīng)用:
composer create-project --prefer-dist laravel/laravel blog
注:如果要下載其他版本柳骄,比如5.2版本,可以使用這個(gè)命令:
composer create-project --prefer-dist laravel/laravel blog 5.2.*
箕般。
http://laravelacademy.org/post/5744.html
部署 laravel 5.3 (php7.0 + nginx)
phpStudy(我用phpStudy 2016.11.03
版本)
server {
listen 80;
server_name l.com ;
root "D:/html/laravel/public";
location / {
index index.html index.htm index.php;
#autoindex on;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
# fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
try_files $uri /index.php =404;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
wnmp.2.2.5
編輯php.ini
vi d:/local/wnmp.2.2.5/php/php.ini
;cgi.fix_pathinfo=1修改為cgi.fix_pathinfo=0
編輯nginx配置
vi d:/local/wnmp.2.2.5/conf/nginx.conf
server {
listen 80;
server_name l.com;
access_log logs/l.com_access.log;
error_log logs/l.com_error.log;
root d:/local/wnmp.2.2.5/html/laravel5.3/blog/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass php_processes;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
初體驗(yàn)
.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=12345
# 驗(yàn)證頁(yè)面
php artisan make:auth
# 數(shù)據(jù)遷移
php artisan migrate
ORM->Eloquent 處理Model類
php artisan make:model Article
Migration和Seeder
php artisan make:migration create_article_table
php artisan migrate
php artisan make:seeder ArticleSeeder
composer dump-autoload
php artisan db:seed