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\SDK\SDK;
use Appwrite\SDK\Language\PHP;
use Utopia\OpenAPI\Parser;

// Parse an OpenAPI 2, 3.0, or 3.1 document into the canonical specification model.
// One document covers every SDK platform; the SDK selects its own below.
$version = '2.0.x';
$platform = 'server';
$content = file_get_contents("https://raw.githubusercontent.com/appwrite/specs/main/specs/{$version}/open-api3-{$version}.json");
$spec = Parser::parse($content);

// 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
    ->setPlatform($platform) // Keep the operations, aliases and security schemes available to this platform
    ->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




ppwrite\SDK\SDK;
use Appwrite\SDK\Language\Skills;
use Utopia\OpenAPI\Parser;

$spec = Parser::parse([
    'openapi' => '3.0.0',
    'info' => [
        'title' => 'Appwrite',
        'description' => 'Appwrite backend as a service',
        'version' => '2.0.x',
        'license' => [
            'name' => 'BSD-3-Clause',
            'url' => 'https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE',
        ],
    ],
    'paths' => [],
]);

$sdk = new SDK(new Skills(), $spec);

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

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