Skip to content

Commit 0e9c6c7

Browse files
committed
Add support for 'extras' disk and bundling application resources
1 parent cc081fd commit 0e9c6c7

File tree

1 file changed

+51
-2
lines changed
  • resources/views/docs/desktop/1/digging-deeper

1 file changed

+51
-2
lines changed

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

Lines changed: 51 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,53 @@ 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 the `public/extras/` directory at the root of your Laravel project:
105+
106+
```
107+
your-project/
108+
├── public/
109+
│ └── extras/
110+
│ ├── my-tool.sh
111+
│ ├── my-tool.exe
112+
│ └── sample.csv
113+
├── app/
114+
└── ...
115+
```
116+
117+
These files will be automatically bundled with your application during the build process.
118+
119+
The `extras` disk is read-only. Any files you write to this directory will be overwritten when your application is updated.
120+
121+
### Accessing Files
122+
123+
You can access bundled extra files using Laravel's Storage facade with the `extras` disk:
124+
125+
```php
126+
use Illuminate\Support\Facades\Storage;
127+
128+
$toolPath = Storage::disk('extras')->path('my-tool.exe');
129+
```
130+
131+
### Using Bundled Tools
132+
133+
```php
134+
use Illuminate\Support\Facades\Storage;
135+
use Native\Laravel\Facades\ChildProcess;
136+
137+
// Get the path to a bundled executable
138+
$toolPath = Storage::disk('extras')->path('my-tool.sh');
139+
140+
ChildProcess::start(
141+
cmd: $toolPath,
142+
alias: 'my-tool'
143+
);
144+
```

0 commit comments

Comments
 (0)