PHP code example of alsalty / argocd-sdk

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

    

alsalty / argocd-sdk example snippets




use Alsalty\Argocd\Core\Auth;
use Alsalty\Argocd\Core\Managers\ApplicationsManager;

try {
    // Set your Argo CD API credentials
    $apiUrl = 'https://your-argocd-api-url';
    $username = 'your-username';
    $password = 'your-password';

    // Create an Auth instance and authenticate
    $auth = new Auth($apiUrl, $username, $password);
    $auth->authenticate();

    // Create an ApplicationsManager instance
    $appManager = new ApplicationsManager($auth);

    // Set projects and namespace filters
    $appManager->setProjects(['project1', 'project2']);
    $appManager->setAppNamespace('namespace1');

    // Fetch and print application names
    $applicationNames = $appManager->getApplicationsNames();
    print_r($applicationNames);

} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}

$appManager->setProjects(['project1', 'project2']);
$appManager->setAppNamespace('namespace1');