Yaf, the full name of Yet Another Framework, is a PHP framework written in C language. [1] It is a PHP development framework provided in the form of a PHP extension. Compared with ordinary PHP frameworks, it is faster and lighter. It It provides Bootstrap, routing, distribution, views, and plug-ins, and is a full-featured PHP framework. In this section, we will talk about the Hello world example based on yaf. Assume that the site directory of my example is /var/www/yaf_test. The directory structure I use is as follows:
- index.php //入口文件 + public |- .htaccess //重写规则 |+ css |+ img |+ js + conf |- application.ini //配置文件 + application |+ controllers |- Index.php //默认控制器 |+ views |+ index //控制器 |- index.phtml //默认视图 |+ modules //其他模块 |+ library //本地类库 |+ models //model目录 |+ plugins //插件目录
Write the entry file index.php
run();
Edit public/.htaccess rewrite rules (apache)
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* index.php
Edit configuration file conf/application.ini
[product] application.directory=APP_PATH "/application/"
Edit default controller application/controllers/Index. php
getView()->assign("content", "Hello world"); } }
Edit the view file templates/index/index.phtml
Hello World
After the above operation, enter the website 127.0.0.1/yaf_test in the browser to see the output of Hello world. If No, please check again whether the above steps are done correctly!
The above is a simple Hello world example based on yaf. If you have any questions, please feel free to consult.
Related recommendations:
PHPYaf execution process source code
Example of PHP's C extension Yaf
Start the yaf journey_PHP tutorial
The above is the detailed content of Yaf's hello world example. For more information, please follow other related articles on the PHP Chinese website!