diff --git a/manuals/1.0/en/package.md b/manuals/1.0/en/package.md index 346c29c5..1e4d14bc 100644 --- a/manuals/1.0/en/package.md +++ b/manuals/1.0/en/package.md @@ -54,7 +54,9 @@ Web public folder. ### var/ -`log` and `tmp` folder need write permission. +`log` and `tmp` need write permission. By default they are `var/tmp/{context}` and `var/log/{context}`. + +To place them outside the project tree, pass paths to the `Meta` constructor ([Production](production.html#writable-paths)). ## Framework Package diff --git a/manuals/1.0/en/production.md b/manuals/1.0/en/production.md index 4aad829e..512bb914 100644 --- a/manuals/1.0/en/production.md +++ b/manuals/1.0/en/production.md @@ -177,6 +177,25 @@ mv autoload.php api.autoload.php Edit `composer.json` to change the content of `composer compile`. +DI scripts are written under `{tmpDir}/di` (default `tmpDir` is `var/tmp/{context}`). The defaults are fine for most deployments. + +#### Changing writable paths {: #writable-paths } + +Optional. Use only when temporary files or logs should live outside the project tree—for example a read-only app root (some serverless or container layouts), or when build-time and runtime writable paths differ. Ordinary VPS or shared hosting does not need this. + +Pass resolved paths to the `Meta` constructor (interpreting environment variables is an application concern): + +```php +new Meta($name, $context, $appDir, '/var/tmp/my-app', '/var/log/my-app'); +``` + +To compile against the same paths, use `Compiler::fromInjector()` with the application `Injector` (`bear.compile` remains available as before): + +```php +// example bin/compile.php +exit(Compiler::fromInjector(Injector::getInstance($context), $context)()); +``` + ### autoload.php An optimized autoload.php file is output to `{project_path}/autoload.php`. diff --git a/manuals/1.0/en/upgrade/injector.md b/manuals/1.0/en/upgrade/injector.md index b191220d..a8f7bfc4 100644 --- a/manuals/1.0/en/upgrade/injector.md +++ b/manuals/1.0/en/upgrade/injector.md @@ -69,6 +69,8 @@ final class Injector } ``` +Only if writable directories should not use the default `var/` layout, build a `Meta` with explicit paths ([Production](../production.html#writable-paths)). The snippet above is enough for ordinary apps. + ### Step 2 Change the `bootstrap.php`. diff --git a/manuals/1.0/ja/aaas.md b/manuals/1.0/ja/aaas.md index 75e6ac2a..9de4b3a8 100644 --- a/manuals/1.0/ja/aaas.md +++ b/manuals/1.0/ja/aaas.md @@ -119,9 +119,13 @@ use BEAR\Package\Bootstrap; require __DIR__ . '/vendor/autoload.php'; -$meta = new Meta('MyVendor\Ticket', 'app'); -$meta->tmpDir = __DIR__ . '/ticket/tmp'; -$meta->logDir = __DIR__ . '/ticket/log'; +$meta = new Meta( + 'MyVendor\Ticket', + 'app', + '', + __DIR__ . '/ticket/tmp', + __DIR__ . '/ticket/log', +); $ticket = (new Bootstrap)->newApp($meta, 'app'); ``` diff --git a/manuals/1.0/ja/package.md b/manuals/1.0/ja/package.md index 1e0c4131..297ee82d 100644 --- a/manuals/1.0/ja/package.md +++ b/manuals/1.0/ja/package.md @@ -49,9 +49,11 @@ Web公開フォルダです。 ### var/ -`log`、`tmp`フォルダは書き込み可能にします。`var/www`はWebドキュメントの公開エリアです。 +`log`、`tmp`フォルダは書き込み可能にします。既定ではコンテキストごとに `var/tmp/{context}` と `var/log/{context}` が使われます。`var/www`はWebドキュメントの公開エリアです。 `conf`など可変のファイルを設置します。 +書き込み先をプロジェクト外にしたい場合だけ、`Meta` のコンストラクタでパスを上書きできます([プロダクション](production.html#writable-paths))。 + ## 実行シーケンス 1. コンソール入力(`bin/app.php`、`page.php`)またはWebサーバーのエントリーファイル(`public/index.php`)が`bootstrap.php`を実行します。 diff --git a/manuals/1.0/ja/production.md b/manuals/1.0/ja/production.md index 4f1d31c2..84c08cbf 100644 --- a/manuals/1.0/ja/production.md +++ b/manuals/1.0/ja/production.md @@ -169,6 +169,25 @@ mv autoload.php api.autoload.php `composer.json`を編集して`composer compile`の内容を変更します。 +DI スクリプトの出力先は `{tmpDir}/di` です(既定の `tmpDir` は `var/tmp/{context}`)。ほとんどのデプロイではこの既定のままで問題ありません。 + +#### 書き込み先を変える場合 {: #writable-paths } + +プロジェクトツリー外に一時ファイルやログを置きたいときだけ使います(任意)。例としては、アプリ本体が読み取り専用のホスト(一部の serverless / コンテナ構成)や、ビルド時と実行時で書き込みパスが分かれる場合です。通常の VPS や共有ホストでは不要です。 + +`Meta` のコンストラクタに解決済みのパスを渡せます(環境変数の解釈はアプリ側の都合です)。 + +```php +new Meta($name, $context, $appDir, '/var/tmp/my-app', '/var/log/my-app'); +``` + +コンパイルも同じパスにしたい場合は、アプリの `Injector` が組み立てた Meta をそのまま使う `Compiler::fromInjector()` があります(`bear.compile` は従来どおり使えます)。 + +```php +// bin/compile.php の例 +exit(Compiler::fromInjector(Injector::getInstance($context), $context)()); +``` + ### autoload.php `{project_path}/autoload.php`に最適化されたautoload.phpファイルが出力されます。`composer dump-autoload --optimize`で出力される`vendor/autoload.php`よりずっと高速です。 diff --git a/manuals/1.0/ja/upgrade/injector.md b/manuals/1.0/ja/upgrade/injector.md index 5f5dc5d7..c2b9ef81 100644 --- a/manuals/1.0/ja/upgrade/injector.md +++ b/manuals/1.0/ja/upgrade/injector.md @@ -69,6 +69,8 @@ final class Injector } ``` +書き込みディレクトリを既定の `var/` 以外にしたい場合だけ、`Meta` を組み立ててパスを渡す形に拡張できます([プロダクション](../production.html#writable-paths))。通常は上記のままで構いません。 + ### Step 2 `bootstrap.php`を変更します。