PHP code example of freedomtech-hosting / polydock-app
1. Go to this page and download the library: Download freedomtech-hosting/polydock-app library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
freedomtech-hosting / polydock-app example snippets
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-
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()
-> {
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(),
]),
];
}
}
// In your app lifecycle methods
public function preDeployAppInstance(PolydockAppInstanceInterface $appInstance): PolydockAppInstanceInterface
{
// Get the Store App model and access custom field values ( to endpoint: ' . $endpoint);
return $appInstance;
}