PHP code example of ninjaphp / ninja

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

    

ninjaphp / ninja example snippets

 php

use \Ninja\Ninja;

Ninja::addHazard(
    'throttle',
    Ninja::HAZARD_TYPE_THROTTLE,
    function (\Symfony\Component\HttpFoundation\Request $request) {
        return true;
    },
    array(
        'bucket_size' => 10,
        'bucket_leak' => 1
    )
);
 php

use Ninja\Ninja;

// ...
Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();

// Send the Ninjas
Ninja::prepare(__DIR__ . '/../app/config/ninja.php', $request);
Ninja::protect();

$response = $kernel->handle($request);

// Inject the Ninja in the response
Ninja::inject($response);

$response->send();
$kernel->terminate($request, $response);