定制 abdullahfaqeir/laravel-dynamic-servers-vultr 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

abdullahfaqeir/laravel-dynamic-servers-vultr

最新稳定版本:1.0.0

Composer 安装命令:

composer require abdullahfaqeir/laravel-dynamic-servers-vultr

包简介

Vultr provider for Spatie's Laravel Dynamic Servers package

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a Server Provider for Spatie's Laravel Dynamic Servers Package.

Installation

You can install the package via composer:

composer require abdullahfaqeir/laravel-dynamic-servers-vultr

Afterward make sure to publish the EventServiceProvider that comes with this package:

php artisan dynamic-servers-vultr:install

Usage

In your config/dynamic-servers.php register the Vulter provider

return [
    'providers' => [
        'vultr' => [
            'class' => AbdullahFaqeir\LaravelDynamicServersVultr\Vultr\VultrServerProvider::class,
            'maximum_servers_in_account' => 15,
            'options' => [
                'token' => env('VULTR_TOKEN'),
                'region' => env('VULTR_REGION'),
            ],
        ],
    ],
];

In your app/Providers/DynamicServersProvider.php register a new server type using the Vultr provider

public function register()
{
    ....
    
    
    $vultrServer = ServerType::new('small')
        ->provider('vultr')
        ->configuration(function (Server $server) {
            return [
                'label' => Str::slug($server->name),
                "region" => $server->option('region'),
                'plan' => 'vc2-1c-1gb',
                "vpc_uuid" => '62420e18-5628-4f6c-9ee4-aca48a5a7c17',
                'os_id' => 1743,
                'enable_ipv6' => true,
                'backups' => 'disabled',
                'tags' => [
                    'tag1',
                    'tag2'
                ]
            ];
        });

    DynamicServers::registerServerType($vultrServer);
}

Events

After the base package's CreateServerJob is executed, a new job, VerifyServerStartedJob will be dispatched and will check every 20 seconds to make sure that the provider eventually marks the Instance as running.

After it ensures it runs, no other attempt is made to fetch again the server meta.

Considering that Vultr will return the ip address of a instance only after it has been full created we need to fetch once more the instance meta.

For this, we will use the base package's event 'ServerRunningEvent'.

This package, publishes a App\Providers\VultrEventServiceProvider in your project.

By default there is a single listener, configured and it will fetch again the Instance's meta after the base package has ensured that it is running.

protected $listen = [
        ServerRunningEvent::class => [
            UpdateServerMeta::class,
        ],
    ];

You may customise the listener, disable it or replace it with a your own.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固