PHP code example of hskrasek / arazzo-parser

1. Go to this page and download the library: Download hskrasek/arazzo-parser 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/ */

    

hskrasek / arazzo-parser example snippets


use HSkrasek\Arazzo\Parser;

$specification = Parser::parse(
    file_get_contents('https://raw.githubusercontent.com/bump-sh-examples/train-travel-api/a97f549346f8cb44ec8d5e9d08cfe57b8b09cd6e/arazzo.yaml')
);

var_dump($specification);

//object(HSkrasek\Arazzo\Specification\Arazzo)#636 (5) {
//  ["arazzo"]=>
//  enum(HSkrasek\Arazzo\Specification\Version::V1_0_1)
//  ["info"]=>
//  object(HSkrasek\Arazzo\Specification\Info)#736 (4) {
//    ["title"]=>
//    string(30) "BNPL Loan Application Workflow"
//    ["version"]=>
//    string(5) "1.0.0"
//    ["summary"]=>
//    NULL
//    ["description"]=>
//    string(354) "This workflow walks through the steps to apply for a BNPL loan at checkout, including checking product eligibility, retrieving terms and conditions, creating a customer record, initiating the loan transaction, customer authentication, and retrieving the finalized payment plan. It concludes by updating the order status once the transaction is complete."
//  ...
//  }

use HSkrasek\Arazzo\Parser;

// Parse an Arazzo specification string
$specification = Parser::parse(
    file_get_contents('https://raw.githubusercontent.com/bump-sh-examples/train-travel-api/a97f549346f8cb44ec8d5e9d08cfe57b8b09cd6e/arazzo.yaml')
);
// or parse an Arazzo specification from a file
$specification = Parser::parse(new SplFileObject(__DIR__ . '/arazzo.yaml'));

// or parse an Arazzo specification from a resource handler

$specification = Parser::parse(fopen(__DIR__ . '/arazzo.yaml'));