Minor "PHP framework" 2. First app Hello World

Source: Internet
Author: User
Tags php framework

2.1 Hello World

  2.1.1 Configuring routing

Add the following configuration in the app/config/routes.php file:

return [   ...    ' /helloworld '            = ' +        [' name '                = '    HelloWorld ',        ' controller ' +        = '    app\modules\demo\controller\hellocontroller ',        ' action '            = '    hello '    ], ];

This configuration then executes the Hello method in the App\modules\demo\controller\hellocontroller when we access the Http://xxx.xxx.xxx/helloworld in the browser

  2.1.2 Creating a Controller

Under the App/modules folder, create the folder: demo/controller/, and then create the file hellocontroller.php, and then write in the file:

 <? phpnamespace App\modules\demo\controller;  use   Minor\controller\controller;  class  Hellocontroller extends   controller{ Span style= "color: #0000ff;" >public  function   Hello () { return  view::render ( " Demo:hello:hello.php ' Name ' =>  ' world '];              

  2.1.3 Creating a View File

Create the folder under the App/modules/demo/folder/tpl/hello/and then create the hello.php:

$name?>

And then access it in the browser: Http://xxx.xxx.xxx/helloworld can see Hello World.

Minor "PHP framework" 2. First app Hello World

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.