PHPackages                             vikkio88/nicu - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. vikkio88/nicu

ActiveProject

vikkio88/nicu
=============

v0.0.3(7y ago)112MITPHP

Since May 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/vikkio88/nicu)[ Packagist](https://packagist.org/packages/vikkio88/nicu)[ RSS](/packages/vikkio88-nicu/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

nicu
====

[](#nicu)

developing micro rest api in seconds, shared hosting friendly This is a simple startup project for a **nicu** restful api.

Create a project
================

[](#create-a-project)

```
composer create-project vikkio88/nicu NAME_OF_PROJECT

```

Run locally
-----------

[](#run-locally)

to run this app locally using the php server just type

```
php start.php

```

This will use the `router.php` to simulate a simple URLRewrite

To change the default port edit the `config/app.json`

```
{
  "app": {
    "version": 0.1,
    "port": 8088  '/NAME_OF_THE_ROUTE',
    'method' => 'get',
    'action' => AppSampleAction::class
]
```

There are three parameter to specify per each route:

1. **Route** The syntax for the routes is the one specified in [here](https://www.slimframework.com/docs/v3/objects/router.html).
2. **Method** This is the HTTP verb and can be any HTTP request type (options,post,get).
3. **Action** this is the Action that will be invoked when the route is matched, as long as it extends `ApiAction` and implements `action()` method returning an `array` it will work fine.

Add new / read Config from action
---------------------------------

[](#add-new--read-config-from-action)

Config lib is provided by [hassankhan/config](https://github.com/hassankhan/config), [here](https://github.com/hassankhan/config/tree/master/tests/mocks/pass) you can find some example of config files that are supported.

### Set

[](#set)

To add a config, add a file or a simple array key to the one specified:

```
'someStuff' => 'Stuff'
```

to get it

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

### Get

[](#get)

if **Config** will be injected in the constructor, you will have access to all the configs in the 'config/ folder'

```
class MyAction extends ApiAction {

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

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

Setup the Di Container
----------------------

[](#setup-the-di-container)

This small framework integrated [PhpDi](http://php-di.org) instead of Pimple, as autowiring makes everything a bit easier to read.

To link the interface to the implementation, you need to specify a provider into `config/providers`.

The provider body, will work a bit like the Laravel Providers, you will need to specify, using **php-di** syntax the bind between interface and implementation.

The **php-di** injection will autowire whatever is configured in those providers, and will inject the implementation on whatever you are creating injecting it into the Action constructor.

### Example

[](#example)

`config/providers.php`

```
return [
    'providers' => [
        SampleProvider::class
    ]
];

```

`SampleProvider.php`

```
class SampleProvider extends Provider
{

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

Middlewares
-----------

[](#middlewares)

Slim (so PSR) Middlewares are supported by **nicu**. To find out more read [this](https://www.slimframework.com/docs/v3/concepts/middleware.html).

To add a new one you need to specify it into the file `config/app.php` under the config key `app.middlewares`:

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

As ↑ shows, the config can be provided in two ways, either as a Middleware class, specifying a config as value in the array (config being an `array` too), or as a simple `\Callable`.

DotEnv
------

[](#dotenv)

You can specify a config as environment variable in a .env file.

```
SOME_STUFF="I like trains"

```

those will be loaded on the `index.php` on the bootstrap phase.

And you can inject it into a config like this.

```
'stuff' => getenv('SOME_STUFF')
```

For more info about this check out [vlucas/phpdotenv](https://github.com/vlucas/phpdotenv) docs.

Build
-----

[](#build)

This framework allows you to create a build version of your rest api, and it will cleanup the vendor folder in order to have less file to upload.

To run the build just type

```
composer run build

```

This will create a cleaned up/production ready version of the app in the subfolder `./dist/` ready to be uploaded to your Apache or Nginx server.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

2561d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b2ad137676a697a1f32c643900a319716944fa16b936026d22ef25e5ac10e22?d=identicon)[vikkio88](/maintainers/vikkio88)

### Embed Badge

![Health badge](/badges/vikkio88-nicu/health.svg)

```
[![Health](https://phpackages.com/badges/vikkio88-nicu/health.svg)](https://phpackages.com/packages/vikkio88-nicu)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
