How to use MC in PhalconMicro applications

Source: Internet
Author: User
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,

getAccess/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,

getAccess/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 ";});
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.