PHP code example of appwrite / sdk-generator

1. Go to this page and download the library: Download appwrite/sdk-generator 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/ */

    

appwrite / sdk-generator example snippets




ppwrite\Spec\Swagger2;
use Appwrite\SDK\SDK;
use Appwrite\SDK\Language\PHP;

// Read API specification file (Swagger 2) and create spec instance
$version = '1.9.x';
$platform = 'server';
$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
    ->setLogo('https://appwrite.io/v1/images/console.png')
    ->setLicenseContent('License content here.')
    ->setVersion('v1.1.0')
;

$sdk->generate(__DIR__ . '/examples/php'); // Generate source code




ppwrite\Spec\StaticSpec;
use Appwrite\SDK\SDK;
use Appwrite\SDK\Language\AgentSkills;

$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 AgentSkills(), $spec);

$sdk
    ->setName('Appwrite')
    ->setVersion('1.9.x')
;

$sdk->generate(__DIR__ . '/examples/agent-skills');
bash
composer lint-twig  # Check for linting errors
bash
php example.php
php example.php <target>
php example.php <target> <platform>
bash
php example.php web client
php example.php node server
php example.php cli console
php example.php agent-skills