Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion manuals/1.0/en/package.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 19 additions & 0 deletions manuals/1.0/en/production.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 2 additions & 0 deletions manuals/1.0/en/upgrade/injector.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
10 changes: 7 additions & 3 deletions manuals/1.0/ja/aaas.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
```

Expand Down
4 changes: 3 additions & 1 deletion manuals/1.0/ja/package.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`を実行します。
Expand Down
19 changes: 19 additions & 0 deletions manuals/1.0/ja/production.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`よりずっと高速です。
Expand Down
2 changes: 2 additions & 0 deletions manuals/1.0/ja/upgrade/injector.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ final class Injector
}
```

書き込みディレクトリを既定の `var/` 以外にしたい場合だけ、`Meta` を組み立ててパスを渡す形に拡張できます([プロダクション](../production.html#writable-paths))。通常は上記のままで構いません。

### Step 2

`bootstrap.php`を変更します。
Expand Down