openi-ict/api-builder

OPENi API Builder 的实现

安装: 0

依赖: 0

建议者: 0

安全: 0

星标: 2

关注者: 13

分支: 2

开放问题: 0

语言:CSS

类型:项目

v1.2.0 2015-04-16 11:29 UTC

README

OPENi API Builder 是一个允许开发者添加对象和组合方法以与官方 OPENi API 框架 一起使用的网络项目。

Latest Stable Version Build Status

目录结构

  .docs/              contains Documents for building the API Builder (mockups etc.)
  assets/             contains assets definition
  commands/           contains console commands (controllers)
  config/             contains application configurations
  controllers/        contains Web controller classes
  mail/               contains view files for e-mails
  migrations/         contains migrations for the database to be configured automatically
  models/             contains model classes
  runtime/            contains files generated during runtime
  tests/              contains various tests for the basic application (not yet fully charged)
  vendor/             contains dependent 3rd-party packages
  views/              contains view files for the Web application
  web/                contains the entry script and Web resources
  widgets/            contains additional widgets used in this app

要求

本应用程序模板的最低要求是您的 Web 服务器支持 PHP 5.4.0。在 composer.json 文件中标记了所需的其他包。

安装

此处 下载最新版本或从 api-builder 下载压缩的 master 源代码,并将其放入 Web 根目录下的名为 api-builder 的目录中。

在该目录中打开命令提示符并输入

composer global require "fxp/composer-asset-plugin:1.0.0"
composer install

注意:如果您没有 Composer,可以按照 getcomposer.org 上的说明进行安装。

这将获取所有所需的包并将它们保存到您的 vendor 目录中。

然后您可以通过以下 URL 访问应用程序

https:///api-builder/web/

注意:为了在 API 视图中拥有推荐功能,应从 此处 安装 Elasticsearch

配置

数据库

创建一个包含实际数据的文件 config/db.php,例如

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=apiBuilder',
    'username' => 'root',
    'password' => '1234',
    'charset' => 'utf8',
];

或者将 dbSample.php 重命名为包含实际数据的文件。

然后,打开终端并运行

yii migrate

以创建数据库中的所有表。

还要检查并编辑 config/ 目录中的其他文件以自定义应用程序。如果您的网站不是 https:///api-builder/,您需要更新 /web/js/swagger/site.js 中 js 文件的 url 属性。

最后,您需要将 /web/indexSample.php 重命名为 /web/index.php 以使应用程序正常工作,如果您处于生产环境,则需要取消注释环境行。

Elasticsearch

此请求应用于创建 'api-builder' 索引

curl -XPUT http://127.0.0.1:9200/api-builder
curl -XPOST http://127.0.0.1:9200/api-builder/_close

推荐设置

curl -XPUT 'http://127.0.0.1:9200/api-builder/_settings' -d 
'{
     "settings": {
         "index": {
             "analysis": {
                 "filter": {
                     "stem_filter": {
                         "type": "stemmer",
                         "name": "english"
                     },
                     "low_filter": {
                         "type": "lowercase"
                     },
                     "synonym_filter": {
                         "type": "synonym",
                         "synonyms_path": "analysis/synonyms.txt"
                     },
                     "stop_filter": {
                         "type": "stop",
                         "stopwords_path": "analysis/stopwords.txt"
                     }
                 },
                 "analyzer": {
                     "analyzer": {
                         "type": "custom",
                         "tokenizer": "standard",
                         "filter": [
                             "low_filter",
                             "synonym_filter",
                             "stop_filter",
                             "stem_filter"
                         ],
                         "char_filter": [
                             "html_strip"
                         ]
                     }
                 }
             }
         }
     }
 }'

注意:这当然意味着您在 elasticsearch/config/ 文件夹中有同义词和停用词文本。示例可以在项目的根目录中找到。

curl -XPUT 'http://127.0.0.1:9200/api-builder/api/_mapping' -d 
'{ 
     "api": { 
         "properties": { 
             "objects": { 
                 "type": "nested", 
                 "properties": { 
                     "name": { 
                         "type": "string", 
                         "index": "analyzed", 
                         "analyzer": "analyzer"
                     }, 
                     "description": { 
                         "type": "string", 
                         "index": "analyzed", 
                         "analyzer": "analyzer" 
                     }, 
                     "properties": { 
                         "type": "nested", 
                         "properties": { 
                             "name": { 
                                 "type": "string", 
                                 "index": "analyzed", 
                         "analyzer": "analyzer"
                             }, 
                             "type": { 
                                 "type": "string", 
                                 "index": "not_analyzed" 
                             } 
                         } 
                     } 
                 } 
             } 
         } 
     } 
 }'
curl -XPOST http://127.0.0.1:9200/api-builder/_open

开发所使用的技术栈 - 非常感谢!

yii 2

composer

bootstrap

bootstrap-material-design

Krajee Yii 扩展

Elasticsearch