Wellcome to PhpOpenMVC.

© 2008 Choosak Rangmai (r_choosak@hotmail.com). All rights reserved.
Black-Dog Studio.

 home | installation | configuration | tutorial | download


PhpOpenMVC is a php framework(model view controller). It's very small and fast.

Why?:
  • use Template_lite for template processor.
  • simple config by XML config file and phpopenmvc-config-1.0.dtd.
  • support simple data type and system validater class.
  • easy to learn and use.
  • free licensing terms.

 
 

Installation

required: simplexml, eval

  1. download PhpOpenMVC Package from sourceforge.net
  2. extract the package to app path.
    |---app path
              |---libs
              |---modules
              |---view
              |---compiled
              |+++controller.php
              |+++index.php
    		  
  3. Directory:
    libs: for install library include Template_lite.
    modules: for install module clesses.
    views: for install template files.
    compiled: for install template cache files.(permission 755)

  4. create config.xml
  5. edit index.php
    in parameter mode:
  6. <?php
    	require_once($_SERVER["DOCUMENT_ROOT"]."/app_path/libs/template_lite/class.template.php");
    	require_once($_SERVER["DOCUMENT_ROOT"]."/app_path/controller.php");
    	
    	$controller =& new Controller();
    	$controller->loadConfig("sample.config.xml");
    	$controller->execute($_REQUEST['module'],$_REQUEST['action']);
    
     ?>


    if use mod_rewrite url:

    # file .htaccess in app path directory
    <IfModule mod_rewrite.c> RewriteEngine on # Rewrite current-style URLs of the form 'index.php?url=x'. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?url=$1 [L,QSA] </IfModule>

    and create function in index.php

    <?php
    	require_once($_SERVER["DOCUMENT_ROOT"]."/app_path/libs/template_lite/class.template.php");
    	require_once($_SERVER["DOCUMENT_ROOT"]."/app_path/controller.php");
    function parseModuleAction($url) { $arr = array(); $arr['module'] = substr($url ....); $arr['action'] = substr($url ....); .... return $arr; } $arr = parseModuleAction($_REQUEST['url']); $controller =& new Controller(); $controller->loadConfig("sample.config.xml"); $controller->execute($arr['module'],$arr['action']); ?>

  7. execute.
     

     

Configuration

xml config file use phpopenmvc-config-1.0.dtd

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE phpopenmvc-config PUBLIC
 "-//PHPOpenMVC/PHPOpenMVC Config DTD 1.0//EN"
 "http://phpopenmvc.sourceforge.net/phpopenmvc-config-1.0.dtd">

<phpopenmvc-config>
  <modules>
    .......
  </modules>
  <views>
    .......
  </views>
</phpopenmvc-config>

Document xml config

Root: phpopenmvc-config

phpopenmvc-config
Attribute Value Description
no    
Element Value Description
modules module list of module.
views view list of view.


modules
Attribute Value Description
no    
Element Value Description
module actions module element.


views
Attribute Value Description
no    
Element Value Description
view   view element.


view
Attribute Value Description
name   define view name.
resource   file path (template file)
Element Value Description
no    


module
Attribute Value Description
name   module's name.
resource   file path for include.
Element Value Description
actions action list of action.


actions
Attribute Value Description
no    
Element Value Description
action actionviews, parameters action element.


action
Attribute Value Description
name   action's name.
classname   bind php class name.
method   bind method of class name for process.
Element Value Description
actionview   bind view element.
parameters* param, onValidateError list of parameter.
* : option element or attribute.

activeview
Attribute Value Description
view view's name bind view for the action display.
Element Value Description
no    


parameters
Attribute Value Description
no    
Element Value Description
param* validater define parameter for action
onValidateError*   validate parameter error exception action.
* : option element or attribute.

param
Attribute Value Description
name   param's name.
src src [=value] default = _REQUEST get value parameter from source.
type* type [=value] default = dynamic type of parameter.
allowNull* yes or no default = yes allow null.
defaultValue*   default value when null.
forceValidate* yes or no default = no force validate.
Element Value Description
validater validater define parameter for action
* : option element or attribute.

src [value]: _REQUEST, _POST, _GET, _SESSION, _COOKIE, _FILES, _SERVER, GLOBALS,
_ENV, HTTP_POST_VARS, HTTP_GET_VARS, HTTP_POST_FILES, HTTP_SESSION_VARS,
HTTP_COOKIE_VARS, HTTP_ENV_VARS, HTTP_SERVER_VARS

type [value]: boolean, numeric, int, integer, float, real, double, long, string, array,
object, email, date, datetime, time, timestamp, special, dynamic


validater
Attribute Value Description
classname   bind validater class
method   bind method for validate
resource   file path for include.
Element Value Description
no    


onValidateError
Attribute Value Description
classname   bind validater class
method   bind method for validate
resource   file path for include.
module module's name module validate error exception.
action action's name action validate error exception.
Element Value Description
no    
* : option element or attribute.

Example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE phpopenmvc-config PUBLIC
 "-//PHPOpenMVC/PHPOpenMVC Config DTD 1.0//EN"
 "http://phpopenmvc.sourceforge.net/phpopenmvc-config-1.0.dtd">

<phpopenmvc-config>
 <modules>
    <module name="hello" resource="modules/Hello.class.php" >
      <actions>
        <action name="say" classname="Hello" method="say">
          <actionview view="hello"/>
        </action>
      </actions>
    </module>
 </modules>
 <views>
  <view name="hello" resource="views/Hello.tpl.htm" />
 </views>
</phpopenmvc-config>

 

Tutorial

soon.


© 2008 Choosak Rangmai (r_choosak@hotmail.com). All Rights Reserved.