femtopixel / nano-framework
Nano Framework - easier than easiest framework
Requires
- php: ^8.0
Requires (Dev)
- phpmd/phpmd: ^2.4
- phpunit/phpunit: ^8.0
- squizlabs/php_codesniffer: ^3.0
README
Caution
As-of 2021, this product does not have a free support team anymore. If you want this product to be maintained, please support my work.
Note
(This product is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added.)
Nano Framework
Nano is a simple stupid framework, really easy to handle, and really efficient.
It only implements the C part (Controller) of the MVC design pattern which allows developers to use any other existing library for others parts
Installation
composer require femtopixel/nano-framework
Bootstrap
all your request can be redirected to your bootstrap (assuming index.php)
<?php require_once ('vendor/autoload.php'); $nano = new \Nano\Framework(); $nano->dispatch();
That's all!
How it works?
With that on, you can now access to your pages like this :
http://mysite.tld/ <controller>/<action>
And it will load the class \Project\Controller\<controller>::<method><action>Action
You can easily configure your namespace, controller package and action suffix!
<method> represents the HTTP method used (usually get but you can use post/update/delete etc...). This is optional.
Either <controller> or <action> are optional and considered as 'index' if not defined.
Therefore
Parameter Matching
Since 0.6.0, you can use "Parameter Matching"
Simply activate it when dispatching :
require_once ('vendor/autoload.php'); $nano = new \Nano\Framework(); $nano->setParameterMatching()->dispatch();
And then you'll be able to use it like this :
<?php namespace \Project\Controller; class MyAwesomeController { public function getHelloAction($age, $name) { echo "Hello $name, I'm {$age}yo"; //please, use this code for test only } }
and call http://mysite.tld/myawesomecontroller/hello?name=World&age=900
to display "Hello World, I'm 900yo" !