Skip to content

Commit 53762f6

Browse files
committed
update namespaces to Native\Desktop
1 parent 26e539e commit 53762f6

26 files changed

+247
-198
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ NativePHP injects a `window.Native` object into every window. The `on()` method
4646
the second parameter that will run when the event specified in the first parameter is fired:
4747

4848
```js
49-
Native.on("Native\\Laravel\\Events\\Windows\\WindowBlurred", (payload, event) => {
50-
//
51-
});
49+
Native.on(
50+
'Native\\Desktop\\Events\\Windows\\WindowBlurred',
51+
(payload, event) => {
52+
//
53+
},
54+
)
5255
```
5356

5457
## Listening with Livewire
@@ -64,13 +67,13 @@ class AppSettings extends Component
6467
{
6568
public $windowFocused = true;
6669

67-
#[On('native:\\Native\\Laravel\\Events\\Windows\\WindowFocused')]
70+
#[On('native:\\Native\\Desktop\\Events\\Windows\\WindowFocused')]
6871
public function windowFocused()
6972
{
7073
$this->windowFocused = true;
7174
}
7275

73-
#[On('native:\\Native\\Laravel\\Events\\Windows\\WindowBlurred')]
76+
#[On('native:\\Native\\Desktop\\Events\\Windows\\WindowBlurred')]
7477
public function windowBlurred()
7578
{
7679
$this->windowFocused = false;
@@ -81,8 +84,8 @@ class AppSettings extends Component
8184
You may find it more convenient to use PHP's class name resolution keyword, `::class`:
8285

8386
```php
84-
use Native\Laravel\Events\Windows\WindowBlurred;
85-
use Native\Laravel\Events\Windows\WindowFocused;
87+
use Native\Desktop\Events\Windows\WindowBlurred;
88+
use Native\Desktop\Events\Windows\WindowFocused;
8689

8790
class AppSettings extends Component
8891
{

resources/views/docs/desktop/2/digging-deeper/child-processes.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ only be able to run while your application is running.**
6262

6363
PHP has good built-in support for running arbitrary programs in separate processes. For example:
6464

65-
- [`shell_exec`](https://www.php.net/manual/en/function.shell-exec.php) allows you to run commands and return their
66-
output to your application.
67-
- [`proc_open`](https://www.php.net/manual/en/function.proc-open.php) allows you to spin up a command with more control
68-
over how its input and output streams are handled.
65+
- [`shell_exec`](https://www.php.net/manual/en/function.shell-exec.php) allows you to run commands and return their
66+
output to your application.
67+
- [`proc_open`](https://www.php.net/manual/en/function.proc-open.php) allows you to spin up a command with more control
68+
over how its input and output streams are handled.
6969

7070
While these can be used in your NativePHP application, consider that they:
7171

72-
- May block the script that is executing them until the sub-process has finished.
73-
- May become orphaned from your application, allowing them to continue running after your app has quit.
72+
- May block the script that is executing them until the sub-process has finished.
73+
- May become orphaned from your application, allowing them to continue running after your app has quit.
7474

7575
Runaway orphaned processes could negatively impact your user's system and can become tricky to manage without user
7676
intervention. You should be cautious about starting processes this way.
@@ -85,15 +85,15 @@ throughout your application.
8585
You may start a process using the `ChildProcess` facade:
8686

8787
```php
88-
use Native\Laravel\Facades\ChildProcess;
88+
use Native\Desktop\Facades\ChildProcess;
8989

9090
ChildProcess::start(
9191
cmd: 'tail -f storage/logs/laravel.log',
9292
alias: 'tail'
9393
);
9494
```
9595

96-
The `start` method will return a `Native\Laravel\ChildProcess` instance, which represents the process. You may interact
96+
The `start` method will return a `Native\Desktop\ChildProcess` instance, which represents the process. You may interact
9797
directly with this instance to make changes to that process, but this does not necessarily mean that the
9898
process was started.
9999

@@ -157,7 +157,7 @@ You can use the `ChildProcess` facade's `get` method to get a running process wi
157157
$tail = ChildProcess::get('tail');
158158
```
159159

160-
This will return a `Native\Laravel\ChildProcess` instance.
160+
This will return a `Native\Desktop\ChildProcess` instance.
161161

162162
### Getting all processes
163163

@@ -167,14 +167,14 @@ You can use the `ChildProcess` facade's `all` method to get all running processe
167167
$processes = ChildProcess::all();
168168
```
169169

170-
This will return an array of `Native\Laravel\ChildProcess` instances.
170+
This will return an array of `Native\Desktop\ChildProcess` instances.
171171

172172
## Stopping a Child Process
173173

174174
Your child processes will shut down when your application exits. However, you may also choose to stop them manually or
175175
provide this control to your user.
176176

177-
If you have a `Native\Laravel\ChildProcess` instance, you may call the `stop` method on it:
177+
If you have a `Native\Desktop\ChildProcess` instance, you may call the `stop` method on it:
178178

179179
```php
180180
$tail->stop();
@@ -196,7 +196,7 @@ Note that [persistent processes](/docs/digging-deeper/child-processes#persistent
196196
As a convenience, you may simply restart a Child Process using the `restart` method. This may be useful in cases where
197197
the program has become unresponsive and you simply need to "reboot" it.
198198

199-
If you have a `Native\Laravel\ChildProcess` instance, you may call the `restart` method on it:
199+
If you have a `Native\Desktop\ChildProcess` instance, you may call the `restart` method on it:
200200

201201
```php
202202
$tail->restart();
@@ -212,10 +212,10 @@ ChildProcess::restart('tail');
212212

213213
There are multiple ways to provide input to your Child Process:
214214

215-
- The environment.
216-
- Arguments to the command.
217-
- Its standard input stream (`STDIN`).
218-
- A custom interface, e.g. a network socket.
215+
- The environment.
216+
- Arguments to the command.
217+
- Its standard input stream (`STDIN`).
218+
- A custom interface, e.g. a network socket.
219219

220220
Which you use will depend on what the program is capable of handling.
221221

@@ -266,10 +266,10 @@ The message format and how they are handled will be determined by the program yo
266266

267267
A Child Process may send output via any of the following interfaces:
268268

269-
- Its standard output stream (`STDOUT`).
270-
- Its standard error stream (`STDERR`).
271-
- A custom interface, e.g. a network socket.
272-
- Broadcasting a Custom Event
269+
- Its standard output stream (`STDOUT`).
270+
- Its standard error stream (`STDERR`).
271+
- A custom interface, e.g. a network socket.
272+
- Broadcasting a Custom Event
273273

274274
`STDOUT`, `STDERR` & [Custom Events](/docs/digging-deeper/broadcasting#custom-events) are dispatched using
275275
Laravel's event system.
@@ -297,7 +297,7 @@ All events get dispatched as regular Laravel events, so you may use your `AppSer
297297

298298
```php
299299
use Illuminate\Support\Facades\Event;
300-
use Native\Laravel\Events\ChildProcess\MessageReceived;
300+
use Native\Desktop\Events\ChildProcess\MessageReceived;
301301

302302
/**
303303
* Bootstrap any application services.
@@ -317,37 +317,37 @@ Sometimes you may want to listen and react to these events in real-time, which i
317317
Child Process events to the `nativephp` broadcast channel. Any events broadcasted this way also get dispatched over IPC, enabling you to react to them on the front-end without using websockets.
318318

319319
```js
320-
Native.on("Native\\Laravel\\Events\\ChildProcess\\MessageReceived", (event) => {
321-
if (event.alias === "tail") {
322-
container.append(event.data);
320+
Native.on('Native\\Desktop\\Events\\ChildProcess\\MessageReceived', (event) => {
321+
if (event.alias === 'tail') {
322+
container.append(event.data)
323323
}
324-
});
324+
})
325325
```
326326

327327
To learn more about NativePHP's broadcasting capabilities, please refer to the
328328
[Broadcasting](/docs/digging-deeper/broadcasting) section.
329329

330330
### `ProcessSpawned`
331331

332-
This `Native\Laravel\Events\ChildProcess\ProcessSpawned` event will be dispatched when a Child Process has successfully
332+
This `Native\Desktop\Events\ChildProcess\ProcessSpawned` event will be dispatched when a Child Process has successfully
333333
been spawned. The payload of the event contains the `$alias` and the `$pid` of the process.
334334

335335
**In Electron, the `$pid` here will be the Process ID of an Electron Helper process which spawns the underlying
336336
process.**
337337

338338
### `ProcessExited`
339339

340-
This `Native\Laravel\Events\ChildProcess\ProcessExited` event will be dispatched when a Child Process exits. The
340+
This `Native\Desktop\Events\ChildProcess\ProcessExited` event will be dispatched when a Child Process exits. The
341341
payload of the event contains the `$alias` of the process and its exit `$code`.
342342

343343
### `MessageReceived`
344344

345-
This `Native\Laravel\Events\ChildProcess\MessageReceived` event will be dispatched when the Child Process emits some
345+
This `Native\Desktop\Events\ChildProcess\MessageReceived` event will be dispatched when the Child Process emits some
346346
output via its standard output stream (`STDOUT`). The payload of the event contains the `$alias` of the process and the
347347
message `$data`.
348348

349349
### `ErrorReceived`
350350

351-
This `Native\Laravel\Events\ChildProcess\ErrorReceived` event will be dispatched when the Child Process emits an error
351+
This `Native\Desktop\Events\ChildProcess\ErrorReceived` event will be dispatched when the Child Process emits an error
352352
via its standard error stream (`STDERR`). The payload of the event contains the `$alias` of the process and the
353353
error `$data`.

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,29 @@
22
title: Queues
33
order: 500
44
---
5+
56
# Queues
67

78
Queueing tasks to be run in the background is a critical part of creating a great user experience.
89

910
NativePHP has built-in support for Laravel's [Queues](https://laravel.com/docs/queues).
1011

1112
## Queueing a job
13+
1214
If you're familiar with queueing jobs in Laravel, you should feel right at home. There's nothing special you need to do.
1315

1416
Jobs live in the SQLite [database](/docs/digging-deeper/databases) that your app uses by default and the `jobs` table
1517
migration will have been created and migrated for you.
1618

1719
## Processing Jobs / Working the Queue
20+
1821
By default, NativePHP will boot up a single queue worker which will consume jobs from the `default` queue.
1922

2023
If you wish to modify the configuration of this worker or run more workers, see [Configuring workers](#configuring-workers).
2124

2225
### Configuring workers
23-
Once you publish the NativePHP config file using `php artisan vendor:publish`, you will find a `queue_workers` key in
26+
27+
Once you publish the NativePHP config file using `php artisan vendor:publish`, you will find a `queue_workers` key in
2428
`config/nativephp.php`. Here are some acceptable values to get you started:
2529

2630
```php
@@ -65,7 +69,7 @@ and stop workers, should you need to.
6569

6670
```php
6771
use Native\DTOs\QueueConfig;
68-
use Native\Laravel\Facades\QueueWorker;
72+
use Native\Desktop\Facades\QueueWorker;
6973

7074
$queueConfig = new QueueConfig(alias: 'manual', queuesToConsume: ['default'], memoryLimit: 1024, timeout: 600);
7175

@@ -79,6 +83,7 @@ QueueWorker::down(alias: 'manual');
7983
```
8084

8185
## When to Queue
86+
8287
Given that your database and application typically exist on the same machine (i.e. there's no network involved),
8388
queueing background tasks can mostly be left for very intense operations and when making API calls over the network.
8489

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ title: Configuration
33
order: 200
44
---
55

6-
7-
The `native:install` command publishes a configuration file to `config/nativephp.php`.
6+
The `native:install` command publishes a configuration file to `config/nativephp.php`.
87
This file contains all the configuration options for NativePHP.
98

109
## Default Configuration File
@@ -40,12 +39,12 @@ return [
4039
* The author of your application.
4140
*/
4241
'author' => env('NATIVEPHP_APP_AUTHOR'),
43-
42+
4443
/**
4544
* The copyright notice for your application.
4645
*/
4746
'copyright' => env('NATIVEPHP_APP_COPYRIGHT'),
48-
47+
4948
/**
5049
* The description of your application.
5150
*/
@@ -152,8 +151,8 @@ This method should return an array of php.ini directives to be set.
152151
```php
153152
namespace App\Providers;
154153

155-
use Native\Laravel\Facades\Window;
156-
use Native\Laravel\Contracts\ProvidesPhpIni;
154+
use Native\Desktop\Facades\Window;
155+
use Native\Desktop\Contracts\ProvidesPhpIni;
157156

158157
class NativeAppServiceProvider implements ProvidesPhpIni
159158
{

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ How to setup your storage and generate the relevant API credentials:
8282
- Amazon S3 - See [this video](https://www.youtube.com/watch?v=FLIp6BLtwjk&ab_channel=CloudCasts) by Chris Fidao or
8383
this [Step 2](https://www.twilio.com/docs/video/tutorials/storing-aws-s3#step-2) of this article by Twilio
8484

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.
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.
8888

8989
## Disabling the updater
9090

@@ -100,7 +100,7 @@ NATIVEPHP_UPDATER_ENABLED=false
100100
You can manually check for updates by calling the `checkForUpdates` method on the `AutoUpdater` facade:
101101

102102
```php
103-
use Native\Laravel\Facades\AutoUpdater;
103+
use Native\Desktop\Facades\AutoUpdater;
104104

105105
AutoUpdater::checkForUpdates();
106106
```
@@ -113,7 +113,7 @@ will download the update two times.
113113
You can quit the application and install the update by calling the `quitAndInstall` method on the `AutoUpdater` facade:
114114

115115
```php
116-
use Native\Laravel\Facades\AutoUpdater;
116+
use Native\Desktop\Facades\AutoUpdater;
117117

118118
AutoUpdater::quitAndInstall();
119119
```
@@ -127,21 +127,21 @@ application starts.
127127

128128
### `CheckingForUpdate`
129129

130-
The `Native\Laravel\Events\AutoUpdater\CheckingForUpdate` event is dispatched when checking for an available update has
130+
The `Native\Desktop\Events\AutoUpdater\CheckingForUpdate` event is dispatched when checking for an available update has
131131
started.
132132

133133
### `UpdateAvailable`
134134

135-
The `Native\Laravel\Events\AutoUpdater\UpdateAvailable` event is dispatched when there is an available update. The
135+
The `Native\Desktop\Events\AutoUpdater\UpdateAvailable` event is dispatched when there is an available update. The
136136
update is downloaded automatically.
137137

138138
### `UpdateNotAvailable`
139139

140-
The `Native\Laravel\Events\AutoUpdater\UpdateNotAvailable` event is dispatched when there is no available update.
140+
The `Native\Desktop\Events\AutoUpdater\UpdateNotAvailable` event is dispatched when there is no available update.
141141

142142
### `DownloadProgress`
143143

144-
The `Native\Laravel\Events\AutoUpdater\DownloadProgress` event is dispatched when the update is being downloaded.
144+
The `Native\Desktop\Events\AutoUpdater\DownloadProgress` event is dispatched when the update is being downloaded.
145145

146146
The event contains the following properties:
147147

@@ -153,7 +153,7 @@ The event contains the following properties:
153153

154154
### `UpdateDownloaded`
155155

156-
The `Native\Laravel\Events\AutoUpdater\UpdateDownloaded` event is dispatched when the update has been downloaded.
156+
The `Native\Desktop\Events\AutoUpdater\UpdateDownloaded` event is dispatched when the update has been downloaded.
157157

158158
The event contains the following properties:
159159

@@ -165,7 +165,7 @@ The event contains the following properties:
165165

166166
### `Error`
167167

168-
The `Native\Laravel\Events\AutoUpdater\Error` event is dispatched when there is an error while updating.
168+
The `Native\Desktop\Events\AutoUpdater\Error` event is dispatched when there is an error while updating.
169169

170170
The event contains the following properties:
171171

resources/views/docs/desktop/2/testing/basics.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
title: Basics
33
order: 99
44
---
5+
56
# Understanding fake test doubles
7+
68
When working with a NativePHP application, you may encounter an elevated level of difficulty when writing tests for your code.
79
This is because NativePHP relies on an Electron/Tauri application to be open at all times, listening to HTTP requests. Obviously,
810
emulating this in a test environment can be cumbersome. You will often hit an HTTP error, and this is normal. This is where
911
NativePHP's fake test doubles come in.
1012

1113
```php
12-
use Native\Laravel\Facades\Window;
14+
use Native\Desktop\Facades\Window;
1315

1416
#[\PHPUnit\Framework\Attributes\Test]
1517
public function example(): void
@@ -26,5 +28,5 @@ public function example(): void
2628

2729
If you've ever written tests for a Laravel application, you may have seen the `*::fake()` method available on
2830
all sorts of facades. Under the hood, these methods are swapping the real implementation and behavior – in NativePHP's case,
29-
an HTTP call that forces us to keep the server up and running, in turn degrading the ability to write expressive tests – with a fake one
31+
an HTTP call that forces us to keep the server up and running, in turn degrading the ability to write expressive tests – with a fake one
3032
that follows the same API. This means you do not have to change any of your code to write great tests.

0 commit comments

Comments
 (0)