Skip to content

Commit 1ee78d6

Browse files
authored
Merge pull request #181 from NativePHP/add-extra-files
Add docs for 'extras' disk and bundling application resources
2 parents 0afd89b + b5d6464 commit 1ee78d6

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

resources/views/docs/desktop/1/digging-deeper/files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ However, in a NativePHP app, this approach is less applicable. The entire applic
9292
We recommend avoiding symlinks within your NativePHP app. Instead, consider either:
9393

9494
- Placing files directly in their intended locations
95-
- Using Laravel's Storage facade to mount directories outside your application
95+
- Using Laravel's Storage facade to mount directories outside your application

resources/views/docs/desktop/2/digging-deeper/files.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Storage::disk('music')->get('file.txt');
5353
Storage::disk('pictures')->get('file.txt');
5454
Storage::disk('videos')->get('file.txt');
5555
Storage::disk('recent')->get('file.txt');
56+
Storage::disk('extras')->get('file.txt');
5657
```
5758

5859
Note that the PHP process which runs your application operates with the same privileges as the logged-in user, this
@@ -91,5 +92,52 @@ However, in a NativePHP app, this approach is less applicable. The entire applic
9192

9293
We recommend avoiding symlinks within your NativePHP app. Instead, consider either:
9394

94-
- Placing files directly in their intended locations
95-
- Using Laravel's Storage facade to mount directories outside your application
95+
- Placing files directly in their intended locations
96+
- Using Laravel's Storage facade to mount directories outside your application
97+
98+
## Bundling Application Resources
99+
100+
NativePHP allows you to bundle additional files with your application that can be accessed at runtime. This is useful for including pre-compiled executables or other resources that need to be distributed with your app.
101+
102+
### Adding Files
103+
104+
To include extra files with your application, place them in a `extras/` directory at the root of your Laravel project:
105+
106+
```
107+
your-project/
108+
├── extras/
109+
│ ├── my-tool.sh
110+
│ ├── my-tool.exe
111+
│ └── sample.csv
112+
├── app/
113+
└── ...
114+
```
115+
116+
These files will be automatically bundled with your application during the build process.
117+
118+
The `extras` disk is read-only. Any files you write to this directory will be overwritten when your application is updated.
119+
120+
### Accessing Files
121+
122+
You can access bundled extra files using Laravel's Storage facade with the `extras` disk:
123+
124+
```php
125+
use Illuminate\Support\Facades\Storage;
126+
127+
$toolPath = Storage::disk('extras')->path('my-tool.exe');
128+
```
129+
130+
### Using Bundled Tools
131+
132+
```php
133+
use Illuminate\Support\Facades\Storage;
134+
use Native\Desktop\Facades\ChildProcess;
135+
136+
// Get the path to a bundled executable
137+
$toolPath = Storage::disk('extras')->path('my-tool.sh');
138+
139+
ChildProcess::start(
140+
cmd: $toolPath,
141+
alias: 'my-tool'
142+
);
143+
```

0 commit comments

Comments
 (0)