PHP code example of dunglas / digital-ocean-bundle
1. Go to this page and download the library: Download dunglas/digital-ocean-bundle 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/ */
dunglas / digital-ocean-bundle example snippets
// src/Controller/DigitalOceanController.php
namespace App\Controller;
use DigitalOceanV2\Client;
use DigitalOceanV2\ResultPager;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class ProductController
{
#[Route("/droplets")]
public function listDroplets(Client $doClient): Response
{
// get the first 100 droplets as an array
$droplets = $doClient->droplet()->getAll();
// or create a new result pager
$pager = new ResultPager($doClient);
// and get all droplets as an array
$droplets = $pager->fetchAll($doClient->droplet(), 'getAll');
// ...
}
}
// config/bundles.php
return [
// ...
\Dunglas\DigitalOceanBundle\DunglasDigitalOceanBundle::class => ['all' => true],
];