Minor [PHP framework] 2. The first application Hello World, minorhello
2.1 Hello World
2.1.1 configure routes
Add the following configuration to the app/Config/routes. php file:
return [ ... '/helloworld' => [ 'name' => 'helloworld', 'controller' => 'App\Modules\Demo\Controller\HelloController', 'action' => 'hello' ],];
After this configuration, when we access the ingress
2.1.2 create a controller
In the app/Modules folder, create a folder: Demo/Controller/, create the file HelloController. php, and write the following in the file:
<?phpnamespace App\Modules\Demo\Controller;use Minor\Controller\Controller;class HelloController extends Controller{ public function hello() {return View::render('Demo:Hello:hello.php', ['name' => 'World']); }}
2.1.3 create a View File
Create a folder/Tpl/Hello/in the app/Modules/Demo/folder and then create hello. php:
Hello <?= $name?>
Then visit http://xxx.xxx.xxx/helloworldin the browser to see hello World.