• 3.layhm框架的流程与Boot类启动


    思路

    1. 在项目根目录里新建好对应的目录
    2. cmd里在项目根目录里,composer init初使化,一路回车
    3. 把要自动加载的文件和目录定在composer.json文件的autoload里,file是自动加载的文件 psr-4是自动加载的目录
    4. composer dump生成vendor目录
    5. hmcorefunctions.php是公共文件,公共函数可以都放在这里,
    6. hmcoreBoot.php是启动文件.
    7. publicindex.php是文件的单一入口文件. include '../vendor/autoload.php'; 调用hmcoreBoot::run();方法


    "autoload":{
            "files":[
                "hm/core/functions.php"
            ],
            "psr-4":{
                "hm\":"hm\",
                "app\":"app",
                "system\":"system"
            }
        }
    

    D:xampphtdocsluymiya>composer dump
    Generating autoload files

    安装好后会多出vendor目录

    public/index.php

    <?php
    include '../vendor/autoload.php';
    p(13);
    hmcoreBoot::run();
    ?>
    

    hmcorefunctions.php

    <?php
    function p($var){
        echo '<pre>';
        print_r($var);
        echo '</pre>';
    }
    

    hmcoreBoot.php

    <?php
    /**
     * Created by Haima.
     * Author:Haima
     * QQ:228654416
     * Date: 2018/9/12
     * Time: 5:39
     */
    
    namespace hmcore;
    
    class Boot
    {
        public static function run()
        {
            echo 'Boot run';
        }
    }
    

    打印结果
    13
    Boot run

    [Haima的博客] http://www.cnblogs.com/haima/
  • 相关阅读:
    SharedPreferences
    Handler
    Gallery 和ImageSwitcher
    poj 1077 Eight (BFS)
    HDU 1208 Pascal's Travels( 记忆化搜索)
    HDU 1619 Unidirectional TSP (dp,dfs)
    HDU 3683 Gomoku (枚举+BFS)
    HDU 3647 Tetris (暴力DFS)
    poj 1020 Anniversary Cake (DFS)
    poj 1375 Intervals(解析几何 过圆外一点求与圆的切线)
  • 原文地址:https://www.cnblogs.com/haima/p/9632486.html
Copyright © 2020-2023  润新知