小程序之旅——第四站(模板框架)

一、后台前端框架

后台前端页面框架使用ACE1.4框架

将ACE框架文件加压至public/static/下

二、后台框架配置文件

开发语言PHP

框架:ThinkPHP 5.1

开发环境下开启调试模式

application/config.php文件

return [
    // +----------------------------------------------------------------------
    // | 应用设置
    // +----------------------------------------------------------------------

    // 应用命名空间
    'app_namespace'          => 'app',
    // 应用调试模式
    'app_debug'              => true,
    // 应用Trace
    'app_trace'              => true,

app_debug改为true

app_trace改为true

 

application/admin/config.php文件

<?php
//配置文件
return [
    'extra_config_list'     => ['database'],
    //模板
    'template'  =>  [
    'layout_on'     =>  true,
    'layout_name'   =>  'layout',
    ],
    'public'=>[
        'static'=>'/OrderWechatApplet/public/static'
    ],
];

database.php文件

<?php

return [
    // 数据库类型
    'type'            => 'mysql',
    // 服务器地址
    'hostname'        => '127.0.0.1',
    // 数据库名
    'database'        => 'order',
    // 用户名
    'username'        => 'root',
    // 密码
    'password'        => 'root',
    // 端口
    'hostport'        => '3306',
    // 连接dsn
    'dsn'             => '',
    // 数据库连接参数
    'params'          => [],
    // 数据库编码默认采用utf8
    'charset'         => 'utf8',
    // 数据库表前缀
    'prefix'          => 'ord_',
    // 数据库调试模式
    'debug'           => true,
    
];

application/common.php文件

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

// 应用公共文件
// 异常错误报错级别,
error_reporting(E_ERROR | E_PARSE );

修改报错级别可忽略变量未定义的问题

三、入口文件隐藏

在ThinkPHP5.0中,出于优化的URL访问原则,还支持通过URL重写隐藏入口文件,下面以Apache为例说明隐藏应用入口文件index.php的设置。

下面是Apache的配置过程,可以参考下:
1、httpd.conf配置文件中加载了mod_rewrite.so模块
2、AllowOverride None 将None改为 All
3、在应用入口文件同级目录添加.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>

更多其它环境的隐藏入口文件参考后面的 URL重写

现在可以通过  http://localhost/项目名称/public/模块名称/控制器/方法   访问了

在正式环境上可以将服务地址指向  项目名称/public 

 

posted @ 2017-10-10 16:55  Rainbowz  阅读(307)  评论(0编辑  收藏  举报