How to use MC in Phalcon micro applications

Source: Internet
Author: User
In the official documentation, here's a simple example

use Phalcon\Mvc\Micro;$app = new Micro();$app->get('/say/welcome/{name}', function ($name) {    //do something});$app->handle();

All the processing code is written fcunction inside, apparently impossible,

get/say/getwelcome/{name}when accessing, want to let it instance a controller, how to do

Reply content:

In the official documentation, here's a simple example

use Phalcon\Mvc\Micro;$app = new Micro();$app->get('/say/welcome/{name}', function ($name) {    //do something});$app->handle();

All the processing code is written fcunction inside, apparently impossible,

get/say/getwelcome/{name}when accessing, want to let it instance a controller, how to do

Thank you for the invitation, did not use this framework, specifically search for a bit, and then can only say please this pro carefully complete read the document. Please see //对象内的方法 section.


  
   Hello! $name";}$app->get('/say/hello/{name}', "say_hello");//  静态方法$app->get('/say/hello/{name}', "SomeClass::someSayMethod");//  对象内的方法$myController = new MyController();$app->get('/say/hello/{name}', array($myController, "someAction"));// 匿名函数$app->get('/say/hello/{name}', function ($name) {    echo "

Hello! $name

";});
  • 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.