PHP code example of kleijnweb / php-api-descriptions
1. Go to this page and download the library: Download kleijnweb/php-api-descriptions 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/ */
$validator = new MessageValidator(
(new Repository())
->setFactory(new DescriptionFactory(DescriptionFactory::BUILDER_RAML))
->get('tests/definitions/raml/mobile-order-api/api.raml')
);
// $input is deserialized and validated using $inputSchema
$builder = new ProcessorBuilder(new ClassNameResolver(['Some\Namespace']));
$processor = $builder->build($schema);
$hydrated = $processor->hydrate($input, $inputSchema);
// Perform business logic, creating $appOutput
$output = $processor->dehydrate($appOutput, $outputSchema);
// Validate output using $outputSchema
$builder = new ProcessorBuilder($classNameResolver, new DateTimeSerializer(\DateTime::RFC850));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.