Permalink
Browse files

Update Readme.md

  • Loading branch information...
1 parent 331f1f7 commit 2793b9474feac55780cbc002c2e3dc03897398d7 @laruence committed Aug 26, 2012
Showing with 136 additions and 6 deletions.
  1. +0 −1 README
  2. +131 −0 README.md
  3. +1 −1 requests/simple.c
  4. +1 −1 yaf_controller.c
  5. +1 −1 yaf_dispatcher.c
  6. +1 −1 yaf_exception.h
  7. +1 −1 yaf_request.c
View
@@ -1 +0,0 @@
-Yaf is a PHP framework written in c and built as a PHP extension.
View
@@ -0,0 +1,131 @@
+# Yaf - PHP framework written in c and built as a PHP extension.
+
+## Install
+
+### Compile Yaf in Linux
+````
+$/path/to/phpize
+$./configure --with-php-config=/path/to/php-config/
+$make && make install
+````
+
+### For windows
+Yaf binary dlls could be found at http://code.google.com/p/yafphp/downloads/list
+
+## Tutorial
+
+### layout
+A classic Application directory layout:
+
+````
+- .htaccess // Rewrite rules
++ public
+ | - index.php // Application entry
+ | + css
+ | + js
+ | + img
++ conf
+ | - application.ini // Configure
+- application/
+ - Bootstrap.php // Bootstrap
+ + controllers
+ - Index.php // Default controller
+ + views
+ |+ index
+ - index.phtml // View template for default controller
+ - library
+ - models // Models
+ - plugins // Plugins
+````
+### DocumentRoot
+you should set DocumentRoot to application/public, thus only the public folder can be accessed by user
+
+### index.php
+index.php in the public directory is the only way in of the application, you should rewrite all request to it(you can use .htaccess in Apache+php_mod)
+
+````php
+<?php
+define("APP_PATH", dirname(__FILE__));
+
+$app = new Yaf_Application(APP_PATH . "/conf/application.ini");
+$app->bootstrap() //call bootstrap methods defined in Bootstrap.php
+ ->run();
+````
+### Rewrite rules
+
+#### Apache
+
+````conf
+#.htaccess, 当然也可以写在httpd.conf
+RewriteEngine On
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule .* index.php
+````
+
+#### Nginx
+
+````conf
+server {
+ listen ****;
+ server_name domain.com;
+ root document_root;
+ index index.php index.html index.htm;
+
+ if (!-e $request_filename) {
+ rewrite ^/(.*) /index.php/$1 last;
+ }
+}
+````
+
+#### Lighttpd
+
+````conf
+$HTTP["host"] =~ "(www.)?domain.com$" {
+ url.rewrite = (
+ "^/(.+)/?$" => "/index.php/$1",
+ )
+}
+````
+
+### application.ini
+
+application.ini is the application config file
+
+````ini
+[product]
+;CONSTANTS is supported
+application.directory=APP_PATH "/application/"
+````
+
+### default controller
+In Yaf, the default controller is named IndexController?:
+
+````php
+<?php
+class IndexController extends Yaf_Controller_Abstract {
+ public function indexAction() { // default action name
+ }
+}
+?>
+````
+
+###view script
+The view script for default controller and default action is in the application/views/index/index.phtml, Yaf provides a simple view engineer called Yaf_View_Simple?, which supported the view template written by PHP.
+
+````html
+<html>
+ <head>
+ <title>Hello World</title>
+ </head>
+ <body>
+ Hellow World!
+ </body>
+</htlm>
+````
+
+## Run the Applicatioin
+
+http://www.yourhostname.com/application/index.php
+
+## Alternative
+you can generate the example above by using Yaf Code Generator: https://github.com/laruence/php-yaf/tree/master/tools/cg
View
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: simple.c 321289 2011-12-21 02:53:29Z laruence $ */
+/* $Id: simple.c 327283 2012-08-26 07:58:18Z laruence $ */
static zend_class_entry *yaf_request_simple_ce;
View
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: yaf_controller.c 325274 2012-04-18 08:12:55Z laruence $ */
+/* $Id: yaf_controller.c 327283 2012-08-26 07:58:18Z laruence $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
View
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: yaf_dispatcher.c 327270 2012-08-25 15:13:04Z laruence $ */
+/* $Id: yaf_dispatcher.c 327283 2012-08-26 07:58:18Z laruence $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
View
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: yaf_exception.h 325425 2012-04-23 11:39:24Z laruence $ */
+/* $Id: yaf_exception.h 327283 2012-08-26 07:58:18Z laruence $ */
#ifndef YAF_EXCEPTION_H
#define YAF_EXCEPTION_H
View
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: yaf_request.c 326040 2012-06-08 10:35:44Z laruence $*/
+/* $Id: yaf_request.c 327283 2012-08-26 07:58:18Z laruence $*/
#ifdef HAVE_CONFIG_H
#include "config.h"

0 comments on commit 2793b94

Please sign in to comment.