From 0e9c6c7e68f22c6ea5ba7c7f15c328effd62bb11 Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 9 Jul 2025 22:50:19 +0200 Subject: [PATCH 1/2] Add support for 'extras' disk and bundling application resources --- .../docs/desktop/1/digging-deeper/files.md | 53 ++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/resources/views/docs/desktop/1/digging-deeper/files.md b/resources/views/docs/desktop/1/digging-deeper/files.md index 8c5fbc70..fe3c89a3 100644 --- a/resources/views/docs/desktop/1/digging-deeper/files.md +++ b/resources/views/docs/desktop/1/digging-deeper/files.md @@ -53,6 +53,7 @@ Storage::disk('music')->get('file.txt'); Storage::disk('pictures')->get('file.txt'); Storage::disk('videos')->get('file.txt'); Storage::disk('recent')->get('file.txt'); +Storage::disk('extras')->get('file.txt'); ``` 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 We recommend avoiding symlinks within your NativePHP app. Instead, consider either: -- Placing files directly in their intended locations -- Using Laravel's Storage facade to mount directories outside your application +- Placing files directly in their intended locations +- Using Laravel's Storage facade to mount directories outside your application + +## Bundling Application Resources + +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. + +### Adding Files + +To include extra files with your application, place them in the `public/extras/` directory at the root of your Laravel project: + +``` +your-project/ +├── public/ +│ └── extras/ +│ ├── my-tool.sh +│ ├── my-tool.exe +│ └── sample.csv +├── app/ +└── ... +``` + +These files will be automatically bundled with your application during the build process. + +The `extras` disk is read-only. Any files you write to this directory will be overwritten when your application is updated. + +### Accessing Files + +You can access bundled extra files using Laravel's Storage facade with the `extras` disk: + +```php +use Illuminate\Support\Facades\Storage; + +$toolPath = Storage::disk('extras')->path('my-tool.exe'); +``` + +### Using Bundled Tools + +```php +use Illuminate\Support\Facades\Storage; +use Native\Laravel\Facades\ChildProcess; + +// Get the path to a bundled executable +$toolPath = Storage::disk('extras')->path('my-tool.sh'); + +ChildProcess::start( + cmd: $toolPath, + alias: 'my-tool' +); +``` From 9dfca4e0d5afbadb46f241aef0a00942f477afe9 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Fri, 11 Jul 2025 18:31:04 +0100 Subject: [PATCH 2/2] Change path to extras --- .../views/docs/desktop/1/digging-deeper/files.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/resources/views/docs/desktop/1/digging-deeper/files.md b/resources/views/docs/desktop/1/digging-deeper/files.md index fe3c89a3..47fcf7b4 100644 --- a/resources/views/docs/desktop/1/digging-deeper/files.md +++ b/resources/views/docs/desktop/1/digging-deeper/files.md @@ -101,15 +101,14 @@ NativePHP allows you to bundle additional files with your application that can b ### Adding Files -To include extra files with your application, place them in the `public/extras/` directory at the root of your Laravel project: +To include extra files with your application, place them in a `extras/` directory at the root of your Laravel project: ``` your-project/ -├── public/ -│ └── extras/ -│ ├── my-tool.sh -│ ├── my-tool.exe -│ └── sample.csv +├── extras/ +│ ├── my-tool.sh +│ ├── my-tool.exe +│ └── sample.csv ├── app/ └── ... ```