Ground Sunlight

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

ユーザ用ツール

サイト用ツール


apricot:core:top

差分

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

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

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
次のリビジョン 両方とも次のリビジョン
apricot:core:top [2020/05/05 10:14]
y2sunlight [Apricot コア作成の準備]
apricot:core:top [2020/05/15 22:06]
y2sunlight [Apricot コア作成の準備]
行 13: 行 13:
     * [[apricot:core:request-class|Apricot リクエストクラス]]     * [[apricot:core:request-class|Apricot リクエストクラス]]
     * [[apricot:core:response-class|Apricot レスポンスクラス]]     * [[apricot:core:response-class|Apricot レスポンスクラス]]
 +    * [[apricot:core:base-controller|Apricot ベースコントローラ]]
     * [[apricot:core:completion|Apricot コアの完成]]     * [[apricot:core:completion|Apricot コアの完成]]
   * [[apricot:app:top|Apricot アプリ]]   * [[apricot:app:top|Apricot アプリ]]
-  * [[apricot:ext:top|Apricot 拡張]] +  * [[apricot:ext:middleware|Apricot 拡張]]
- +
-\\+
  
 まずは、apricotのコアを作る為に以下を準備します。 まずは、apricotのコアを作る為に以下を準備します。
行 392: 行 391:
 { {
     return (new \ReflectionClass($object))->getShortName();     return (new \ReflectionClass($object))->getShortName();
 +}
 +
 +/**
 + * Get snake_case from UpperCamelCase or lowerCamelCase
 + * @param string $camel
 + * @return string|null
 + */
 +function snake_case(string $camel =null)
 +{
 +    if (!isset($camel)) return null;
 +
 +    $snake = preg_replace('/([A-Z])/', '_$1', $camel);
 +    return ltrim(strtolower($snake), '_');
 +}
 +
 +/**
 + * Get SQL text from a file
 + * @param string $filename
 + * @return array
 + */
 +function file_get_sql(string $filename):array
 +{
 +    if (!file_exists($filename)) return [];
 +
 +    // Read a file
 +    $text = file_get_contents($filename);
 +    $text = str_replace(["\r\n","\r"], "\n", $text);
 +
 +    // Remove comment
 +    $text = preg_replace("/\/\*.*?\*\//s", '', $text);
 +    $text = preg_replace("/--.*?$/m", '', $text);
 +
 +    // Split SQL text
 +    $sql = preg_split("/\s*;\s*/", $text);
 +    array_walk($sql, function(&$item){
 +        $item = trim($item);
 +    });
 +    $sql = array_filter($sql, function($val){
 +        return !empty(trim($val));
 +    });
 +    return $sql;
 } }
 </code> </code>
apricot/core/top.txt · 最終更新: 2020/06/03 10:02 by tanaka