The following simple example {code...} is provided in the official document ...} it is obviously impossible to write all the processing code in fcunction. when get accesses saygetwelcome {name} and wants to let it instance a controller, how can we provide the following simple example in the official document?
use Phalcon\Mvc\Micro;$app = new Micro();$app->get('/say/welcome/{name}', function ($name) { //do something});$app->handle();
It is obviously impossible to write all the processing code in fcunction,
get
Access/say/getwelcome/{name}
How to make it an instance controller?
Reply content:
The following simple example is provided in the official document:
use Phalcon\Mvc\Micro;$app = new Micro();$app->get('/say/welcome/{name}', function ($name) { //do something});$app->handle();
It is obviously impossible to write all the processing code in fcunction,
get
Access/say/getwelcome/{name}
How to make it an instance controller?
Thanks for the invitation. I did not use this framework. I searched for it and asked this person to read the document carefully. See// Methods in the object
.
Get ('/say/hello/{name}', "say_hello"); // static method $ app-> get ('/say/hello/{name }', "SomeClass: someSayMethod"); // method in the object $ myController = new MyController (); $ app-> get ('/say/hello/{name }', array ($ myController, "someAction"); // Anonymous functions $ app-> get ('/say/hello/{name}', function ($ name) {echo "Hello! $ Name ";});