PHP code example of shawnhooper / outdated-to-jira
1. Go to this page and download the library: Download shawnhooper/outdated-to-jira 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/ */
shawnhooper / outdated-to-jira example snippets
pp\Service\DependencyCheckerService;
use Monolog\Logger; // Or your preferred PSR-3 Logger
use Monolog\Handler\StreamHandler;
// 1. Configure JIRA details (load from .env, config files, etc.)
$jiraConfig = [
'jira_url' => 'https://your-domain.atlassian.net',
'jira_user_email' => '[email protected]',
'jira_api_token' => getenv('JIRA_API_TOKEN'), // Get token securely!
'jira_project_key' => 'YOUR_PROJECT_KEY',
'jira_issue_type' => 'Task',
'dry_run' => false, // Set to true to simulate
];
// 2. Create a PSR-3 Logger instance
$logger = new Logger('MyApplication');
$logger->pushHandler(new StreamHandler('php://stdout', Logger::INFO));
// 3. Instantiate the service
$checkerService = new DependencyCheckerService($jiraConfig, $logger);
// 4. Define the path to your dependency file and optional filters
$dependencyFilePath = __DIR__ . '/path/to/your/composer.json'; // Or package.json
$packagesToFilter = ['some/package', 'another/vendor']; // Optional
// 5. Process the dependencies
try {
$results = $checkerService->process($dependencyFilePath, $packagesToFilter);
$logger->info("Processing Results:", $results);
// Example: Check status for a specific package
if (isset($results['some/package'])) {
$status = $results['some/package'][DependencyCheckerService::RESULT_STATUS_KEY];
$jiraKey = $results['some/package'][DependencyCheckerService::RESULT_JIRA_KEY];
$logger->info("Status for some/package: {$status}" . ($jiraKey ? " ({$jiraKey})" : ''));
}
} catch (\InvalidArgumentException $e) {
$logger->error("Configuration or file path error: " . $e->getMessage());
} catch (\RuntimeException $e) {
$logger->error("Processing error: " . $e->getMessage());
} catch (\Exception $e) {
$logger->error("An unexpected error occurred: " . $e->getMessage());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.