Download the PHP package nervsys/ns without Composer
On this page you can find all versions of the php package nervsys/ns. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ns
Nervsys
README: 简体中文
About Nervsys
-
What is "Nervsys"?
A very slight PHP framework, very easy to use and integrate. -
Why called "Nervsys"?
At the very beginning, as we hoped. The unit could process more like a nerve cell, and build together as a pure data-based calling system. Exact commands would be unnecessary to tell the system what to do. -
Any short name?
NS, that's what most of us call it, but, don't mix it up with Nintendo Switch. -
Requirements:
PHP 8.1+ and above. Any kind of web server or running under CLI mode. - Usage example:
- Ordinary framework for Web-backend-developing
- API controller for all types of Apps
- Client for program communication
- More...
Installation
- Clone or download source code to anywhere on your machine. Only one copy is required on the same machine even multiple projects exist.
- Include "NS.php" in the main entry script of the project, and call it with using "NS::new();".
- If needed, using "trait System" to register your own modules and functions before calling "NS::new();".
- Write your API code classes under "/api", application code classes under "/app", if not changed, and there you go.
- In "/Ext", there are common useful extensions for normal project development, so, please do review them when coding. They can be helpful.
Usage
All demo usage is under default system settings.
1. Suggested project structure
Notice: App root path will be set to the parent directory of the entry php script.
2. NS integration
Follow "Installation" steps to integrate NS into your entry script. Demo code is as follows.
3. Request data format
NS can parse data from both FormData and request Payload via GET or POST.
When data is sending as request Payload, both JSON and XML are supported.
Data fetcher and parser library in NS is "/Core/Lib/IOUnit.php".
In HTTP request, NS fetch and parse data in the following steps:
In CLI mode, NS takes "c" from "-c" parameter, or the first argument if not found. String parameter "-d" will be taken to decode to get CGI data source. "-r" forces output returned data format. Other arguments will be considered as CLI argv.
4. About key "c"
"c" in request data will be taken as request command, and will lead system to go continue.
"c" can be passed in any ways, URL, GET, POST, all is OK, no matter FormData or request Payload.
In CGI mode, normally known as HTTP request, "c" is always redirected to api path for some security reasons, but, CLI mode allows calling from root by adding "/" in the beginning of "c" using full class namespace path.
Valid "c" format should be as follows:
5. Data autofill
Once "c" and data source are taken by system, Router library and Execute library will be woken up to run exact method. Key matched parameters will be taken out of data source, and pass in the right order automatically into target method when calling. Watch out of all data passed to NS, keys are case-sensitive, and data values are type-strict. All returned results will be captured and output.
example:
-
API 1
- API 2
6. Exposed Core libraries
NS leaves some important core libraries exposed to developers since 8.0 and on.
Thanks to douglas99, all changeable core related APIs are merged into "
Ext/libCoreApi.php".
With this, developers can register own libraries instead of default ones, such as custom Router, outputHandler, ApiPath,
hook related functions, etc...
Todo
- [x] Basic Core and Ext logic
- [x] Automatic argument mapping
- [x] App code env detection logic
- [x] Custom router module support
- [x] Custom error handler module support
- [x] Custom data reader/output module support
- [x] Path based hook registration function support
- [x] Put main system controlling functions in trait for easily use
- [x] Process controller manager support
- [x] Simple Fiber manager support
- [x] Socket related functions
- [x] Some useful algorithms
- [ ] ML/AI based internal router
- [ ] More detailed documents and demos
Except functions listed above, NS still has a long way to go.
Thanks for issues & pull requests if you found bugs or make it better, or just need help. Contact us.
Supporters
Thanks to JetBrains for supporting the project, within the Open Source Support Program.
License
This software is licensed under the terms of the Apache 2.0 License.
You can find a copy of the license in the LICENSE.md
file.
All versions of ns with dependencies
ext-curl Version *
ext-fileinfo Version *
ext-gd Version *
ext-gettext Version *
ext-libxml Version *
ext-json Version *
ext-openssl Version *
ext-pdo Version *
ext-redis Version *
ext-simplexml Version *
ext-mbstring Version *