File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
resources/views/docs/1/digging-deeper Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ title : Queues
3
+ order : 500
4
+ ---
5
+ # Queues
6
+
7
+ Queueing tasks to be run in the background is a critical part of creating a great user experience.
8
+
9
+ NativePHP has built-in support for Laravel's [ Queues] ( https://laravel.com/docs/queues ) .
10
+
11
+ ## Queueing a job
12
+ If you're familiar with queueing jobs in Laravel, you should feel right at home. There's nothing special you need to do.
13
+
14
+ Jobs live in the SQLite [ database] ( /docs/digging-deeper/databases ) that your app uses by default and the ` jobs ` table
15
+ migration will have been created and migrated for you.
16
+
17
+ ## Processing Jobs / Working the Queue
18
+ When your application boots up, NativePHP starts a single queue worker, ready to process any jobs you send its way.
19
+
20
+ There's nothing more required.
21
+
22
+ In the context of your user's device, it's very rare that you would need multiple queues or many workers, as your
23
+ application is likely to only be used by one user at a time.
24
+
25
+ ## When to Queue
26
+ Given that your database and application typically exist on the same machine (i.e. there's no network involved),
27
+ queueing background tasks can mostly be left for very intense operations and when making API calls over the network.
28
+
29
+ Even so, you may find it more user-friendly to have slow tasks complete in the main application thread. You may simply
30
+ choose to have your UI indicate that something is occurring (e.g. with a loading spinner) while the user waits for the
31
+ process to finish.
32
+
33
+ This may be clearer for the user and easier to handle in case issues arise, as you can provide visual feedback to the
34
+ user and they can try again more easily.
You can’t perform that action at this time.
0 commit comments