PHP code example of vikkio88 / nicu

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

    

vikkio88 / nicu example snippets


[
    'route' => '/NAME_OF_THE_ROUTE',
    'method' => 'get',
    'action' => AppSampleAction::class
]

'someStuff' => 'Stuff'

// $config being an instance of Config
$config->get('someStuff', 'fallback value');

class MyAction extends ApiAction {

    public function __construct(Config $config)
    {
        $this->config = $config;
    }

    protected function action(): array
    {
        return [
            'test' => $this->config->get('stuff')
        ];
    }
}

class SampleProvider extends Provider
{

    public function boot()
    {
        $this->bind(Interface::class, function(ContainerInterface $c){
            return new Implementation($c->get(AnotherInterface::class));
        });
    }
}

'middlewares' => [
    Cors::class => [
        "origin" => ["*"],
        "methods" => ["GET", "POST", "PUT", "PATCH", "DELETE"],
    ],
    function(RequestInterface $request, ResponseInterface $response,closure $next){
        // do something
        $next($request,$response);
        return $response;
    }
]

'stuff' => getenv('SOME_STUFF')

php start.php
router.php

php start.php 8090