PHPackages                             pier-infor/nymfonya - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. pier-infor/nymfonya

ActiveProject[HTTP &amp; Networking](/categories/http)

pier-infor/nymfonya
===================

Nymfonya Rest App

1.0.6(5y ago)12[1 PRs](https://github.com/pierre-fromager/nymfonya/pulls)LGPL-3.0-or-laterPHPPHP &gt;=7.3.10

Since Nov 22Pushed 3y ago2 watchersCompare

[ Source](https://github.com/pierre-fromager/nymfonya)[ Packagist](https://packagist.org/packages/pier-infor/nymfonya)[ Docs](https://github.com/pierre-fromager/nymfonya)[ RSS](/packages/pier-infor-nymfonya/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (16)Versions (8)Used By (0)

🐘 Nymfonya
==========

[](#elephant-nymfonya)

is not a Symfony app...¯\\*(ツ)*/¯

[![TravsisBadgeBuild](https://camo.githubusercontent.com/22b53ce503c2ef66b16d66a44a9e2c541d8fe6497782ca2a773d449681be8e9a/68747470733a2f2f6170692e7472617669732d63692e636f6d2f7069657272652d66726f6d616765722f6e796d666f6e79612e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/pierre-fromager/nymfonya)[![CoverageCi](https://camo.githubusercontent.com/5b5586ca9aea451cecc2d510ca50530eba9fe3f8171fdd17fc15902e68b6c9ee/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7069657272652d66726f6d616765722f6e796d666f6e79612f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/pierre-fromager/nymfonya/)[![ScrutinizerCq](https://camo.githubusercontent.com/9d27c85fca0deeef17016a7b47f593b79f4a9deab37b631f19e8fd66e661c2a2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7069657272652d66726f6d616765722f6e796d666f6e79612f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/pierre-fromager/nymfonya/)[![Latest Stable Version](https://camo.githubusercontent.com/9c75db2405adc7a6f4a41494d059249ca55e2ea9c1ee3002d1cbbe86eaa8445a/68747470733a2f2f706f7365722e707567782e6f72672f706965722d696e666f722f6e796d666f6e79612f762f737461626c65)](https://packagist.org/packages/pier-infor/nymfonya)[![Total Downloads](https://camo.githubusercontent.com/282475588b409f0051163744dcbb0d92d43eb26834172e3363bd714bad695f17/68747470733a2f2f706f7365722e707567782e6f72672f706965722d696e666f722f6e796d666f6e79612f646f776e6c6f616473)](https://packagist.org/packages/pier-infor/nymfonya)[![Latest Unstable Version](https://camo.githubusercontent.com/80e55c3e76ade41c9d1b5c1f52543b1cf3c88e1e879e11bd41dee8f4aff1f1a9/68747470733a2f2f706f7365722e707567782e6f72672f706965722d696e666f722f6e796d666f6e79612f762f756e737461626c65)](https://packagist.org/packages/pier-infor/nymfonya)

[![logo](assets/img/nymfonya-logo.png)](assets/img/nymfonya-logo.png)

ʕʘ̅͜ʘ̅ʔ Why
-----------

[](#ʕʘ̅͜ʘ̅ʔ-why)

I want :

- Play rest only.
- Slim conf.
- Console features.
- Low memory footprint.
- Minimize load files (max 150) for any final purpose.
- Response time always lower than 10ms.
- All testable.
- Packageable.
- CI compliant.

👀 Introduction
--------------

[](#eyes-introduction)

Involved into backend projects based on Symfony or Laravel with Angular as front, I was frustrated about performances. I turned to micro frameworks like Silex, Slim...to improve more. A lot of them have been abandonned in favor of majors actors. I can't figure why, maybe a lake of maintainers or people prefered something more generalistic and large feature oriented.

Composer package manager, introduced in 2011 changed the way to design php app with the concept of package and dependencie. Autoloading RFCs as PSR-0 then PSR-4 were introduced a bit later aligning packages with namespace as vendor/feature.
Php is still interpreted and requires sources to be loaded, parsed(AST), assembled(as opcode) then executed in Zend VM @ request time. Some companies tried to compile source with JIT to speed up these steps (HipHop, HHVM) but did not ensure compatibility with the native source... 😞 !

😿 Situation
-----------

[](#crying_cat_face-situation)

To speed up packages's dependencies Composer introduced optimization options to build a 'resource catalog' by namespace. To speed up the interpretation process php introduced Opcache as opcode cache but first run is still slower. Despite all these benefits, some frameworks require around 3K files to boot, multiplying I/O on storage device and wasting memory.
This is frustrating 😡 !
We can do better, don't we ?

🌊 Best practices
----------------

[](#ocean-best-practices)

- Instanciate objects once.
- Inject container everywhere.
- Type hinting usage when we can (better with php =&gt; 7.3).
- Avoid slow processes as Reflection when we can.
- Prohibit functional annotations.
- Log everything (Monolog) by env even errors.
- Responds minimal error structure with error code and message even no error.
- No magic methods.
- No globals nor define.
- Avoid static.
- Declare class constant in Interfaces.

🐴 Arch
------

[](#horse-arch)

- 😎 rest App.
- 🐠 Extra packages as features (unsupported).
- 🍺 I would say Mvc but I love to forget about controllers and use Closure instead.
- 🌀 Configs in config/$env.
- 🐚 Run with php &gt;= 7.0.

### Config

[](#config)

- 🐟 [nymfonya-config](https://github.com/pierre-fromager/nymfonya-config) external package dependencie (supported).
- Config manager.
- Keep config as associative arrays.
- Isolate by Env.
- Testable : check autoload-dev psr-4 for namespace.

### Container

[](#container)

- 🐟 [nymfonya-container](https://github.com/pierre-fromager/nymfonya-container) external package dependencie (supported).
- not PSR-11.
- Instanciate classes with injected params.
- Roll-in precedence order.
- Container config is associative array (classname =&gt; params).
- Testable : check autoload-dev psr-4 for namespace.

### Kernel &amp; Http Foundation

[](#kernel--http-foundation)

- 🐟 [nymfonya-http-foundation](https://github.com/pierre-fromager/nymfonya-http-foundation) external package (supported).
- Load Config.
- Run Kernel in server and cli mode.
- Instanciate services from container.
- Setup middlewares in design order (before/core/after).
- Run middleware sequence when routes match.
- Execute controler action as middleware core Closure.
- Testable : check autoload-dev psr-4 for namespace.

### Services

[](#services)

- Config
- Logger (Monolog)
- Request (not PSR-7 yet)
- Routes
- Router
- Controller
- Response (nor PSR-7 yet)

### Rules

[](#rules)

- Request is 'Immutable'.
- Container services can be modified.
- Container injects Peel method middleware as first param.
- Container injects Constructor controller method as first param.
- Response modified at any time both by middlewares and controllers.

### Middlewares

[](#middlewares)

Middleware stack must contain at least one.

- Cors : play with cross domain request (\\ö/ Angular OPTIONS preflight).
- Jwt : deal with auth based on Jwt Token.
- After : terminator to ensure middleware logic is fully functional.

💥 Usage
-------

[](#boom-usage)

### Server

[](#server)

#### Start

[](#start)

From root path

```
composer run start
```

#### Play

[](#play)

Postman recommended.

##### Middleware Jwt

[](#middleware-jwt)

```
#!/bin/bash
curl -v \
	--request POST \
	--url http://localhost:8888/api/v1/auth/login \
	--header 'Cache-Control: no-cache' \
	--header 'Connection: keep-alive' \
	--header 'Content-Type: application/json' \
	--header 'Host: localhost:8888' \
	--header 'cache-control: no-cache' \
	--data '{"login": "admin@domain.tld","password": "adminadmin"}'
```

Free access

-
-
-

Bearer Token required

-
-
-

##### Middleware Restufl

[](#middleware-restufl)

-

##### Middleware Cors &amp; After

[](#middleware-cors--after)

Enabled for all endpoints.

### Cli

[](#cli)

Ideal for batch mode, cron stuffs. From the root of the project. This does not require any server to be running. Middleware Jwt is disable.
Use [jq](https://stedolan.github.io/jq/) to pretty or filter json in console.

#### Sample Auth

[](#sample-auth)

```
php src/index.php '/api/v1/auth/login?login=admin@domain.tld&password=adminadmin' | jq
```

#### Sample Stat Opcache

[](#sample-stat-opcache)

```
php src/index.php '/api/v1/stat/opcache' | jq
```

#### Sample OpenApi Generator

[](#sample-openapi-generator)

```
php src/index.php '/config/swaggerdoc'
```

🌟 Code
------

[](#star2-code)

### Catalog

[](#catalog)

```
find ./src -name *.php | grep -E -v 'vendor|config|test' | wc -l
```

### Complexity

[](#complexity)

- run phploc

```
composer run cq
```

### Mess

[](#mess)

- run phpmd (mess detector)

```
composer run md
```

😇 Tests
-------

[](#innocent-tests)

Run phpunit all tests.

```
composer run test
```

To get the code coverage the command below then browse coverage/index.html file.

To run xdebug driver (xdebug required), considered as fat and buggy.

```
composer run cov
```

To run phpdbg driver (phpdbg required), faster and precise.

```
composer run covdbg
```

You can also use a very fast driver [PCOV](https://github.com/krakjoe/pcov).
Check S.Bergmann [travis config](https://github.com/sebastianbergmann/php-code-coverage/blob/master/.travis.yml).

🔥 Security
----------

[](#fire-security)

Develop app is dev job, secure it is one other.

### Dev side

[](#dev-side)

Use filters and validators everywhere and never trust input params.

- [Filters type](https://www.php.net/manual/fr/filter.filters.php), [filter\_input](https://www.php.net/manual/fr/function.filter-input.php). , [filter\_input\_array](https://www.php.net/manual/fr/function.filter-input-array.php). , [filter\_var\_array](https://www.php.net/manual/fr/function.filter-var-array.php).

### Devops side

[](#devops-side)

Devops/SysAdmins should propose/setup solutions.

- Prefer php-fpm to modules for flexibility.
- Prefer Nginx to Apache for performance and http/2.
- Do not use php server in prod (single threaded).
- For static content setup varnish.

I would recommend third part services if exposed as below :

- apache(2) mod\_security(2) to let OWASP breaks and logs most common attacks.
- Nginx ModSecurity.
- fail2ban in conjonction with mod\_security(2) or ModSecurity to ban recurent attackers.

This should stop most common attacks but do not exempt your app to be bullet proofed.

Check your app logs with [Tail for Monolog](https://bytefreaks.net/gnulinux/bash/tail-logs-with-color-for-monolog) make logs reading easier.

Change some settings in php.ini

- Read [Linux 25 PHP Security Best Practices For Sys Admins](https://www.cyberciti.biz/tips/php-security-best-practices-tutorial.html)

🐹 Todo
------

[](#hamster-todo)

### Core

[](#core)

- Refacto Request to use behind a proxy.
- Console tool.
- More middlewares before Acl, Waf, after Transfos...
- Implement Controller forward method.
- Implement Response redirect 30X.

### Extra packages

[](#extra-packages)

- Model with doctrine, mongodb, elasticsearch.
- Mail with swiftmailer.

🐔 Naming convention
-------------------

[](#chicken-naming-convention)

- (I)nterface.
- (T)rait.

Controller action must be declared as final public.

👅 Conclusion
------------

[](#tongue-conclusion)

I'm aware it requires improvements on many points and I'm sorry to break most PSR.(⌐■\_■)
Performance rocks (response 15ms for a 40X at first run, then 6ms).

I attempted to keep the code :

- short.
- readable and annotated.
- testable (Wip 93% methods coverage).
- explicit.
- decoupled.
- linted.
- type hinted (insofar as php v7.X compatibility).

Can't wait trying Php v8.0 [JIT](https://wiki.php.net/rfc/jit) with [DynAsm](https://luajit.org/dynasm.html).
It should perf x4 face to v7.4 and generate native code (VM + AOT).
You can try JIT from Php v7.4 as experimental feature (compile time) !
Star and or fork then PR to improve it.
Test it and be happy or not ¯\\*(ツ)*/¯

🐼 Extras
--------

[](#panda_face-extras)

- Markdown [Emoji](https://gist.github.com/rxaviers/7360908).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% of commits — single point of failure

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 ~101 days

Total

5

Last Release

1959d ago

PHP version history (2 changes)1.0.2PHP &gt;=7.0.0

1.0.6PHP &gt;=7.3.10

### Community

Maintainers

![](https://www.gravatar.com/avatar/f8cb8f7bafca38b4daa3da1d8414e3becf5f5b6119ec0d0343f4e56cc3bb3943?d=identicon)[pierre-fromager](/maintainers/pierre-fromager)

---

Top Contributors

[![pierre-fromager](https://avatars.githubusercontent.com/u/607663?v=4)](https://github.com/pierre-fromager "pierre-fromager (3 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")

---

Tags

restbackendNymfonya App

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/pier-infor-nymfonya/health.svg)

```
[![Health](https://phpackages.com/badges/pier-infor-nymfonya/health.svg)](https://phpackages.com/packages/pier-infor-nymfonya)
```

###  Alternatives

[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[lesstif/php-jira-rest-client

JIRA REST API Client for PHP Users.

5219.2M25](/packages/lesstif-php-jira-rest-client)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.3M14](/packages/xeroapi-xero-php-oauth2)[vgrem/php-spo

PHP Office 365 library. It allows to performs CRUD operations against Office 365 resources via an REST/OData based API

3741.4M5](/packages/vgrem-php-spo)

PHPackages © 2026

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