承接 freedomtech-hosting/polydock-app 相关项目开发

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

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

freedomtech-hosting/polydock-app

Composer 安装命令:

composer require freedomtech-hosting/polydock-app

包简介

Library for Polydock Apps

README 文档

README

NOTE: Deprecated — see the polydock-engine repo.

Polydock App Library

A PHP library providing the core interfaces, base classes, and utilities for building Polydock applications. This library defines the contract for app lifecycle management, instance handling, and integration with the Polydock engine.

Quick Start

Create a new Polydock app by extending PolydockAppBase:

<?php

namespace MyVendor\MyPolydockApp;

use FreedomtechHosting\PolydockApp\Attributes\PolydockAppTitle;
use FreedomtechHosting\PolydockApp\PolydockAppBase;
use FreedomtechHosting\PolydockApp\PolydockAppInstanceInterface;
use FreedomtechHosting\PolydockApp\PolydockAppVariableDefinitionBase;

#[PolydockAppTitle('My Custom App', 'A description of what my app does')]
class MyPolydockApp extends PolydockAppBase
{
    public static string $version = '1.0.0';

    public static function getAppVersion(): string
    {
        return self::$version;
    }

    public static function getAppDefaultVariableDefinitions(): array
    {
        return [
            new PolydockAppVariableDefinitionBase('my-required-variable'),
            new PolydockAppVariableDefinitionBase('another-variable'),
        ];
    }

    public function preCreateAppInstance(PolydockAppInstanceInterface $appInstance): PolydockAppInstanceInterface
    {
        $this->info('Pre-create hook executing...');
        // Your pre-create logic here
        return $appInstance;
    }

    public function createAppInstance(PolydockAppInstanceInterface $appInstance): PolydockAppInstanceInterface
    {
        $this->info('Creating app instance...');
        // Your create logic here
        return $appInstance;
    }

    // Implement other lifecycle methods as needed...
}

Custom Store App Form Fields

Polydock App classes can define custom form fields that appear in the admin panel when configuring a Store App. These fields allow app-specific settings to be collected and stored.

Defining Custom Fields

  1. Add the #[PolydockAppStoreFields] attribute to your class
  2. Implement the HasStoreAppFormFields interface (recommended for type safety)
  3. Create static getStoreAppFormSchema() and getStoreAppInfolistSchema() methods
use FreedomtechHosting\PolydockApp\Attributes\PolydockAppTitle;
use FreedomtechHosting\PolydockApp\Attributes\PolydockAppStoreFields;
use FreedomtechHosting\PolydockApp\Contracts\HasStoreAppFormFields;
use Filament\Forms;
use Filament\Infolists;

#[PolydockAppTitle('My Custom App')]
#[PolydockAppStoreFields]
class MyCustomApp extends PolydockAppBase implements HasStoreAppFormFields
{
    public static function getStoreAppFormSchema(): array
    {
        return [
            Forms\Components\Section::make('Custom Settings')
                ->schema([
                    Forms\Components\TextInput::make('custom_endpoint')
                        ->label('API Endpoint')
                        ->url()
                        ->required(),

                    Forms\Components\TextInput::make('api_secret')
                        ->label('API Secret')
                        ->password()
                        ->extraAttributes(['encrypted' => true]), // Stored encrypted

                    Forms\Components\Select::make('environment')
                        ->label('Environment')
                        ->options([
                            'development' => 'Development',
                            'staging' => 'Staging',
                            'production' => 'Production',
                        ])
                        ->default('production'),
                ]),
        ];
    }

    public static function getStoreAppInfolistSchema(): array
    {
        return [
            Infolists\Components\Section::make('Custom Settings')
                ->schema([
                    Infolists\Components\TextEntry::make('custom_endpoint')
                        ->label('API Endpoint'),

                    Infolists\Components\TextEntry::make('api_secret')
                        ->label('API Secret')
                        ->formatStateUsing(fn ($state) => $state ? '••••••••' : 'Not set'),

                    Infolists\Components\TextEntry::make('environment')
                        ->label('Environment')
                        ->badge(),
                ]),
        ];
    }
}

Field Name Prefixing

All custom field names are automatically prefixed with app_config_ when stored to avoid collisions with built-in model fields. You should define fields without the prefix - it's added automatically.

For example, a field named ai_endpoint will be stored as app_config_ai_endpoint in PolydockVariables.

Encrypted Fields

Mark sensitive fields for encrypted storage by adding the encrypted extra attribute:

Forms\Components\TextInput::make('api_key')
    ->password()
    ->extraAttributes(['encrypted' => true])

The value will be encrypted before storage and automatically decrypted when retrieved.

Accessing Custom Field Values

Custom field values are stored as PolydockVariables and can be accessed from your app lifecycle methods:

// In your app lifecycle methods
public function preDeployAppInstance(PolydockAppInstanceInterface $appInstance): PolydockAppInstanceInterface
{
    // Get the Store App model and access custom field values (include the prefix)
    $endpoint = $storeApp->getPolydockVariableValue('app_config_custom_endpoint');
    $apiSecret = $storeApp->getPolydockVariableValue('app_config_api_secret'); // Auto-decrypted

    $this->info('Deploying to endpoint: ' . $endpoint);

    return $appInstance;
}

Supported Field Types

Any Filament form component can be used, including:

  • TextInput - Text, email, URL, password inputs
  • Textarea - Multi-line text
  • Select - Dropdown selections
  • Toggle - Boolean switches
  • Checkbox / CheckboxList - Checkbox inputs
  • Radio - Radio button groups
  • DatePicker / DateTimePicker - Date inputs
  • FileUpload - File uploads (stored as paths)
  • KeyValue - Key-value pair editors
  • Repeater - Repeatable field groups (stored as JSON)
  • Section / Grid / Fieldset - Layout components

Validation

Use standard Filament validation rules:

Forms\Components\TextInput::make('port')
    ->numeric()
    ->minValue(1)
    ->maxValue(65535)
    ->required(),

Forms\Components\TextInput::make('webhook_url')
    ->url()
    ->rules(['starts_with:https://']),

freedomtech-hosting/polydock-app 适用场景与选型建议

freedomtech-hosting/polydock-app 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.86k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 freedomtech-hosting/polydock-app 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 9
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-26