thinkphp5(thinkphp5菜鸟教程)
很多朋友对于thinkphp5和thinkphp5菜鸟教程不太懂,今天就由小编来为大家分享,希望可以帮助到大家,下面一起来看看吧!
如何评价thinkphp5.0
ThinkPHP5重新颠覆了之前的版本。
1.支持 Composer,PHPunit(中大型项目必备的依赖管理和测试框架)
2.使用同 yii2一样的类惰性加载(性能暴升)
3.大量参考了 Laravel风格,还保证了以往 ThinkPHP简单易学(优雅并且易学)
4.引入了 php5.4特性 Traits拓展(多重继承,以前的关联模型,视图模型混合一起用)
5.终于遵循 PSR规范了!终于遵循 PSR规范了!终于遵循 PSR规范了!
符合PSR-4的自动加载规范(专门写给CI党:PSR-4是命名空间的自动加载规范哦)
6.以前单字母全局函数改成了别名函数(M,D,S,C等,除了易学好用还不会污染全局)
Thinkphp5项目在nginx服务器部署
1,切换到nginx的配置目录,找到nginx.conf文件
cd/usr/local/nginx/conf
vim nginx.conf
2,如果是单项目部署的话,只需要在nginx.conf文件里面加上以下
server{
listen 80;
#域名,本地测试可以使用127.0.0.1或localhost
server_name www.zhangc.cn;
# php项目根目录
root/home/data-www/blog;
location/{
#定义首页索引文件的名称
index index.php index.html index.htm;
#影藏入口文件
if(-f$request_filename/index.html){
rewrite(.*)$1/index.html break;
}
if(-f$request_filename/index.php){
rewrite(.*)$1/index.php;
}
if(!-f$request_filename){
rewrite(.*)/index.php;
}
try_files$uri$uri//index.php?$query_string;
}
# PHP脚本请求全部转发到 FastCGI处理.使用FastCGI协议默认配置.
# Fastcgi服务器和程序(PHP)沟通的协议
.location~.*\.php${
#设置监听端口
fastcgi_pass 127.0.0.1:9000;
#设置nginx的默认首页文件
fastcgi_index index.php;
#设置脚本文件请求的路径
fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;
#引入fastcgi的配置文件
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set$path_info$fastcgi_path_info;
fastcgi_param PATH_INFO$path_info;
try_files$fastcgi_script_name=404;
}
}
3,如果多项目部署,就需要配置vhost
第一步:编辑nginx.conf文件,在最后加上 include vhost/*.conf;
第二步:进入vhost文件夹,创建域名.conf文件,如创建一个:quanma.meyat.com.conf
第三步:编辑quanma.meyat.com.conf文件,内容如下:
server
{
listen 80;
server_name quanma.meyat.com;
index index.html index.htm index.php default.html default.htm default.php;
root/data/wwwroot/default/quanma/public/;
#error_page 404/404.html;
location/{
index index.html index.php;
if(-f$request_filename/index.html){
rewrite(.*)$1/index.html break;
}
if(-f$request_filename/index.php){
rewrite(.*)$1/index.php;
}
if(!-f$request_filename){
rewrite(.*)/index.php;
}
try_files$uri$uri//index.php?$query_string;
}
location~ [^/]\.php(/|$)
{
# comment try_files$uri=404; to enable pathinfo
#try_files$uri=404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set$path_info$fastcgi_path_info;
fastcgi_param PATH_INFO$path_info;
try_files$fastcgi_script_name=404;
#include fastcgi.conf;
#include pathinfo.conf;
}
location~.*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location~.*\.(js|css)?$
{
expires 12h;
}
# Disallow access to.ht,.svn,.bzr,.git,.hg,.cvs directories
location~/\.(ht|svn|bzr|git|hg|cvs){
deny all;
}
#access_log/date/nginx/bmp.com.conf/access.log main;
}
thinkphp5的问题
ThinkPHP5在保持快速开发和大道至简的核心理念不变的同时,PHP版本要求提升到5.4,对已有的CBD模式做了更深的强化,优化核心,减少依赖,基于全新的架构思想和命名空间实现,是ThinkPHP突破原有框架思路的颠覆之作,其主要特性包括:
基于命名空间和众多PHP新特性
核心功能组件化
强化路由功能
更灵活的控制器
配置文件可分离
简化扩展机制
API支持完善
文章分享结束,thinkphp5和thinkphp5菜鸟教程的答案你都知道了吗?欢迎再次光临本站哦!