thinkphp v5.1 开发笔记

一.安装TP5.1

  1.使用git安装

    <1>下载Tp

      git clone https://github.com/top-think/think tp5

    <2>安装核心库

      git clone https://github.com/top-think/framework thinkphp

  2.使用compose安装(需下载compose)

   compose下载链接

  https://getcomposer.org/Composer-Setup.exe

  第一次安装使用,切换到web目录下:

  composer create-project topthink/think tp5

二.绑定入口文件到根目录下

  复制public文件夹下的index.php文件到根目录下

  修改index.php中的引入base.php文件路径

  

<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

// [ 应用入口文件 ]
namespace think;

// 加载基础文件
require __DIR__ . '/thinkphp/base.php';

// 支持事先使用静态方法设置Request对象和Config对象

// 执行应用并响应
Container::get('app')->run()->send();

  访问路径:http://localhost/fuxiphp/tp5/index.php

  

  三.URl重写

  在入口文件(index.php)同级添加.htaccess文件

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

  四.模块设计

  

  

原文地址:https://www.cnblogs.com/a-dong/p/10424232.html