appwrite/sdk-generator
Composer 安装命令:
composer require appwrite/sdk-generator
包简介
SDK generator for Appwrite APIs across multiple programming languages and platforms
README 文档
README
Appwrite SDK generator is a PHP library for auto-generating SDK libraries for multiple languages and platforms.
The SDK Generator uses predefined language settings as Twig templates to generate codebases based on different API specs.
Both OpenAPI 3.0 and Swagger 2.0 specs are supported and produce identical SDKs, including services, methods, models, enums, and union types.
Getting Started
Install using composer:
CLI
composer update --ignore-platform-reqs --optimize-autoloader
Docker (UNIX)
docker run --rm --interactive --tty --volume "$(pwd)":/app composer install --ignore-platform-reqs
Docker (Windows)
docker run --rm --interactive --tty --volume "%cd%":/app composer install --ignore-platform-reqs
Create language and SDK instances and generate code to target directory.
<?php require_once 'vendor/autoload.php'; use Appwrite\Spec\OpenAPI3; use Appwrite\SDK\SDK; use Appwrite\SDK\Language\PHP; // Read API specification file (OpenAPI 3) and create spec instance $version = '1.9.x'; $platform = 'server'; $spec = new OpenAPI3(file_get_contents("https://raw.githubusercontent.com/appwrite/specs/main/specs/{$version}/open-api3-{$version}-{$platform}.json")); // Swagger 2 specs are supported as well: // use Appwrite\Spec\Swagger2; // $spec = new Swagger2(file_get_contents("https://raw.githubusercontent.com/appwrite/specs/main/specs/{$version}/swagger2-{$version}-{$platform}.json")); // Create language instance $lang = new PHP(); $lang // Set language or platform specific options ->setComposerPackage('my-api') ->setComposerVendor('my-company') ; // Create the SDK object with the language and spec instances $sdk = new SDK($lang, $spec); $sdk ->setCoverImage('https://github.com/appwrite/appwrite/raw/main/public/images/github.png') ->setLicenseContent('License content here.') ->setVersion('v1.1.0') ; $sdk->generate(__DIR__ . '/examples/php'); // Generate source code
For generated artifacts that do not need an API specification, use StaticSpec:
<?php require_once 'vendor/autoload.php'; use Appwrite\Spec\StaticSpec; use Appwrite\SDK\SDK; use Appwrite\SDK\Language\Skills; $spec = new StaticSpec( title: 'Appwrite', description: 'Appwrite backend as a service', version: '1.9.x', licenseName: 'BSD-3-Clause', licenseURL: 'https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE', ); $sdk = new SDK(new Skills(), $spec); $sdk ->setName('Appwrite') ->setVersion('1.9.x') ; $sdk->generate(__DIR__ . '/examples/skills');
Linting Twig Templates
This project uses djLint to lint Twig template files for syntax and common issues.
Note: Formatting is disabled as it breaks code generation syntax. Only linting is used.
Available command:
composer lint-twig # Check for linting errors
Requires uv to be installed. Configuration is in pyproject.toml. The linter runs automatically on pull requests via GitHub Actions.
Supported Specs
- OpenAPI 3
- Swagger 2
- RAML 1.0 (Not Ready)
- RAML 0.8 (Not Ready)
- Postman 2.0 (Not Ready)
- Postman 1.0 (Not Ready)
- API Blueprint 1A (Not Ready)
Generated SDKs and Artifacts
The primary generation targets are defined in example.php. Run it without arguments to generate every target with the default console platform spec, or pass a target and optional platform to generate one SDK:
php example.php php example.php <target> php example.php <target> <platform> php example.php <target> <platform> <format>
<platform> can be console, client, or server. If omitted, it defaults to console.
<format> can be openapi3 or swagger2. If omitted, it defaults to openapi3. Both formats produce identical SDKs.
Examples:
php example.php web client php example.php node server php example.php cli console php example.php skills php example.php zed-extension
Client SDKs
| Target | Argument | Supported Versions | Coding Standards | Package Manager | Output |
|---|---|---|---|---|---|
| Web | web |
ES5+; Node.js >=18 for builds | NPM Coding Style | NPM | examples/web/ |
| Flutter | flutter |
Dart >=2.17 <4; Flutter stable | Effective Dart | pub | examples/flutter/ |
| Apple | apple |
iOS 15+, macOS 11+, watchOS 7+, tvOS 13+ | Swift Style Guide | Swift Package Manager | examples/apple/ |
| Android | android |
Android 6.0+; Java 17 in CI | Android style guide | Gradle, Maven | examples/android/ |
| React Native | react-native |
React Native >=0.76.7 <1.0.0; Node.js >=18 | NPM Coding Style | NPM | examples/react-native/ |
Server SDKs
| Target | Argument | Supported Versions | Coding Standards | Package Manager | Output |
|---|---|---|---|---|---|
| Node.js | node |
Node.js 20 in CI | NPM Coding Style | NPM | examples/node/ |
| PHP | php |
PHP >=8.2 | PHP FIG | Composer | examples/php/ |
| Python | python |
Python >=3.9 | PEP8 | pip | examples/python/ |
| Ruby | ruby |
Ruby 3.1 in CI | Ruby Style Guide | RubyGems, Bundler | examples/ruby/ |
| Dart | dart |
Dart >=2.17 <4 | Effective Dart | pub | examples/dart/ |
| Go | go |
Go 1.26.5 | Effective Go | Go modules | examples/go/ |
| Swift | swift |
Swift 5.1+; Swift 5.9.2 in CI | Swift Style Guide | Swift Package Manager | examples/swift/ |
| .NET | dotnet |
.NET Standard 2.0; .NET Framework 4.6.2 | C# Coding Conventions | NuGet | examples/dotnet/ |
| Kotlin | kotlin |
JVM 1.8 target; Java 17 in CI | Kotlin style guide | Gradle, Maven | examples/kotlin/ |
| Rust | rust |
Rust >=1.83 | Rust API Guidelines | Cargo | examples/rust/ |
Tooling and Documentation
| Target | Argument | Supported Versions | Coding Standards | Package Manager | Output |
|---|---|---|---|---|---|
| CLI | cli |
Node.js 20 and Bun 1.3.11 in CI | NPM Coding Style | NPM, Bun, native binaries | examples/cli/ |
| REST examples | rest |
N/A | Markdown | N/A | examples/REST/ |
| GraphQL | graphql |
N/A | GraphQL | N/A | examples/graphql/ |
| Skills | skills |
N/A | Markdown | N/A | examples/skills/ |
| Cursor Plugin | cursor-plugin |
N/A | Markdown | N/A | examples/cursor-plugin/ |
| Claude Plugin | claude-plugin |
N/A | Markdown | N/A | examples/claude-plugin/ |
| Codex Plugin | codex-plugin |
N/A | Markdown | N/A | examples/codex-plugin/ |
| Zed Extension | zed-extension |
Zed extension API 0.7.0 | Rust | Cargo | examples/zed-extension/ |
Contributing
All code contributions, including those by people with commit access, must go through a pull request and be approved by a core developer before being merged. This is to ensure proper review of all the code.
We truly ❤️ pull requests! If you wish to help, you can learn more about how you can contribute to this project in the contribution guide.
Copyright and license
The MIT License (MIT) http://www.opensource.org/licenses/mit-license.php
appwrite/sdk-generator 适用场景与选型建议
appwrite/sdk-generator 是一款 基于 Twig 开发的 Composer 扩展包,目前已累计 211.02k 次下载、GitHub Stars 达 322, 最近一次更新时间为 2019 年 05 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 appwrite/sdk-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 appwrite/sdk-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 211.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 322
- 点击次数: 17
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-23