Example #1
0
 */
///whatever you named your database
define('DATABASE_NAME', 'gdi_php_mvc');
///the user with permissions to your database. By default this is 'root'
define('DATABASE_USER', 'root');
///the password of the user.
///For MAMP users, this is 'root' by default.
///For XAMPP and WAMP users, this is '' by default
define('DATABASE_PASSWORD', 'root');
///The host of your database.
///For all local database users, this is localhost.
///For many hosted users (those on bluehost, rackspace, etc.) it is also localhost. But some have a special host name like Dreamhost that they will give you when you sign up for a database on their server.
define('DATABASE_HOST', 'localhost');
session_start();
/**
 * include all config files, and all files in the models and controllers directories
 */
require_once 'db.php';
require_once 'model.php';
include_all_php($_SERVER['DOCUMENT_ROOT'] . '/' . 'application/models');
include_all_php($_SERVER['DOCUMENT_ROOT'] . '/' . 'application/controllers');
/**
 * @param $folder
 * function to recursively include all files in a folder
 */
function include_all_php($folder)
{
    foreach (glob("{$folder}/*.php") as $filename) {
        require_once $filename;
    }
}
<?php

// change the following paths if necessary
$yii = dirname(__FILE__) . '/../../yii/framework/yii.php';
$component = dirname(__FILE__) . '/../protected/components';
$config = dirname(__FILE__) . '/../protected/config/main.php';
$controllers = dirname(__FILE__) . '/../protected/controllers';
$models = dirname(__FILE__) . '/../protected/models';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
require_once $config;
require_once $yii;
//Yii::createWebApplication($config)->run();
function include_all_php($folder)
{
    foreach (glob("{$folder}/*.php") as $filename) {
        include $filename;
    }
}
include_all_php($component);
include_all_php($controllers);
include_all_php($models);
Example #3
0
<?php

session_start();
ini_set("display_errors", 1);
//mindent meghív a megadott mappából
function include_all_php($folder)
{
    foreach (glob("{$folder}/*.php") as $filename) {
        include $filename;
    }
}
//szükséges class-ok lérrehozása/include-olása
include_all_php('library');
include_all_php('model');
include_once 'controller/BlogController.php';
//controllerek kezelése, megfelelő alcontroller meghívása
$blog = new BlogController();
$controller_name = $blog->chooseController();
include 'controller/' . $controller_name . '.php';