FleaPHP single-entry document in Detail

sponsored links
Forum Posts: http://qeephp.com/bbs/thread-10922-1-1.html

Posts Reporter:

Posted record does not matter, just opening Ming Yi Bale. We can see that this thing can not help but ask, "Big Brother ah, do you this stuff in 2008, if not, posted in early 2007 said of the past, now posted, is it too late? What significance does ?. " Oh ......, night is bit late, or some sense. Although FleapHP's fans are now less and less, but because of its fewer people, we need to insist that only need to encourage each other. Confucius said, "Jen, I stick too!." Here, I have to say: "FleapHP, I stick too!" - FleapHP also I have been insisting on, you?

-------- X ------- x ------- x ------- x ------- x ----- x --- -> Beautiful separator <------ x ------- x ------ x ------ x ------ x -------- x ------- x -------- x -------

In FleaPHP application uses MVC pattern, the application of all functions through a single file to call. This single file to perform all the functions of the application procedure, known as single-entry application.

The file is usually placed in the main program directory. The code is as follows:

<?php
/**
 *  Import file  
 *
 * @file:index.php
 * @author:hegz
 * @update:2009/10/27
 */

define('__ROOT__', dirname(__FILE__)); //  Defines the root directory of your Web site  
define('DEPLOY_MODE', true); // Deployment mode enabled  
//define('NO_LEGACY_FLEAPHP', true); // Compatible with the legacy FleaPHP  , Now effect  

//  Mount FleaPHP framework files  
require(__ROOT__ . '/lib/FLEA/FLEA.php');

/**
 *  Mount configuration file  
 */
FLEA::loadAppInf(__ROOT__ . DS . 'public/Config/COMMON_INF.php'); //  Custom environment profile  
FLEA::loadAppInf(__ROOT__ . DS . 'public/Config/DSN.php'); //  The database link parameters configuration file  
FLEA::loadAppInf(__ROOT__ . DS . 'APP/Config/APP_INF.php'); //  Custom application-configuration file  

/**
 *  Set the run directory  
 */
FLEA::import(__ROOT__);
FLEA::import(__ROOT__ . DS . 'APP');
FLEA::import(__ROOT__ . DS . 'public');

//dump($GLOBALS['__FLEA_CORE__']['CLASS_PATH']); //  The debugger path  
//exit;

//  To the MVC pattern running system  
FLEA::runMVC();
?>

Note: the above code in the DS framework document for the FleaPHP defined path separator is a constant, Windows under the "\", Linux under the "/."

Code analysis

10th row:

define('__ROOT__', dirname(__FILE__));

Defined site root directory of the constant, the results may as shown below:

e: \ apmxe4 \ htdocs \ mmfs2010

Linux, may be:

/ Www/htdocs/mmfs2010

11th row:

define('DEPLOY_MODE', true);

Procedures deployed in real production environments when enabled, then the program will automatically call FleaPHP Frame FLEA / FLEA / Config / DEPLOY_MODE_CONFIG.php configuration file initialization program execution environment.
In the development environment, the need to display some error messages in detail, to facilitate debugging, you can be true to false, or you can directly block out the statement. As shown below:

define('DEPLOY_MODE', false);

Or directly to mask:

//define('DEPLOY_MODE', true);

At this point, the program will automatically call FleaPHP Frame FLEA / FLEA / Config / DEBUG_MODE_CONFIG.php profile initial program execution environment. Have time, we can compare the two files inside the configuration parameters of the similarities and differences.

15th row:

require(__ROOT__ . '/lib/FLEA/FLEA.php');

This well know, is loaded FleaPHP framework document FLEA.php, in the framework of the document loading process, the parameter values according to DEPLOY_MODE to load the default configuration file.

Article ~ 22 lines:

FLEA::loadAppInf(__ROOT__ . DS . 'public/Config/COMMON_INF.php');
FLEA::loadAppInf(__ROOT__ . DS . 'public/Config/DSN.php');
FLEA::loadAppInf(__ROOT__ . DS . 'APP/Config/APP_INF.php');

The three statements to load some custom configuration file, the program will run with the custom configuration file parameters override the default global configuration parameters.

Of which:

COMMON_INF.php files are shared environment configuration parameters, as follows:

<?php

return array(
    'controllerAccessor' => 'ctl',
    'defaultController'  => 'Default',
    'actionAccessor'     => 'act',
    'urlLowerChar'       => false,
    //'dispatcher'         => 'FLEA_Dispatcher_Auth',

    /**
     *  Scheduler scheduling failed  ( For example, the controller or the controller method does not exist  ) Later, to call the custom handler  
     */
    'dispatcherFailedCallback'  => 'onDispatcherFailedCallback', //'dispatcher' = 'FLEA_Dispatcher_Simple' When you enable  
    //'dispatcherAuthFailedCallback' => 'onAuthFailedCallback', //'dispatcher' = 'FLEA_Dispatcher_Auth' When you enable  

    /**
     *  Indicates when in the generated url  , Always use the application's entry, only the file name   URL_STANDARD  Mode  
     *
     *  If this setting is false, the resulting   url  Similar  :
     *
     * http://www.example.com/?controller=xxx&action=yyy
     */
    'urlAlwaysUseBootstrap'     => false,

    /**
     *  Indicates when in the generated url  , Always use the full name of the controller and action name  
     *
     *  If this setting is false, the default controller and action name does not appear in the   url  In  
     */
    'urlAlwaysUseAccessor'      => false,

    'responseCharset'    => 'gb2312',
    'defaultLanguage'    => 'chinese-gb2312',
    'databaseCharset'    => 'gb2312',
    'RBACSessionKey'     => 'RBAC_MMFS2009',
    //'autoResponseHeader'        => false,
    'internalCacheDir'   => __ROOT__ . DS . '_cache',

    /**
     * WebControls  Extended controls save directory  
     */
    'webControlsExtendsDir'     => __ROOT__ . DS . 'public/WebControls',

    /**
     *  Indicates whether to enable logging, set to  true When you enable  
     */
    'logEnabled'         => false,

);

?>

DSN.php parameters for the database link definition file, as follows:

<?php
/**
 *  The database connection parameters  
 */
return array(
    'dbDSN'     => array(
        'driver'        => 'mysql',
        'host'          => 'localhost',
        'login'         => 'mmfs2009',
        'password'      => ' ×××××××  ',
        'database'      => 'mmfs2009',
    )
);

?>

APP_INF.php custom foreground run parameter file, as follows:

<?php

return array(
    'dispatcher'       => 'FLEA_Dispatcher_Auth',

    /**
     *  Indicates whether the RBAC component you want to use the default   ACT  File  ( Use a single act file  )
     */
    'defaultControllerACTFile' => __ROOT__ . DS . 'APP/Controller/App.act.php',

    'view' => 'FLEA_View_Smarty',
    'viewConfig' => array(
        'smartyDir'         => __ROOT__ . DS . 'lib/Smarty',
        'template_dir'      => __ROOT__ . DS . 'APP/Templates',
        'compile_dir'       => __ROOT__ . DS . '_cache/1',
        'left_delimiter'    => '{{',
        'right_delimiter'   => '}}',
    ),
);
?>

Why do not these three configuration files into a configuration file as well? This is possible, but in some occasions to use less convenient, and easy modification. In general, the public after the configuration parameters configured little changes, but the link parameter in the deployment of the database parameters to the production environment, it is possible to modify the. Also, taking into account the foreground process and background process split into two directories, and if there is a back-entry documents, many parameters change, such as the path parameter, so before and after the Taiwan program requires a set of operating parameters have their own , then split the configuration file was very good.

27th ~ 29 lines:

FLEA::import(__ROOT__);
FLEA::import(__ROOT__ . DS . 'APP');
FLEA::import(__ROOT__ . DS . 'public');

The above statement is used to set the program to run directory. Implementation process, will route the data into the global array $ GLOBALS ['__FLEA_CORE__'] ['CLASS_PATH'] in the store, to facilitate subsequent use.

import () is defined in the framework document, which is a static method. The code is:

    /**
     *  Import the file search path  
     *
     * FLEA::loadClass().FLEA::getSingleton()  In the search path Specifies the name of the class definition file  .
     *  Therefore you need to call the   FLEA::import()  The storage class definition file directories are added to the search path  .
     *  However, should not be the directory containing the class files are added directly to the search path  , But according to the naming of the class to determine which directory you want to add  .
     *
     *  For example, the class name is Table_Posts, while the actual file is   ./APP/Table/Posts.php.
     *  You should add directory is./APP, rather than   ./APP/Table .
     *
     * example:
     * <code>
     * FLEA::import(APP_DIR . '/LIBS');
     * </code>
     *
     * @param string $dir
     */
    function import($dir)
    {
        if (array_search($dir, $GLOBALS[G_FLEA_VAR]['CLASS_PATH'], true)) { return; }
        if (DIRECTORY_SEPARATOR == '/') {
            $dir = str_replace('\\', DIRECTORY_SEPARATOR, $dir);
        } else {
            $dir = str_replace('/', DIRECTORY_SEPARATOR, $dir);
        }
        $GLOBALS[G_FLEA_VAR]['CLASS_PATH'][] = $dir;
    }

Index.php file to remove the two backslashes, as shown below:

//dump($GLOBALS['__FLEA_CORE__']['CLASS_PATH']); //  The debugger path  
//exit;

Remove the double slash:

dump($GLOBALS['__FLEA_CORE__']['CLASS_PATH']); //  The debugger path  
exit;

Implementation of the program, results are as follows:

Array
(
[0] => e: \ apmxe4 \ htdocs \ mmfs2010 \ lib \ FLEA
[1] => e: \ apmxe4 \ htdocs \ mmfs2010
[2] => e: \ apmxe4 \ htdocs \ mmfs2010 \ APP
[3] => e: \ apmxe4 \ htdocs \ mmfs2010 \ public
)

Explain:

mmfs2010 - the main program directory,
lib \ FLEA - FleaPHP framework document storage directory
APP - foreground application directory, which contains a Config, Controller, Templates directory
public - the public file storage directory, which contains a Config, Model, Table, WebControls other subdirectory

35th row:

FLEA::runMVC();

Then the last entry in the file statement to MVC mode system. In the case of non-MVC mode system, the implementation of the

FLEA::init();

Command.

FLEA:: init () key to complete the following tasks:

Exception handling routines to install FleaPHP application settings under settings determine whether loading in magic_quotes log service check php.ini settings to on, and will be automatically escaped PHP escape after the withdrawal of data set according to the application to decide whether urlMode on the URL for processing according to the application running determine what set requestFilters input filter settings autoLoad decisions based application which automatically loads the file under the application settings sessionProvider and autoSessionStart decided to use which application session services according to the definition set responseCharset and requestCharset constants RESPONSE_CHARSET and DATABASE_CHARSET
According to the application to decide whether to set multiLangaugeSupport multi-language support included in the application settings autoResponseHeader according to whether the output HTTP HEADER information such automatic initialization procedure for the vast majority of applications are all necessary. So be sure to remember that require ('FLEA.php') after going to call FLEA:: init ().

FLEA:: runMVC () role:

If you want to use the MVC pattern FleaPHP. Then loaded FLEA.php, call FLEA:: runMVC () to start the MVC pattern.
In the MVC pattern starts, FleaPHP URL address according to the controller name and the controller contains the action name, the implementation of the controller developers to write code.

In fact, FLEA:: runMVC () calls inside the FLEA:: init () method.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of FleaPHP single-entry document in Detail

  • Hibernate primary key strategy-sequence

    Today, the use of hibernate in the company encountered a troublesome problem, the use of hibernate when the primary key generation strategy set sequence, but always reported in the implementation could not get next sequence value of the error, then o ...

  • hibernate call stored procedure

    hibernate call stored procedure

  • hibernate using c3p0 connection pooling

    Private http://www.lifevv.com/tenyo/doc/20070605102040991.html c3p0 for open source's JDBC connection pool, with the release hibernate. This article describes how to use the hibernate configuration in c3p0. c3p0 connection pool configuration is v ...

  • Hibernate configuration parameters hibernate.hbm2ddl.auto

    Hibernate in the configuration file: <properties> <property name="hibernate.hbm2ddl.auto" value="create" /> </ properties> Parameter Description: validate load hibernate, the authentication to create a database t ...

  • Build flex + spring + blazeds + hibernate application

    Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries