zoukankan      html  css  js  c++  java
  • PHP框架开发——使用composer加载文件

    开始开发框架的时候想使用php的自动加载函数来加载自定义的类,但是后来发现

    • 类多了之后写加载函数太麻烦
    • 与新技术不接轨

    哈哈,所以就使用composer重新代码重写了一下,顺便记录下在本地使用composer开发项目的步骤

    首先新建一个composer扩展目录  /home/www/wwwroot/gdemo/hiframe/framework  并且创建 composer.json 文件,例如

    {
      "name": "hiframe/framework",
      "require": {
        "php": ">7.0"
      },
      "authors": [
        {
          "name": "gphper",
          "email": "570165887@qq.com"
        }
      ],
      "autoload": {
        "psr-4": {
          "HiFrame\Framework\":"src"
        },
        "files": [
          "src/Support/helpers.php"
        ]
      }
    }

    然后在项目的根目录  /home/www/wwwroot/gdemo  新建composer.json定义内容如下

    {
      "name": "hiframe/hiframe",
      "require": {
        "hiframe/framework": "dev-master"
      },
      "repositories": {
        "hiframe/framework": {
          "type": "path",
          "url": "/home/www/wwwroot/gdemo/hiframe/framework"
        }
      },
      "autoload": {
        "psr-4": {
            "App\": "app"
        },
        "files": [
          "routes/api.php"
        ]
      }
    }

    然后执行  composer install 实例化项目就好啦。

    至于发布composer包的过程,可以参考下这篇 https://www.cnblogs.com/huaweichenai/p/10255439.html

  • 相关阅读:
    [CF1462F] The Treasure of The Segments
    [CF1466E] Apollo versus Pan
    SYZOJ 搭建 Note
    [CF1476D] Journey
    [CF1476E] Pattern Matching
    [CF1494D] Dogeforces
    [CF1383B] GameGame
    [CF1383A] String Transformation 1
    [CF1453D] Checkpoints
    [CF1453C] Triangles
  • 原文地址:https://www.cnblogs.com/itsuibi/p/13585425.html
Copyright © 2011-2022 走看看