Yaf's hello world example

小云云
Release: 2023-03-17 15:54:01
Original
1779 people have browsed it

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 //插件目录
Copy after login

Write the entry file index.php

run();
Copy after login

Edit public/.htaccess rewrite rules (apache)

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* index.php
Copy after login

Edit configuration file conf/application.ini

[product] application.directory=APP_PATH "/application/"
Copy after login

Edit default controller application/controllers/Index. php

getView()->assign("content", "Hello world"); } }
Copy after login

Edit the view file templates/index/index.phtml

 Hello World
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!