zoukankan      html  css  js  c++  java
  • Astrology PHP 框架

    1、Web 服务器配置

    PHP 支持

    URL Rewrite、PATH_INFO

    2、环境需求

     PHP 7.2+

    扩展:gettext

    3、目录结构

    + src

       | - autoload.php

       | + Astrology

           | - Start.php

           | - Kernel.php

           | - Controller.php

           | - Database.php

           | - View.php

       | + Anfora

           | - Autoload.php

           | + Autoload

               | - ClassLoader.php

       | + DbTable

       | + Extension

    + app

       | - bootstrap.php

       | - config.php

       | + Index

       | + _App

          | + Controller

              | - _Controller.php

              | - Index.php

          | + Model

          | + View

              | + _Controller

                  | - _NotFound.php

                  | - index.mobi..php

                  | - index.php

              | + _helper

                  | - footer.php

              | + _layout

                  | - default.mobi..php

                  | - default.php

              | + Index

    + web

       | - .htaccess

       | - index.php

    4、入口文件

    web/index.php

    require_once __DIR__ . '/../app/bootstrap.php';
    new \Astrology\Start();

    5、引导文件

    app/bootstrap.php

    define('APP_ROOT', realpath(__DIR__));
    define('ANFORA_AUTOLOAD', 0);
    
    if (ANFORA_AUTOLOAD) {
        require APP_ROOT . '/../src/autoload.php';
    } else {
        require APP_ROOT . '/../vendor/autoload.php';
    }
    
    include_once 'function.php';

    6、自动加载类

    src/autoload.php

    require_once __DIR__ . '/Anfora/Autoload.php';
    return Anfora_Autoload::getLoader();

    7、运行

    src/Astrology/Start.php

    class Start extends Kernel
    {
        public function __construct()
        {
            $this->loadConfig();    
            $this->initRoute();     
            $this->loadController();
        }
     
        public function loadConfig()
        {
            $GLOBALS['CONFIG'] = include_once APP_ROOT . '/config.php';
     
            /* 这里获取配置中的默认语言、客户端语言... */
            /* 使用 gettext 扩展、没有的话用 PHP 数组代替 */
             
            @$GLOBALS['LANG'] = include_once $directory . "/$locale/LC_MESSAGES/$text_domain.php";
        }
    }

    8、主内核

    class Kernel
    {
        public function __construct()
        {
            /* REQUEST_URI 修正 */
            /* 开启缓存、php_errormsg 和 php.ini 信息、客户端设备检测 */
        }

    public function initRoute() { /* 默认路由设置 */ /* 从 REQUEST_URI、PATH_INFO、QUERY_STRING(m, c, a 或 r)获取路由信息 */ /* 匹配路由规则 */ /* 模块和控制器异常处理 */ } public function loadController() { /* 添加 Composer 加载规则 */ /* 检测模块和控制器、引入控制器 */ } }

    9、控制器原型

    class Controller
    {
        public function __construct()
        {
            /* 设置动作方法 */
            /* 是否开启 session */
        }
    
        public function run($method = null)
        {
            /* 执行方法 */
        }
    
        public function _NotFound()
        {
            /* 全局未找到动作 */
        }
    
        public function _redirect($url = '/', $second = null, $prefix = null)
        {
            /* 几种重定向 */
        }
    
        public function __destruct()
        {
            /* 是否自动运行 */
            /* 是否渲染页面 */
            /* 输出格式 */
        }
    }
  • 相关阅读:
    Java 给Word指定字符串添加批注
    Java 打印Word文档
    Java 在PDF中添加页面跳转按钮
    C# 添加、修改、删除Excel图表数据标签
    C# 添加、读取、删除Excel文档属性
    Java 操作Word表格——创建嵌套表格、添加/复制表格行或列、设置表格是否禁止跨页断行
    【Luogu5348】密码解锁(莫比乌斯反演,数论)
    AtCoder Grand Contest 015
    AtCoder Grand Contest 014
    Codeforces Round #556 (Div. 1)
  • 原文地址:https://www.cnblogs.com/wudi/p/8506442.html
Copyright © 2011-2022 走看看