Skip to content

Commit c076b92

Browse files
authored
Add new updater docs, config options, and app relaunch feature (#112)
Expanded documentation for the auto-updater, including events, manual updates, and usage instructions. Introduced new configuration fields for app description and website. Added support for relaunching the application with the `App::relaunch()` method.
1 parent 594e5ac commit c076b92

File tree

3 files changed

+105
-6
lines changed

3 files changed

+105
-6
lines changed

resources/views/docs/desktop/1/getting-started/configuration.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ return [
4545
* The copyright notice for your application.
4646
*/
4747
'copyright' => env('NATIVEPHP_APP_COPYRIGHT'),
48+
49+
/**
50+
* The description of your application.
51+
*/
52+
'description' => env('NATIVEPHP_APP_DESCRIPTION', 'An awesome app built with NativePHP'),
53+
54+
/**
55+
* The Website of your application.
56+
*/
57+
'website' => env('NATIVEPHP_APP_WEBSITE', 'https://nativephp.com'),
4858

4959
/**
5060
* The default service provider for your application. This provider

resources/views/docs/desktop/1/publishing/updating.md

Lines changed: 88 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
title: Updating
33
order: 300
44
---
5+
56
## The Updater
7+
68
NativePHP ships with a built-in auto-update tool, which allows your users to update your application without needing to
79
manually download and install new releases.
810

911
This leaves you to focus on building and releasing new versions of your application, without needing to worry about
1012
distributing those updates to your users.
1113

1214
**macOS: Automatic updating is only supported for [signed](/docs/publishing/building#signing-and-notarizing)
13-
applications.**
15+
applications.**
1416

1517
## How it works
18+
1619
The updater works by checking a remote URL for a new version of your application. If a new version is found, the updater
1720
will download the new version and replace the existing application files with the new ones.
1821

@@ -27,9 +30,10 @@ The updater supports three providers:
2730

2831
You can configure all settings for the updater in your `config/nativephp.php` file or via your `.env` file.
2932

30-
**The updater will only run when your app is running in production mode.**
33+
**The updater will only run when your app is running in production mode.**
3134

3235
## Configuration
36+
3337
The default updater configuration looks like this:
3438

3539
```php
@@ -73,12 +77,14 @@ The default updater configuration looks like this:
7377
```
7478

7579
How to setup your storage and generate the relevant API credentials:
80+
7681
- [DigitalOcean](https://docs.digitalocean.com/products/spaces/how-to/manage-access/)
77-
- Amazon S3 - See [this video](https://www.youtube.com/watch?v=FLIp6BLtwjk&ab_channel=CloudCasts) by Chris Fidao or
78-
this [Step 2](https://www.twilio.com/docs/video/tutorials/storing-aws-s3#step-2) of this article by Twilio
82+
- Amazon S3 - See [this video](https://www.youtube.com/watch?v=FLIp6BLtwjk&ab_channel=CloudCasts) by Chris Fidao or
83+
this [Step 2](https://www.twilio.com/docs/video/tutorials/storing-aws-s3#step-2) of this article by Twilio
7984

80-
If you got the error message "The bucket does not allow ACLs" you can follow this guide from [Learn AWS](https://www.learnaws.org/2023/08/26/aws-s3-bucket-does-not-allow-acls)
81-
on how to setup your bucket correctly.
85+
If you got the error message "The bucket does not allow ACLs" you can follow this guide
86+
from [Learn AWS](https://www.learnaws.org/2023/08/26/aws-s3-bucket-does-not-allow-acls)
87+
on how to setup your bucket correctly.
8288

8389
## Disabling the updater
8490

@@ -88,3 +94,79 @@ If you don't want your application to check for updates, you can disable the upd
8894
```dotenv
8995
NATIVEPHP_UPDATER_ENABLED=false
9096
```
97+
98+
## Manually checking for updates
99+
100+
You can manually check for updates by calling the `checkForUpdates` method on the `AutoUpdater` facade:
101+
102+
```php
103+
use Native\Laravel\Facades\AutoUpdater;
104+
105+
AutoUpdater::checkForUpdates();
106+
```
107+
108+
**Note:** If an update is available, it will be downloaded automatically. Calling `AutoUpdater::checkForUpdates() twice
109+
will download the update two times.
110+
111+
## Quit and Install
112+
113+
You can quit the application and install the update by calling the `quitAndInstall` method on the `AutoUpdater` facade:
114+
115+
```php
116+
use Native\Laravel\Facades\AutoUpdater;
117+
118+
AutoUpdater::quitAndInstall();
119+
```
120+
121+
This will quit the application and install the update. The application will then relaunch automatically.
122+
123+
**Note:** Calling this method is optional — any successfully downloaded update will be applied the next time the
124+
application starts.
125+
126+
## Events
127+
128+
### `CheckingForUpdate`
129+
130+
The `Native\Laravel\Events\AutoUpdater\CheckingForUpdate` event is dispatched when checking for an available update has
131+
started.
132+
133+
### `UpdateAvailable`
134+
135+
The `Native\Laravel\Events\AutoUpdater\UpdateAvailable` event is dispatched when there is an available update. The
136+
update is downloaded automatically.
137+
138+
### `UpdateNotAvailable`
139+
140+
The `Native\Laravel\Events\AutoUpdater\UpdateNotAvailable` event is dispatched when there is no available update.
141+
142+
### `DownloadProgress`
143+
144+
The `Native\Laravel\Events\AutoUpdater\DownloadProgress` event is dispatched when the update is being downloaded.
145+
146+
The event contains the following properties:
147+
148+
- `total`: The total size of the update in bytes.
149+
- `delta`: The size of the update that has been downloaded since the last event.
150+
- `transferred`: The total size of the update that has been downloaded.
151+
- `percent`: The percentage of the update that has been downloaded (0-100).
152+
- `bytesPerSecond`: The download speed in bytes per second.
153+
154+
### `UpdateDownloaded`
155+
156+
The `Native\Laravel\Events\AutoUpdater\UpdateDownloaded` event is dispatched when the update has been downloaded.
157+
158+
The event contains the following properties:
159+
160+
- `version`: The version of the update.
161+
- `downloadedFile`: The local path to the downloaded update file.
162+
- `releaseDate`: The release date of the update in ISO 8601 format.
163+
- `releaseNotes`: The release notes of the update.
164+
- `releaseName`: The name of the update.
165+
166+
### `Error`
167+
168+
The `Native\Laravel\Events\AutoUpdater\Error` event is dispatched when there is an error while updating.
169+
170+
The event contains the following properties:
171+
172+
- `error`: The error message.

resources/views/docs/desktop/1/the-basics/application.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ To quit the app, use the `quit` method:
2323
App::quit();
2424
```
2525

26+
### Relaunch the app
27+
To relaunch the app, use the `relaunch` method. This will quit the app and relaunch it.
28+
29+
```php
30+
App::relaunch();
31+
```
32+
2633
### Focus the app
2734

2835
To focus the app, use the `focus` method.

0 commit comments

Comments
 (0)