PHP code example of sidis405 / laravel-dynamic-servers-digital-ocean

1. Go to this page and download the library: Download sidis405/laravel-dynamic-servers-digital-ocean 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/ */

    

sidis405 / laravel-dynamic-servers-digital-ocean example snippets


return [
    'providers' => [
        ...

        'digital_ocean' => [
            'class' => Sidis405\LaravelDynamicServersDigitalOcean\DigitalOcean\DigitalOceanServerProvider::class,
            'maximum_servers_in_account' => 20,
            'options' => [
                'token' => env('DIGITAL_OCEAN_TOKEN'),
                'region' => env('DIGITAL_OCEAN_REGION'),
                'size' => env('DIGITAL_OCEAN_SIZE'),
                'image' => env('DIGITAL_OCEAN_IMAGE'),
                'vpc_uuid' => env('DIGITAL_OCEAN_VPC_UUID'),
            ],
        ],
    ]
];

public function register()
{
    ....

    $doServer = ServerType::new('do')
        ->provider('digital_ocean')
        ->configuration(function(Server $server) {
            return [
                'name' => Str::slug($server->name),

                "image" => $server->option('image'),
                "vpc_uuid" => $server->option('vpc_uuid'),
                "region" => $server->option('region'),
                "size" => $server->option('size'),

                "ipv6" => false,
                "backups" => false,
                "monitoring" => true,
            ];
        });

        DynamicServers::registerServerType($doServer);
}

protected $listen = [
        ServerRunningEvent::class => [
            UpdateServerMeta::class,
        ],
    ];
bash
php artisan dynamic-servers-digital-ocean:install