Ground Sunlight

Windowsで作る - PHPプログラミングの開発環境

ユーザ用ツール

サイト用ツール


apricot:core:applocation-class

差分

このページの2つのバージョン間の差分を表示します。

この比較画面にリンクする

次のリビジョン
前のリビジョン
apricot:core:applocation-class [2020/04/29 23:17]
y2sunlight 作成
— (現在)
行 1: 行 1:
->TODO: 編集中 
- 
----- 
- 
-====== Apricot 基本コア ====== 
- --- //[[http://www.y2sunlight.com|y2sunlight]] 2020-04-25// 
- 
-[[apricot:top|Apricot に戻る]] 
- 
-関連記事 
-  * [[apricot:configuration|Apricot プロジェクトの作成]] 
-  * [[apricot:public|Apricot 公開フォルダ]] 
-  * Apricot 基本コア 
-    * [[apricot:core:applocation-class||Apricot 基本コア:アプリケーションクラス]] 
-    * [[apricot:core:basic-class||Apricot 基本コア:各種基本クラス]] 
-  * [[apricot:app:home|Apricot アプリケーションホーム]] 
- 
----- 
- 
-===== コア作成の準備 ===== 
-まずは、apricotのコアを作る為に以下を準備します。 
- 
-  * アプリケーションに追加する環境変数(phpdotenv) 
-  * コアフォルダ、名前空間、オートローディングの設定 
-  * コア構築のヘルパーとなるグローバル関数とベースクラス 
-\\ 
- 
-==== 環境設定 ==== 
- 
-アプリケーション全体の環境設定は [[basic-library:phpdotenv:4.1|phpdotenv]] で行います。phpdotenvで使用する環境ファイル( .env ) はプロジェクトフォルダ直下に設置します。 
- 
-{{fa>folder-open-o}} ** /apricot ** 
-<code ini .env> 
-# Application 
-APP_NAME=Apricot 
-APP_VERSION=0.9 
-#APP_SECRET=Please set a random 32 characters 
-APP_SECRET=0123456789ABCEDF0123456789ABCEDF 
-APP_DEBUG=true 
-APP_TIMEZONE=Asia/Tokyo 
-APP_LANG=ja 
- 
-# Loging 
-LOG_NAME ="apricot" 
-LOG_LEVEL = "debug" 
-</code> 
- 
-^環境変数^設定内容^型^必須^ 
-|APP_NAME|アプリケーション名(半角英数字)|string|〇| 
-|APP_VERSION|バージョン|string|〇| 
-|APP_SECRET|シークレット文字列\\ 安全の為にランダムな32文字を設定して下さい|string|〇| 
-|APP_DEBUG|デバッグモード|bool|〇| 
-|APP_TIMEZON|タイムゾーン|string|〇| 
-|LOG_NAME|ログ名 (省略時はAPP_NAMEと同じ)|string| | 
-|LOG_LEVEL|[[https://github.com/Seldaek/monolog/blob/master/doc/01-usage.md#log-levels|ログレベル]] (省略時はdebug)|string| | 
- 
-\\ 
- 
-==== コアフォルダ ==== 
-以下に示すようにプロジェクトフォルダ下に、コア用のフォルダ core を作成し、その下に4つのフォルダ(Derivations, Exceptions, Foundation, helpers)を作成します。 
- 
-<code> 
-apricot [プロジェクト] 
- | 
- ├── core [Apricotのコア] 
-    | 
-    ├── Derivations [ライブラリの派生クラス] 
-    ├── Exceptions  [例外] 
-    ├── Foundation  [基盤] 
-    └── helpers     [ヘルパー関数] 
-</code> 
- 
-> クラスを保存するフォルダはUpperCamelCaseそれ以外はsnake_caseを使用しています 
- 
-\\ 
- 
-=== composer.jsonの変更 === 
- 
-以下のようにcomposer.jsonへ ''autoload'' を追加します。 
- 
-{{fa>folder-open-o}} ** /apricot ** 
-<code json composer.json> 
-{ 
-   ... 
- "autoload" : { 
- "psr-4" : { 
- "Core\\" : "core/" 
- }, 
- "files": [ 
- "core/helpers/utilities.php", 
- "core/helpers/boilerplates.php" 
- ] 
- } 
-} 
-</code> 
- 
-  * coreフォルダをCore名前空間にマッピングします 
-  * 次のファイルをオートロードの対象に追加します(グローバル関数用) 
-    * core/helpers/utilities.php 
-    * core/helpers/boilerplates.php 
- 
-オートローディングファイルを更新する為に、プロジェクトフォルダで以下のコマンドを実行します。 
-<code> 
-composer dump-autoload 
-</code> 
- 
-\\ 
- 
-==== 例外クラス ==== 
- 
-Exceptionを継承した2つの例外クラスを core\Exceptions に作成します。 
- 
-  * HttpExceptionクラス --- HTTP例外(HTTPステータスコード400番台,500番台) 
-  * TokenMismatchExceptionクラス --- トークンミスマッチ例外(CSRFトークンなどの不一致) 
- 
-{{fa>folder-open-o}} ** /apricot/core/Exceptions ** 
- 
-<code php HttpException.php> 
-<?php 
-namespace Core\Exceptions; 
- 
-/** 
- * Http Exception 
- */ 
-class HttpException extends \Exception 
-{ 
-    /** 
-     * Http Status Code 
-     * @var int 
-     */ 
-    private $statusCode; 
- 
-    /** 
-     * Create HttpException 
-     * @param int $statusCode 
-     * @param string $message 
-     * @param int $code 
-     * @param \Exception $previous 
-     */ 
-    public function __construct(int $statusCode, string $message = null, int $code = 0, \Exception $previous = null) 
-    { 
-        $this->statusCode = $statusCode; 
-        parent::__construct(isset($message) ? $message : "Http Status : {$statusCode}", $code, $previous); 
-    } 
- 
-    /** 
-     * Get Http Status Code 
-     * @return int 
-     */ 
-    public function getStatusCode() 
-    { 
-        return $this->statusCode; 
-    } 
-} 
-</code> 
- 
-<code php TokenMismatchException.php> 
-<?php 
-namespace Core\Exceptions; 
- 
-/** 
- * Token Mismatch Exception 
- */ 
-class TokenMismatchException extends \Exception 
-{ 
-    /** 
-     * Create TokenMismatchException 
-     * @param string $message 
-     * @param int $code 
-     * @param \Exception $previous 
-     */ 
-    public function __construct(string $message = 'Token Mismatch Exception', int $code = 0, \Exception $previous = null) 
-    { 
-        parent::__construct($message, $code, $previous); 
-    } 
-} 
-</code> 
- 
-\\ 
- 
-==== ヘルパー ==== 
- 
-グローバル関数を保存するためのPHPファイルを core\helper に作成します。目的別に2種類のPHPファイルがあります。 
- 
-  * utilities.php --- PHPの基本的な組み込み関数を拡張する目的 
-  * boilerplates.php --- apricotでよく使用される定型文的なコードパターンを関数化したもの\\ ( apricotではボイラープレートと呼んでいる ) 
- 
-{{fa>folder-open-o}} ** /apricot/core/helper ** 
-<code php utilities.php> 
-<?php 
-/** 
- * Add path 
- * @param string $base Base path 
- * @param string $path Sub path, if necessary 
- * @return string path 
- */ 
-function add_path(string $base, string $path = null) : string 
-{ 
-    return (is_null($path)) ? $base : rtrim($base,'/').'/'.$path; 
-} 
- 
-/** 
- * Convert a multi-dimensional associative array to a Dot-notation array 
- * @param  array   $hash multi-dimensional associative array 
- * @param  string  $prepend 
- * @return array   a Dot-notation array 
- */ 
-function array_dot(array $hash, $prepend = '') 
-{ 
-    $dot_arry = []; 
-    foreach ($hash as $key => $value) 
-    { 
-        if (is_array($value) && count($value)) 
-        { 
-            $dot_arry = array_merge($dot_arry, array_dot($value, $prepend.$key.'.')); 
-        } 
-        else 
-        { 
-            $dot_arry[$prepend.$key] = $value; 
-        } 
-    } 
-    return $dot_arry; 
-} 
- 
-/** 
- * Get an item from an array using Dot-notation 
- * @param  array $hash multi-dimensional associative array 
- * @param  string $dot key using Dot-notation 
- * @param  mixed $default 
- * @return mixed 
- */ 
-function array_get(array $hash, string $dot=null, $default=null) 
-{ 
-    if (!isset($dot)) return $hash; 
- 
-    $keys = explode('.', $dot); 
-    foreach($keys as $key) 
-    { 
-        if (array_key_exists($key, $hash)) 
-        { 
-            $hash = $hash[$key]; 
-        } 
-        else 
-        { 
-            return $default; 
-        } 
-    } 
-    return $hash; 
-} 
- 
-/** 
- * Checks if a key is present in an array using Dot-notation 
- * @param  array $hash multi-dimensional associative array 
- * @param  string $dot key using Dot-notation 
- * @return bool 
- */ 
-function array_has(array $hash, string $dot):bool 
-{ 
-    $keys = explode('.', $dot); 
-    foreach($keys as $key) 
-    { 
-        if (array_key_exists($key, $hash)) 
-        { 
-            $hash = $hash[$key]; 
-        } 
-        else 
-        { 
-            return false; 
-        } 
-    } 
-    return true; 
-} 
- 
-/** 
- * Get a subset of the input for only specified items 
- * @param array $input 
- * @param array|mixed $keys 
- * @return array subset of the input 
- */ 
-function array_only(array $input, $keys) 
-{ 
-    $key_arr = is_array($keys) ? $keys : array_slice(func_get_args(),1); 
- 
-    $results = []; 
-    foreach ($key_arr as $key) 
-    { 
-        $results[$key] = $input[$key]; 
-    } 
-    return $results; 
-} 
- 
-/** 
- * Get a subset of the input except for specified items 
- * @param array $input 
- * @param array|mixed $keys 
- * @return array subset of the input 
- */ 
-function array_except(array $input, $keys=null) 
-{ 
-    $key_arr = is_array($keys) ? $keys : array_slice(func_get_args(),1); 
- 
-    $results = []; 
-    foreach($input as $key=>$value) 
-    { 
-        if (!in_array($key,$key_arr)) $results[$key]=$value; 
-    } 
-    return $results; 
-} 
- 
-/** 
- * Generate random numbers 
- * @param number $length 
- * @return string 
- */ 
-function str_random($length = 32) 
-{ 
-    return substr(bin2hex(random_bytes($length)), 0, $length); 
-} 
- 
-/** 
- * Get short class name 
- * @param object $object 
- * @return string 
- */ 
-function get_short_class_name($object) 
-{ 
-    return (new \ReflectionClass($object))->getShortName(); 
-} 
-</code> 
- 
- 
-boilerplates.php へは関数を逐次追加します。現段階での内容は以下の通りです。 
- 
-<code php boilerplates.php> 
-<?php 
- 
-/** 
- * Abort 
- * @param int $code 
- * @param string $message 
- * @throws \Core\Exceptions\HttpException 
- */ 
-function abort(int $code, string $message=null) 
-{ 
-    throw new Core\Exceptions\HttpException($code, $message); 
-} 
-</code> 
- 
-\\ 
- 
-==== ベースクラス ==== 
- 
-apricotでは、ログ、デバッグ、設定、HTMLテンプレート、翻訳などのクラスをシングルトンとして実装します。そして、それらのシングルトンのメソッドを静的にアクセス出来るようにしたいと思います。これらの仕組みを実装する為に、core\Foundation に次の2つのベースクラスを作ります。 
- 
-  * CallStaticクラス --- インスタンスメソッドを静的アクセス可能にするクラス 
-  * Singletonクラス --- CallStaticから継承したシングルトン 
- 
-{{fa>folder-open-o}} ** /apricot/core/Foundation ** 
-<code php CallStatic.php> 
-<?php 
-namespace Core\Foundation; 
- 
-/** 
- * CallStatic 
- */ 
-abstract class CallStatic 
-{ 
-    protected static abstract function getInstance(); 
- 
-    /** 
-     * Handle calls to Instance,Statically. 
-     * @param  string  $method 
-     * @param  array   $args 
-     * @return mixed 
-     */ 
-    public static function __callStatic($method, $args) 
-    { 
-        $instance = static::getInstance(); 
-        return $instance->$method(...$args); 
-    } 
-} 
-</code> 
- 
-<code php Singleton.php> 
-<?php 
-namespace Core\Foundation; 
- 
-/** 
- * Singleton 
- */ 
-abstract class Singleton extends CallStatic 
-{ 
-    protected static abstract function createInstance(); 
- 
-    /** 
-     * Get instance. 
-     * @return object 
-     */ 
-    public static function getInstance() 
-    { 
-        static $instance = null; 
-        if (!$instance) 
-        { 
-            $instance = static::createInstance(); 
-        } 
-        return $instance; 
-    } 
-} 
-</code> 
- 
-\\ 
- 
- 
-===== Applicationクラスの作成 ===== 
- 
-さて、準備が出来たのでいよいよコアのクラス群を作って行きたいと思います。最初にApplicationクラスを作成しますが、その前にApplicationクラスの責任を明確にしておきます。 
- 
-=== Applicationクラスの責任 === 
- 
-  * アプリケーションの初期化 
-  * ルーティングとセキュリティの設定 
-  * ミドルウェアの設定 
-  * アクションの起動 
- 
-Applicationクラスは、以下の公開メソッドを持っています。詳細はソースコードを参照して下さい。 
- 
-=== フロントコントローラ(index.php)から呼び出されるメソッド === 
- 
-^公開メソッド^機能^ 
-|setup(array $app=[])|アプリケーションのセットアップ| 
-|run(callable $routeDefinitionCallback)|アプリケーションの起動| 
- 
-=== ゲッターメソッド === 
- 
-^公開メソッド^機能^ 
-|getInstance():Application|Applicationインスタンスの取得| 
-|getSetting($dot = null, $default=null)|アプリケーション設定(app.php)の取得| 
-|getProjectDir():string|プロジェクトフォルダの取得| 
-|getConfigDir():string|config(一般設定)フォルダの取得| 
-|getAssetsDir():string|assets(資源)フォルダの取得| 
-|getVarDir():string|var(データ)フォルダの取得| 
-|getPublicDirectory():string|public(公開)の取得| 
-|getRouteBase():string|URIルートベースの取得| 
-|getControllerName():string|カレントコントローラ名の取得| 
-|getActionName():string|カレントアクション名の取得| 
- 
-\\ 
- 
-==== Applicationクラス(暫定版) ==== 
- 
-以下に現段階のApplicationクラスを示します。ほとんどの機能は実装していますが、アクションを実行するメソッド(executeAction)だけが未実装(スタブ)です。 
- 
-{{fa>folder-open-o}} ** /apricot/core ** 
-<code php Application.php> 
-<?php 
-namespace Core; 
- 
-/** 
- * Application Class 
- */ 
-class Application 
-{ 
-    /** 
-     * Application Instance 
-     * var Application 
-     */ 
-    private static $instance = null; 
- 
-    /** 
-     * Application Setting 
-     * @var array 
-     */ 
-    private $app = []; 
- 
-    /* 
-     * Project Directories 
-     */ 
-    private $projectDir; 
-    private $configDir; 
-    private $assetsDir; 
-    private $varDir; 
- 
-    /* 
-     * Public Directory 
-     */ 
-    private $publicDir; 
- 
-    /* 
-     * Route Base Path 
-     */ 
-    private $routeBase; 
- 
-    /* 
-     * Controller Name 
-     */ 
-    private $controllerName; 
- 
-    /* 
-     *Action Name; 
-     */ 
-    private $actionName; 
- 
-    /** 
-     * Get Project dir 
-     * @return string 
-     */ 
-    public function getProjectDir():string {return $this->projectDir;} 
- 
-    /** 
-     * Get config dir 
-     * @return string 
-     */ 
-    public function getConfigDir():string {return $this->configDir; } 
- 
-    /** 
-     * Get assets dir 
-     * @return string 
-     */ 
-    public function getAssetsDir():string {return $this->assetsDir; } 
- 
-    /** 
-     * Get var dir 
-     * @return string 
-     */ 
-    public function getVarDir():string {return $this->varDir; } 
- 
-    /** 
-     * Get Public Directory 
-     * @return string 
-     */ 
-    public function getPublicDirectory():string {return $this->publicDir; } 
- 
-    /** 
-     * Get Route Base Path 
-     * @return string 
-     */ 
-    public function getRouteBase():string {return $this->routeBase; } 
- 
-    /** 
-     * Get controller Name 
-     * @return string 
-     */ 
-    public function getControllerName():string {return $this->controllerName; } 
- 
-    /** 
-     * Get Action Name 
-     * @return string 
-     */ 
-    public function getActionName():string {return $this->actionName; } 
- 
-    /** 
-     * Get Application instance. 
-     * @return \Core\Application 
-     */ 
-    static public function getInstance():Application 
-    { 
-        if (!self::$instance) 
-        { 
-            throw new \RuntimeException('Application has not been set.'); 
-        } 
-        return self::$instance; 
-    } 
- 
-    /** 
-     * Create Application 
-     * @param string $projectDir 
-     * @param string $publicDir 
-     */ 
-    function __construct(string $projectDir, string $publicDir) 
-    { 
-        if (!self::$instance) 
-        { 
-            // Set Project Directories 
-            $this->projectDir = $projectDir; 
-            $this->configDir = $projectDir.'/config'; 
-            $this->assetsDir = $projectDir.'/assets'; 
-            $this->varDir = $projectDir.'/var'; 
- 
-            // Set Public Directory 
-            $this->publicDir = $publicDir; 
- 
-            // Set Route Base Path 
-            $routeBase = dirname($_SERVER['SCRIPT_NAME']); 
-            if (preg_match('/^[\\.\\\\]$/', $routeBase)) $routeBase=''; 
-            $this->routeBase = $routeBase; 
- 
-            // Set Dotenv 
-            \Dotenv\Dotenv::createImmutable($projectDir)->load(); 
- 
-            // Set timezone 
-            date_default_timezone_set(env('APP_TIMEZONE','UCT')); 
- 
-            self::$instance = $this; 
-        } 
-    } 
- 
-    /** 
-     * Get an application setting value 
-     * @param string|null $dot Dot-notation key 
-     * @param mixed $default 
-     * @return mixed 
-     */ 
-    public function getSetting($dot = null, $default=null) 
-    { 
-        return array_get($this->app, $dot, $default); 
-    } 
- 
-    /** 
-     * Setup Application 
-     * @param array $app Application Setting 
-     */ 
-    public function setup(array $app=[]) 
-    { 
-        $this->app = $app; 
- 
-        // Application setup 
-        if (!empty($this->app) && array_key_exists('setup', $this->app)) 
-        { 
-            foreach($this->app['setup'] as $setup) 
-            { 
-                $func = require_once $setup; 
-                if (!is_callable($func) || ($func()===false)) 
-                { 
-                    throw new \RuntimeException("Application Setup Error: {$setup}"); 
-                } 
-            } 
-        } 
-    } 
- 
-    /** 
-     * Run Application 
-     * @param callable $routeDefinitionCallback 
-     */ 
-    public function run(callable $routeDefinitionCallback) 
-    { 
-        // Create Dispatcher 
-        $dispatcher = \FastRoute\simpleDispatcher($routeDefinitionCallback); 
- 
-        // Fetch method and URI from somewhere 
-        $httpMethod = $_SERVER['REQUEST_METHOD']; 
-        $uri = $_SERVER['REQUEST_URI']; 
- 
-        // Strip query string (?foo=bar) and decode URI 
-        if (false !== $pos = strpos($uri, '?')) 
-        { 
-            $uri = substr($uri, 0, $pos); 
-        } 
-        $uri = rawurldecode($uri); 
- 
-        $routeInfo = $dispatcher->dispatch($httpMethod, $uri); 
-        switch ($routeInfo[0]) 
-        { 
-            case \FastRoute\Dispatcher::NOT_FOUND: 
-                abort(404, 'Page Not Found'); 
-                break; 
- 
-            case \FastRoute\Dispatcher::METHOD_NOT_ALLOWED: 
-                abort(405, 'Method Not Allowed'); 
-                break; 
- 
-            case \FastRoute\Dispatcher::FOUND: 
- 
-                $handler = $routeInfo[1]; 
-                $params = $routeInfo[2]; 
- 
-                if (is_callable($handler)) 
-                { 
-                    // Case of callable 
-                    $handler($params); 
-                } 
-                elseif(strpos($handler,'@')!==false) 
-                { 
-                    // Case of Controller/Action 
-                    list($this->controllerName, $this->actionName) = explode('@', $handler); 
- 
-                    // Ecexute action 
-                    $this->executeAction($this->controllerName, $this->actionName, $params); 
-                } 
-                else 
-                { 
-                    abort(500,'Action Not Found'); 
-                } 
-                break; 
-        } 
-    } 
- 
-    /** 
-     * Ecexute action 
-     * @param string $controllerName 
-     * @param string $actionName 
-     * @param array $params 
-     */ 
-    private function executeAction(string $controllerName, string $actionName, array $params=[]) 
-    { 
-        // TODO: Stub Version 
-        $controller = "\\App\\Controllers\\{$controllerName}"; 
-        $instance = new $controller(); 
-        return call_user_func_array(array($instance, '$actionName'), $params); 
-    } 
-} 
-</code> 
- 
-\\ 
- 
-==== Applicationクラスのヘルパー関数 ==== 
- 
-Applicationクラスのゲッターメソッドで良く使用されるものは boilerplates.php にヘルパー関数として追加しておきます。 
- 
-{{fa>folder-open-o}} ** /apricot/core/helpers ** 
-<code php boilerplates.php> 
-// ... 
- 
-/** 
- * Get application setting value 
- * @param string|null $dot Dot-notation key 
- * @param mixed $default 
- * @return mixed 
- */ 
-function app($dot = null, $default=null) 
-{ 
-    return Core\Application::getInstance()->getSetting($dot, $default); 
-} 
- 
-/** 
- * Get project directory 
- * @param string|null $default 
- * @return string project directory 
- */ 
-function project_dir($path = null):string 
-{ 
-    return add_path(Core\Application::getInstance()->getProjectDir(), $path); 
-} 
- 
-/** 
- * Get config directory 
- * @param string $path Sub path, if necessary 
- * @return string config directory 
- */ 
-function config_dir($path = null):string 
-{ 
-    return add_path(Core\Application::getInstance()->getConfigDir(), $path); 
-} 
- 
-/** 
- * Get assets directory 
- * @param string $path Sub path, if necessary 
- * @return string assets directory 
- */ 
-function assets_dir($path = null):string 
-{ 
-    return add_path(Core\Application::getInstance()->getAssetsDir(), $path); 
-} 
- 
-/** 
- * Get var directory 
- * @param string $path Sub path, if necessary 
- * @return string var directory 
- */ 
-function var_dir($path = null):string 
-{ 
-    return add_path(Core\Application::getInstance()->getVarDir(), $path); 
-} 
- 
-/** 
- * Get public directory 
- * @param string $path Sub path, if necessary 
- * @return string public directory 
- */ 
-function public_dir($path = null):string 
-{ 
-    return add_path(Core\Application::getInstance()->getPublicDirectory(),$path); 
-} 
- 
-/** 
- * Get application URL 
- * @param string $path Sub path, if necessary 
- * @return string URL 
- */ 
-function url($path = null):string 
-{ 
-    // TODO: DomainとProtocolから計算する 
-    $base = env('APP_URL', Core\Application::getInstance()->getRouteBase()); 
-    return add_path($base,$path); 
-} 
- 
-/** 
- * Get file URL With version 
- * @param string $filename 
- * @return string URL 
- */ 
-function url_ver(string $filename) 
-{ 
-    return url($filename).'?v='.env('APP_VERSION'); 
-} 
- 
-/** 
- * Get routing path 
- * @param string $path Sub path, if necessary 
- * @return string routing path 
- */ 
-function route($path = null):string 
-{ 
-    return add_path(Core\Application::getInstance()->getRouteBase(),$path); 
-} 
- 
-/** 
- * Get current controller name 
- * @return string name 
- */ 
-function controllerName():string 
-{ 
-    return Core\Application::getInstance()->getControllerName(); 
-} 
- 
-/** 
- * Get current action name 
- * @return string name 
- */ 
-function actionName():string 
-{ 
-    return Core\Application::getInstance()->getActionName(); 
-} 
-</code> 
- 
-\\ 
- 
-==== Applicationクラスの設定ファイル ==== 
- 
-Applicationクラスは次の2つの設定ファイルを持っています。これらはconfigフォルダ内に保存されています。 
- 
-  * app.php 
-    * setup --- ライブラリの初期化ファイルの所在(フルパス) 
-    * middleware --- ミドルウェアの完全修飾クラス名 
-    * auth --- ユーザ認証(セッション認証)の設定 
-    * csrf --- CSRFトークンの設定 
-  * routes.php --- ルーティング設定(URIとアクションの紐づけ)\\ ( ルーティング設定に関しては[[https://github.com/nikic/FastRoute|FastRoute]]を参照 ) 
- 
-{{fa>folder-open-o}} ** /apricot/config** 
- 
-<code php app.php> 
-<?php 
-return 
-[ 
-    'setup' =>[], 
-    'middleware' =>[], 
-    'auth' =>[], 
-    'csrf' =>[], 
-]; 
-</code> 
- 
-<code php routes.php> 
-<?php 
-//------------------------------------------------------------------- 
-// Route Definition Callback 
-//------------------------------------------------------------------- 
-return function (FastRoute\RouteCollector $r) 
-{ 
-    $base = Core\Application::getInstance()->getRouteBase(); 
-    $r->addGroup($base, function (FastRoute\RouteCollector $r) use($base) 
-    { 
-        // TODO: Stub Version 
-        $r->get('/', function() use($base){ 
-            header("Content-type: text/html; charset=utf-8"); 
-            echo 'Hello, Apricot!' 
-        }); 
-    }); 
-}; 
-</code> 
- 
-\\ 
- 
-==== index.php(正式版) ==== 
- 
-\\ 
- 
-===== 各種基本コアクラスの作成 ===== 
- 
-次に、Application以外の基本的なコアクラスを作って行きます。ここで作成する多くのクラスはシングルトンとして実装します。 
- 
-\\ 
- 
-==== 設定管理 ==== 
- 
-\\ 
- 
-==== ロギング ==== 
- 
-\\ 
- 
-==== 集約例外ハンドラー ==== 
- 
-\\ 
- 
-==== デバッグバー ==== 
- 
-\\ 
- 
-==== リクエスト ===== 
- 
-\\ 
- 
-==== レスポンス ==== 
- 
-\\ 
- 
-==== HTMLテンプレート ==== 
- 
-\\ 
- 
-==== トランスレーション ==== 
- 
-\\ 
- 
-===== アクションの実行 ===== 
- 
-\\ 
  
apricot/core/applocation-class.1588169861.txt.gz · 最終更新: 2020/04/29 23:17 by y2sunlight