PHP code example of criztianix / php-spore2

1. Go to this page and download the library: Download criztianix/php-spore2 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/ */

    

criztianix / php-spore2 example snippets



use PHP_Spore\Spore;

$spore = Spore::newFromArray([
   "base_url" => "https://httpbin.org",
   "methods" => [
       "get" => [
           "path" => "/get",
           "method" => "GET"
       ],
       "query_params" => [
           "path" => "/response-headers",
           "method" => "GET",
           "params" => [
               "limit" => [ "

$spore = Spore::newFromJson(__DIR__ . "spec.json");

$response = $spore->post([
    "params" => [
        "limit" => 10,
        "page" => 1
    ],
    "form-data" => [
        "data" => [
            1,2,3
        ]
    ]
]);

$spec = [ 
  "base_url" => "https://httpbin.org",
  "methods" => [
    "getCache" => [
      "path" => "/cache",
      "model" => "PHP_Spore\\Test\\Response\\Cache"
    ]
  ]
]


namespace PHP_Spore\Test\Response;

use \PHP_Spore\Spore_Property;
class Cache
{
    public $url;
    /**
     * @Spore_Property(class = "PHP_Spore\Test\Response\Headers")
     */
    public $headers;
}

class Headers
{
    public $Host;
}