动手开发一个简易的 PHP for Git Server 第一章

来源:互联网 发布:中国大数据咨询公司 编辑:程序博客网 时间:2024/06/05 09:27

事情的前因后果,这里不再讲述,直接切入主题进行项目开发,谨以此献给喜欢研究 GIT 的小伙伴

项目结构:

+ router.php // 路由文件+ app.php // 应用文件+ git.php // Git 操作核心文件+ index.php // 入口文件

接下来,将用倒叙的方式,对 git server 进行展开,首先,看一下 index.php

$router = new Router;$app = new App;$app->gitRoot = 'D:\Code\git-demo';// 设置 git 仓库目录,用于服务器端存放各 git 仓库// get repo info/refs$router->any(['get', 'head'], '/*\.git/info/refs', [$app, 'getInfoRefs']);$router->post('/*\.git/git-[a-z]+-pack', [$app, 'command']);// access file contents$router->any(['get', 'head'], '/*\.git/*', function() {return false;});$router->post('/create', function() {    echo Git::init('mine');});$router->run();
原创粉丝点击