PHP code example of archee-nic / decl-api

1. Go to this page and download the library: Download archee-nic/decl-api 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/ */

    

archee-nic / decl-api example snippets


     namespace App\Api;

    use DeclApi\Core\Request;

    class ExampleRequest extends Request
    {
    }
    

    /**
     * @throws \Exception
     */
    protected function initRules()
    {
        parent::initRules();
        $this->rulesInfo()->add('parameter','integer','example','Пример поля','Пример описания поля')->setDefault(10)->setAttributes('

 namespace App\Api;

use DeclApi\Core\ObjectClass;

class ExampleResponse extends ObjectClass
{
}

    /**
     * @throws \Exception
     */
    protected function initRules()
    {
        parent::initRules();
        $this->rulesInfo()->add('integer','example','Пример параметра','Описание параметра');
    }
 

 namespace App\Http\Api;

use DeclApi\Core\PointL5Bridge;

class ExamplePoint extends Laravel5Point
{

}

    /**
     * @param ExampleRequest $request
     *
     * @return ExampleResponse
     * @throws \Exception
     */
    public function handler(ExampleRequest $request): ExampleResponse
    {
        $data = new ExampleResponse();
        return $data;
    }

Route::get('/example','Api\ExamplePoint');