1 Star 0 Fork 3

miss1994 / manual

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

manual

manual

安装

首先创建一个工程:

composer create-project ebcms/project

进入工程目录,然后安装本系统

composer require xielei/manual

安装完成后,需要配置数据库信息,新建config/xielei/database/database.php数据库配置文件,配置如下:

// 若采用mysql数据库,则配置如下,还要导入包里面的import.sql
return [
  'database_name' => '...',
  'server' => '127.0.0.1',
  'username' => '...',
  'password' => '...',
];

// 若采用sqlite,则配置
return [
  'database_type' => 'sqlite',
  'database_file' => 'E:\WWW\ebcms\config\sqlite.db', //根据你的情况填写,包里面有sqlite.db
  'command' => null,
];

当然,也可以动态配置,需要在app.start@xielei.manual上挂载如下代码:

use Ebcms\App;
use Ebcms\Config;

App::getInstance()->execute(function (
    App $app,
    Config $config
) {
    // sqlite
    $config->set('database.database_type@xielei.database', 'sqlite');
    $config->set('database.database_file@xielei.database', $app->getAppPath() . '/config/xielei/manual/manual.db');
    $config->set('database.command@xielei.database', null);
    // mysql
    // ...
});

特点

  • markdown书写
  • 搜索
  • 多级目录

案例

自定义路由

可通过下面的代码实现自定义路由,并挂载到钩子 app.start

use App\Xielei\Manual\Http\Home\Manual;
use App\Xielei\Manual\Http\Home\Post;
use App\Xielei\Manual\Http\Home\Search;
use Ebcms\App;
use Ebcms\Router;

App::getInstance()->execute(function (
    Router $router
) {
    $router->getCollector()->addGroup((function (): string {
        if (
            (!empty($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] == 'https')
            || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
            || (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443')
        ) {
            $schema = 'https';
        } else {
            $schema = 'http';
        }

        $script_name = '/' . implode('/', array_filter(explode('/', $_SERVER['SCRIPT_NAME'])));
        $request_uri = parse_url('/' . implode('/', array_filter(explode('/', $_SERVER['REQUEST_URI']))), PHP_URL_PATH);
        if (strpos($request_uri, $script_name) === 0) {
            return $schema . '://' . $_SERVER['HTTP_HOST'] . $script_name;
        } else {
            return $schema . '://' . $_SERVER['HTTP_HOST'] . (strlen(dirname($script_name)) > 1 ? dirname($script_name) : '');
        }
    })(), function ($route) {
        $route->get('/manual/search/{manual_id}', Search::class, '/xielei/manual/home/search');
        $route->get('/manual/{id}', Manual::class, '/xielei/manual/home/manual');
        $route->get('/manual/post/{id}', Post::class, '/xielei/manual/home/post');
    });
});
MIT License Copyright (c) 2020 xielei Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

manual 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/miss1994/manual.git
git@gitee.com:miss1994/manual.git
miss1994
manual
manual
master

搜索帮助