Skip to content

Commit 1d3802c

Browse files
authored
Merge pull request #31 from mirchaemanuel/patch-2
view.php config for production environment
2 parents 0807a4c + 001b19a commit 1d3802c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

view.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,33 @@ View::make('view.name', ['foo' => 'bar']);
2424
view('view-name', ['foo' => 'bar']);
2525
```
2626

27+
<a name="views-in-production"></a>
28+
## Using views in production
29+
30+
In order to use Blade views in production, a `view.php` file must be added in the `config` directory to specify the path where the compiled views should be stored.
31+
32+
For example:
33+
```php
34+
<?php
35+
36+
return [
37+
'paths' => [
38+
resource_path('views'),
39+
],
40+
'compiled' => \Phar::running()
41+
? getcwd()
42+
: env('VIEW_COMPILED_PATH', realpath(storage_path('framework/views'))),
43+
];
44+
```
45+
46+
An alternative to using the current working directory is to use the system temporary directory with `sys_get_temp_dir()`, but any path can be specified, such as a custom location in the user's home directory.
47+
48+
The `resources` directory must also be added to the `box.json` file to include it in the compiled PHAR file:
49+
```json
50+
"directories": [
51+
// ...
52+
"resources"
53+
],
54+
```
55+
2756
Full details on using the View component is available on the [main Laravel documentation](https://laravel.com/docs/views).

0 commit comments

Comments
 (0)