YAF's Hello World example

Source: Internet
Author: User
Tags php framework
YAF, full name yet another framework, is a C language written PHP framework, [1] is a php extension in the form of a PHP development framework, compared to the general PHP framework, it is faster and lighter. It provides bootstrap, routing, distribution, views, plugins, and is a full-featured PHP framework. In this section we will talk about the YAF-based Hello World example, assuming that the site directory for my example is/var/www/yaf_test, the directory structure I am using is as follows:

-index.php//Entry file + public |-htaccess//rewrite rules  |+ CSS  |+ img  |+ js + conf  |-Application.ini//profile + APPL Ication  |+ Controllers   |-index.php//Default controller  |+   views |+ Index//Controller    |-index.phtml//default view  |+ Modules//Other modules  |+ Library//local class library  |+ models//model directory  |+ plugins//Plugin Directory

Writing the Portal file index.php

<?php    //point to Web site root directory    define ("App_path",  dirname (__file__));    $app = new Yaf_application (App_path. ") /conf/application.ini ");    $app->run ();

Edit public/.htaccess rewrite rule (Apache)

Rewriteengine on     rewritecond%{request_filename}!-f    rewriterule. * index.php

Editing a configuration file Conf/application.ini

[Product]    Application.directory=app_path "/application/"

Edit Default Controller application/controllers/index.php

<?php    class Indexcontroller extends yaf_controller_abstract{public     function indexaction () {    $this- >getview ()->assign ("Content", "Hello World");     }     }

Edit View File templates/index/index.phtml


After the above operation, in the browser input site 127.0.0.1/yaf_test can see the output of Hello World, if not, please check whether the above steps do the right!

The above is a simple yaf-based Hello World example, if you have questions welcome to the consultation OH.

Related Article

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.