プログラム関連

dfw3ライブラリ

PHPライブラリ

functions

  • startSession()
  • makeLoginSession()
  • isLogin($moduleName = null)
  • session($key, $val = null)
  • deleteSession()
  • getCsrfCode()
  • checkCsrf($csrfCode, $moduleName = null)
  • h($text)
  • setTemplate($v)
  • setView($k, $v)
  • setViews($arr)
  • v($text)
  • getView($k)
  • raw($text)
  • redirectModule($modulePath)
  • validate($code = __, &$string, $min = false, $max = false, $byteMode = false)
  • validateByte($code = __, &$string, $min = false, $max = false)
  • getValidateError()
  • writeLog($message, $mode = 'info')

初期設定

  • 設定 bootstrap.php
<?php

$dfwConfig['core'] = array(
       'module_path' => dirname(__FILE__).'/module',
       'autoload_path' => array(
               dirname(__FILE__).'/classes',
        ),
       'top_module_name' => 'top',
       '404_module_name' => '404',
 );
$dfwConfig['view'] = array(
       'engine' => 'Smarty',
       'smarty_file' => dirname(__FILE__).'/vendor/smarty/Smarty.class.php',
       'template_path' => dirname(__FILE__).'/template',
       'cache_path' => dirname(__FILE__).'/cache',
 );

(1) PHPテンプレート

$dfwConfig['view'] = array(
        'engine' => 'PHP',
        'template_path' => dirname(__FILE__).'/template',
    );

(2) Twigテンプレート

$dfwConfig['view'] = array(
        'engine' => 'Twig',
        'autoloader_file' => dirname(__FILE__).'/vendor/Twig/Autoloader.php',
        'template_path' => dirname(__FILE__).'/template',
        'cache_path' => dirname(__FILE__).'/cache',
        'debug' => true,
    );

(3) Smartyテンプレート

$dfwConfig['view'] = array(
        'engine' => 'Smarty',
        'smarty_file' => dirname(__FILE__).'/vendor/smarty/Smarty.class.php',
        'template_path' => dirname(__FILE__).'/template',
        'cache_path' => dirname(__FILE__).'/cache',
    );
  • ファイルとディレクトリ構造

□ DfwLib.php

□ bootstrap.php

■ cache

■ classes

■ module

■ template

■ public_html

  • index.php
require_once __DIR__.'/../bootstrap.php';
require_once __DIR__.'/../DfwLib.php';
  • .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]