zoukankan      html  css  js  c++  java
  • 关于ThinkPHP_5 的入口文件

    config类与config助手函数

      类:/think/library/think/config.php
      助手函数:/think/helper.php


    隐藏入口文件:
      http://tpweb.com/index.php/index/index/index
      http://tpweb.com/index/index/index

    服务器配置(apache)

      apache -> conf -> httpd.conf
      搜索一下rewrite
      #LoadModule rewrite_module modules/mod_rewrite.so 将前面的#去掉
      找到网站根目录的配置 <Directory "G:/xampp/htdocs">
      将AllowOverride None 改为 AllowOverride All
      保存
      重启apache

    在public目录下有一个.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] //这条规则,将当前请求重定向到index.php
      </IfModule>

    入口文件绑定

    方法一:
      在public/index.php入口文件中,添加define('BIND_MODULE','admin');
      当访问index.php,就会自动访问到admin模块
      如果没有这个模块,就会报错。
    方法二:
      在public下新建api.php入口文件,在app下由api模块
      应用配置文件中,添加 'auto_bind_module' =>true【自动绑定模块,默认是false】
      当访问api.php的入口文件时,就会自动寻找相同名字的模块。
      如果没有这个模块,会访问到其他模块。

    路由:
      1、应用配置文件中添加

      // 是否开启路由
      'url_route_on' => true,
      // 是否强制使用路由
      'url_route_must' => false,


      2、再在配置文件同级目录,新建route.php【名称规定的,必须为route.php】,并制定规则,
      以后就变成news/5的形式【原形式:index/index/info/id/5】
      <?php
      return [
        //要访问的规则 => 要访问的方法
        'news/:id' => 'index/index/info',
      ];

  • 相关阅读:
    hdu 4027 Can you answer these queries?
    hdu 4041 Eliminate Witches!
    hdu 4036 Rolling Hongshu
    pku 2828 Buy Tickets
    hdu 4016 Magic Bitwise And Operation
    pku2886 Who Gets the Most Candies?(线段树+反素数打表)
    hdu 4039 The Social Network
    hdu 4023 Game
    苹果官方指南:Cocoa框架(2)(非原创)
    cocos2d 中 CCNode and CCAction
  • 原文地址:https://www.cnblogs.com/Caveolae/p/7112298.html
Copyright © 2011-2022 走看看