承接 vitexsoftware/multiflexi-api-server 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vitexsoftware/multiflexi-api-server

Composer 安装命令:

composer require vitexsoftware/multiflexi-api-server

包简介

README 文档

README

This server has been generated with Slim PSR-7 implementation. PHP-DI package used as dependency container.

Requirements

  • Web server with URL rewriting
  • PHP 8.1 or newer

This package contains .htaccess for Apache configuration. If you use another server(Nginx, HHVM, IIS, lighttpd) check out Web Servers doc.

Installation via Composer

Navigate into your project's root directory and execute the bash command shown below. This command downloads the Slim Framework and its third-party dependencies into your project's vendor/ directory.

$ composer install

Add configs

PHP-DI package helps to decouple configuration from implementation. App loads configuration files in straight order($env can be prod or dev):

  1. config/$env/default.inc.php (contains safe values, can be committed to vcs)
  2. config/$env/config.inc.php (user config, excluded from vcs, can contain sensitive values, passwords etc.)
  3. lib/App/RegisterDependencies.php

Start devserver

Run the following command in terminal to start localhost web server, assuming ./php-slim-server/public/ is public-accessible directory with index.php file:

$ php -S localhost:8888 -t php-slim-server/public

Warning This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.

Tests

PHPUnit

This package uses PHPUnit 8 or 9(depends from your PHP version) for unit testing. Test folder contains templates which you can fill with real test assertions. How to write tests read at 2. Writing Tests for PHPUnit - PHPUnit 8.5 Manual.

Run

Command Target
$ composer test All tests
$ composer test-apis Apis tests
$ composer test-models Models tests

Config

Package contains fully functional config ./phpunit.xml.dist file. Create ./phpunit.xml in root folder to override it.

Quote from 3. The Command-Line Test Runner — PHPUnit 8.5 Manual:

If phpunit.xml or phpunit.xml.dist (in that order) exist in the current working directory and --configuration is not used, the configuration will be automatically read from that file.

PHP CodeSniffer

PHP CodeSniffer Documentation. This tool helps to follow coding style and avoid common PHP coding mistakes.

Run

$ composer phpcs

Config

Package contains fully functional config ./phpcs.xml.dist file. It checks source code against PSR-1 and PSR-2 coding standards. Create ./phpcs.xml in root folder to override it. More info at Using a Default Configuration File

PHPLint

PHPLint Documentation. Checks PHP syntax only.

Run

$ composer phplint

Show errors

Switch your app environment to development

  • When using with some webserver => in public/.htaccess file:
## .htaccess
<IfModule mod_env.c>
    SetEnv APP_ENV 'development'
</IfModule>
  • Or when using whatever else, set APP_ENV environment variable like this:
export APP_ENV=development

or simply

export APP_ENV=dev

Mock Server

Since this feature should be used for development only, change environment to development and send additional HTTP header X-MultiFlexi\Api-Mock: ping with any request to get mocked response. CURL example:

curl --request GET \
    --url 'http://localhost:8888/v2/pet/findByStatus?status=available' \
    --header 'accept: application/json' \
    --header 'X-MultiFlexi\Api-Mock: ping'
[{"id":-8738629417578509312,"category":{"id":-4162503862215270400,"name":"Lorem ipsum dol"},"name":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem i","photoUrls":["Lor"],"tags":[{"id":-3506202845849391104,"name":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectet"}],"status":"pending"}]

Used packages:

Logging

Build contains pre-configured monolog/monolog package. Make sure that logs folder is writable. Add required log handlers/processors/formatters in lib/App/RegisterDependencies.php.

API Endpoints

All URIs are relative to https://virtserver.swaggerhub.com/VitexSoftware/MultiFlexi/1.0.0

Important! Do not modify abstract API controllers directly! Instead extend them by implementation classes like:

// src/Api/PetApi.php

namespace MultiFlexi\Api\Server;

use MultiFlexi\Api\Server\AbstractPetApi;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;

class PetApi extends AbstractPetApi
{
    public function addPet(
        ServerRequestInterface $request,
        ResponseInterface $response
    ): ResponseInterface {
        // your implementation of addPet method here
    }
}

When you need to inject dependencies into API controller check PHP-DI - Controllers as services guide.

Place all your implementation classes in ./src folder accordingly. For instance, when abstract class located at ./lib/Api/AbstractPetApi.php you need to create implementation class at ./src/Api/PetApi.php.

Class Method HTTP request Description
AbstractAppApi setAppById POST /app/ Create or Update Application
AbstractAppApi getAppById GET /app/{appId}.{suffix} Get App by ID
AbstractAppApi listApps GET /apps.{suffix} Show All Apps
AbstractCompanyApi setCompanyById POST /company/ Create or Update Company
AbstractCompanyApi getCompanyById GET /company/{companyId}.{suffix} Get Company by ID
AbstractCompanyApi listCompanies GET /companies.{suffix} Show All Companies
AbstractDefaultApi logoutPost POST /logout Odhlášení uživatele (invalidate token/session)
AbstractDefaultApi rootGet GET / Redirect to index
AbstractDefaultApi getAllCredentialTypes GET /credential_types.{suffix} Get All Credential Types
AbstractDefaultApi getAllTopics GET /topics.{suffix} Get All Topics
AbstractDefaultApi getAllUserCredentials GET /credentials.{suffix} Get All User Credentials
AbstractDefaultApi getApiIndex GET /index.{suffix} Endpoints listing
AbstractDefaultApi getCredential GET /credential/{credentialId}.{suffix} Get User Credentials
AbstractDefaultApi getCredentialType GET /credential_type/{credentialTypeID}.{suffix} Get Credential Type by ID
AbstractDefaultApi getJobsStatus GET /jobs/status.{suffix} Get Jobs Status
AbstractDefaultApi getTopic GET /topic/{topicId}.{suffix} Get Topic by ID
AbstractDefaultApi loginSuffixGet GET /login.{suffix} Return User's token
AbstractDefaultApi loginSuffixPost POST /login.{suffix} Return User's token
AbstractDefaultApi pingSuffixGet GET /ping.{suffix} job heartbeat operation
AbstractDefaultApi statusSuffixGet GET /status.{suffix} Get API status
AbstractDefaultApi updateCredentialType POST /credential_type/{credentialTypeID}.{suffix} Update Credential Type
AbstractDefaultApi updateCredentials POST /credential/{credentialId}.{suffix} Update Credentials
AbstractDefaultApi updateTopic POST /topic/{topicId}.{suffix} Update Topic
AbstractEventruleApi setEventRuleById POST /eventrule/ Create or Update EventRule
AbstractEventruleApi deleteEventRuleById DELETE /eventrule/{eventRuleId}.{suffix} Delete EventRule by ID
AbstractEventruleApi getEventRuleById GET /eventrule/{eventRuleId}.{suffix} Get EventRule by ID
AbstractEventruleApi listEventRules GET /eventrules.{suffix} Show All EventRules
AbstractEventsourceApi setEventSourceById POST /eventsource/ Create or Update EventSource
AbstractEventsourceApi deleteEventSourceById DELETE /eventsource/{eventSourceId}.{suffix} Delete EventSource by ID
AbstractEventsourceApi getEventSourceById GET /eventsource/{eventSourceId}.{suffix} Get EventSource by ID
AbstractEventsourceApi listEventSources GET /eventsources.{suffix} Show All EventSources
AbstractEventsourceApi testEventSourceConnection POST /eventsource/{eventSourceId}/test.{suffix} Test EventSource connection
AbstractGdprApi downloadDataExport GET /data-export-download Download personal data export file
AbstractGdprApi requestDataExport GET /data-export Request personal data export (GDPR Article 15)
AbstractGdprApi requestDataExportPost POST /data-export Request personal data export (GDPR Article 15)
AbstractJobApi setjobById POST /job/ Create or Update job record
AbstractJobApi getjobById GET /job/{jobId}.{suffix} Get job by ID
AbstractJobApi listjobs GET /jobs.{suffix} Show All jobs
AbstractRuntemplateApi setRunTemplateById POST /runtemplate Create or Update RunTemplate
AbstractRuntemplateApi getRunTemplateById GET /runtemplate/{runTemplateId}.{suffix} Get RunTemplate by ID
AbstractRuntemplateApi listRunTemplates GET /runtemplates.{suffix} Show All RunTemplates
AbstractRuntemplateApi updateRunTemplateById POST /runtemplate/{runTemplateId}.{suffix} Update RunTemplate by ID
AbstractUserApi setUserById POST /user/ Create or Update User
AbstractUserApi getUserById GET /user/{userId}.{suffix} Get User by ID
AbstractUserApi listUsers GET /users.{suffix} Show All Users

Models

  • MultiFlexi\Api\Model\App
  • MultiFlexi\Api\Model\AppEnvironmentValue
  • MultiFlexi\Api\Model\AppExitCodesInner
  • MultiFlexi\Api\Model\Company
  • MultiFlexi\Api\Model\ConfField
  • MultiFlexi\Api\Model\Configuration
  • MultiFlexi\Api\Model\Credential
  • MultiFlexi\Api\Model\CredentialType
  • MultiFlexi\Api\Model\Customer
  • MultiFlexi\Api\Model\DataExportData
  • MultiFlexi\Api\Model\DataExportDataActivityLogsInner
  • MultiFlexi\Api\Model\DataExportDataAuditTrails
  • MultiFlexi\Api\Model\DataExportDataAuditTrailsDataExportRequestsInner
  • MultiFlexi\Api\Model\DataExportDataCompanyAssociationsInner
  • MultiFlexi\Api\Model\DataExportDataConsentRecords
  • MultiFlexi\Api\Model\DataExportDataConsentRecordsConsentAuditTrailInner
  • MultiFlexi\Api\Model\DataExportDataConsentRecordsConsentRecordsInner
  • MultiFlexi\Api\Model\DataExportDataCredentialsInner
  • MultiFlexi\Api\Model\DataExportDataExportMetadata
  • MultiFlexi\Api\Model\DataExportDataJobHistoryInner
  • MultiFlexi\Api\Model\DataExportDataSessionHistory
  • MultiFlexi\Api\Model\DataExportDataSessionHistoryCurrentSessionInfo
  • MultiFlexi\Api\Model\DataExportDataUserProfile
  • MultiFlexi\Api\Model\DataExportResponse
  • MultiFlexi\Api\Model\DataExportStatusResponse
  • MultiFlexi\Api\Model\DataExportStatusResponseExportsInner
  • MultiFlexi\Api\Model\ErrorResponse
  • MultiFlexi\Api\Model\EventRule
  • MultiFlexi\Api\Model\EventSource
  • MultiFlexi\Api\Model\GetCredentialType200Response
  • MultiFlexi\Api\Model\GetTopic200Response
  • MultiFlexi\Api\Model\Job
  • MultiFlexi\Api\Model\JobsStatus
  • MultiFlexi\Api\Model\LogoutPostRequest
  • MultiFlexi\Api\Model\RequestDataExport200Response
  • MultiFlexi\Api\Model\RequestDataExportPostRequest
  • MultiFlexi\Api\Model\RunTemplate
  • MultiFlexi\Api\Model\Status
  • MultiFlexi\Api\Model\Tag
  • MultiFlexi\Api\Model\TestEventSourceConnection200Response
  • MultiFlexi\Api\Model\Topic
  • MultiFlexi\Api\Model\UpdateCredentials201Response
  • MultiFlexi\Api\Model\UpdateRunTemplateById400Response
  • MultiFlexi\Api\Model\UpdateRunTemplateById404Response
  • MultiFlexi\Api\Model\UpdateRunTemplateById500Response
  • MultiFlexi\Api\Model\UpdateRunTemplateByIdRequest
  • MultiFlexi\Api\Model\User

Authentication

Security schema basicAuth

Important! To make Basic authentication work you need to extend \MultiFlexi\Api\Auth\AbstractAuthenticator class by \MultiFlexi\Api\Auth\BasicAuthenticator class.

Advanced middleware configuration

Ref to used Slim Token Middleware dyorg/slim-token-authentication

vitexsoftware/multiflexi-api-server 适用场景与选型建议

vitexsoftware/multiflexi-api-server 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 470 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 vitexsoftware/multiflexi-api-server 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 vitexsoftware/multiflexi-api-server 我们能提供哪些服务?
定制开发 / 二次开发

基于 vitexsoftware/multiflexi-api-server 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 470
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-07