1.設置PHPphp
1.1.官網下載PHP
http://windows.php.net/downloads/releases/php-7.1.0-nts-Win32-VC14-x86.ziphtml
1.2.解壓到 c:\wnmp\php 在提示符下,測試是否成功
D:\>c:\wnmp\php\php.exe -vmysql
1.3.,設置系統變量path,指向c:\wnmp\php 重啓生效
D:\>php -v
D:\>php -mnginx
1.4.到官方網站下載 php_xdebug-2.5.0-7.1-vc14-nts-x86_64.dlllaravel
1.5.複製 c:\php\php.ini-development 而且重命名爲 c:\php\php.ini,修改 php.ini 找到如下內容,去掉備註使指定的擴展生效: git
extension_dir = "ext"
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_openssl.dll
extension=php_pdo_mysql.dll
extension=php_pdo_sqlite.dllgithub
zend_extension="php_xdebug-2.5.0-7.1-vc14-nts-x86_64.dll"web
[Xdebug]
;是否開啓自動跟蹤
xdebug.auto_trace=On
;是否開啓異常跟蹤
xdebug.show_exception_trace=On
;是否開啓遠程調試自動啓動
xdebug.remote_autostart=On
;是否開啓遠程調試
xdebug.remote_enable=On
;容許調試的客戶端IP
;遠程調試的端口(默認9000)
xdebug.remote_port=9001
;調試插件dbgp
xdebug.remote_handler=dbgp
;是否收集變量
xdebug.collect_vars=On
;是否收集返回值
xdebug.collect_return=On
;是否收集參數
xdebug.collect_params=On
;跟蹤輸出路徑
xdebug.trace_output_dir="c:\xdebug"
;是否開啓調試內容
xdebug.profiler_enable=On
;調試輸出路徑
xdebug.profiler_output_dir="c:\xdebug"
xdebug.remote_host=vico.io
xdebug.idekey=PHPSTROMsql
設置如下內容,防止攻擊者欺騙PHP去執行非法代碼
cgi.fix_pathinfo=0json
2.設置Nginx
2.1官網下載Nginx
http://nginx.org/download/nginx-1.10.2.zip
2.2.解壓到c:\nginx,在提示符下,測試是否成功
c:\nginx\nginx.exe -V
2.3.打開C:\nginx\conf\nginx.conf,刪除原來並替換成如下內容
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
include vhost/*.conf;
}
2.4.新建目錄 vhosts ,並添加新的設置文件 C:\wnmp\nginx\conf\vhosts\web.conf 輸入如下內容
server {
listen 80;
server_name localhost;
set $root "D:/Repo/laravel5/public";
location / {
root $root;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$query_string;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root $root;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
3.設置composer
3.1.官網下載composer安裝包
https://getcomposer.org/Composer-Setup.exe
***若是exe無法安裝成功,
也能夠下載composer.phar。並將 composer.phar 複製到 PHP 的安裝目錄下面。
在 PHP 安裝目錄下新建一個 composer.bat 文件,並將下列代碼保存到此文件中。
@php "%~dp0composer.phar" %*
執行 composer.bat 便可
在提示符下,輸入composer -v
***
3.2.安裝完成後,查看是否安裝成功(必須先安裝好PHP,而且設置好openssl擴展)
默認安裝到如下目錄 C:\ProgramData\ComposerSetup\bin\composer.phar
D:\>composer -V
3.3.更改composer國內源
composer config -g repo.packagist composer https://packagist.phpcomposer.com
3.4.composer自更新
composer self-update
4.laravel項目初始化(假定項目目錄在d:\repo)
4.1.經過composer,在當前目錄,初始化新的laravel項目(時間稍長)
cd d:\repo
composer create-project laravel/laravel --prefer-dist laravel5
4.2 Lavel擴展包之:Laravel IDE Helper
composer require barryvdh
/laravel-ide-helper
php artisan
clear
-compiled
php artisan ide-helper:generate
php artisan optimize
php artisan clear-compiled"
,
"php artisan ide-helper:generate"
,
"php artisan optimize"
5.服務啓動設置
5.1.下載 RunHiddenConsole.exe.rar ,解壓文件到 C:\wnmp 下
5.2.建立 nginx_start.bat ,錄入如下內容
@echo off
echo Starting PHP FastCGI...
C:\wnmp\RunHiddenConsole.exe C:\wnmp\PHP\php-cgi.exe -b 127.0.0.1:9000 -c C:\wnmp\PHP\php.ini
echo Starting nginx...
C:\wnmp\RunHiddenConsole.exe C:/wnmp/nginx/nginx.exe -p C:/wnmp/nginx
echo. & pause
5.2.建立 nginx_stop.bat ,錄入如下內容
@echo off
echo Stopping nginx...
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
echo. & pause
exit
6.下載php7的 php_memcache.dll (要對應版本)
https://github.com/nono303/PHP7-memcahe-dll/tree/master
解壓php_memcache.dll 文件到 C:\php\ext下
修改 php.ini 添加如下內容
extension=php_memcache.dll
7.phpstorm xdebug
phpstorm安裝Laravel插件
打開File->Settings->Plugins,在搜索框中搜索Laravel Plugin,若是沒有安裝就會出現 Install按鍵
phpstorm配置laravel-ide-helper
composer require barryvdh/laravel-ide-helper
點開項目根目錄下的composer.json,會出現laravel-ide-helper安裝成功後的選項
app/config.php的providers選項中註冊服務提供者:
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
爲了後續方便,你也能夠在 composer.json 文件中的scripts中做以下配置:
"scripts": { "post-update-cmd": [ "Illuminate\\Foundation\\ComposerScripts::postUpdate", "php artisan clear-compiled", "php artisan ide-helper:generate", "php artisan optimize" ]}