You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: artisan.md
+48-20
Original file line number
Diff line number
Diff line change
@@ -27,18 +27,24 @@
27
27
28
28
Artisan is the command line interface included with Laravel. Artisan exists at the root of your application as the `artisan` script and provides a number of helpful commands that can assist you while you build your application. To view a list of all available Artisan commands, you may use the `list` command:
29
29
30
-
php artisan list
30
+
```shell
31
+
php artisan list
32
+
```
31
33
32
34
Every command also includes a "help" screen which displays and describes the command's available arguments and options. To view a help screen, precede the name of the command with `help`:
33
35
34
-
php artisan help migrate
36
+
```shell
37
+
php artisan help migrate
38
+
```
35
39
36
40
<aname="laravel-sail"></a>
37
41
#### Laravel Sail
38
42
39
43
If you are using [Laravel Sail](/docs/{{version}}/sail) as your local development environment, remember to use the `sail` command line to invoke Artisan commands. Sail will execute your Artisan commands within your application's Docker containers:
40
44
41
-
./sail artisan list
45
+
```shell
46
+
./sail artisan list
47
+
```
42
48
43
49
<aname="tinker"></a>
44
50
### Tinker (REPL)
@@ -50,7 +56,9 @@ Laravel Tinker is a powerful REPL for the Laravel framework, powered by the [Psy
50
56
51
57
All Laravel applications include Tinker by default. However, you may install Tinker using Composer if you have previously removed it from your application:
52
58
53
-
composer require laravel/tinker
59
+
```shell
60
+
composer require laravel/tinker
61
+
```
54
62
55
63
> {tip} Looking for a graphical UI for interacting with your Laravel application? Check out [Tinkerwell](https://tinkerwell.app)!
56
64
@@ -59,11 +67,15 @@ All Laravel applications include Tinker by default. However, you may install Tin
59
67
60
68
Tinker allows you to interact with your entire Laravel application on the command line, including your Eloquent models, jobs, events, and more. To enter the Tinker environment, run the `tinker` Artisan command:
61
69
62
-
php artisan tinker
70
+
```shell
71
+
php artisan tinker
72
+
```
63
73
64
74
You can publish Tinker's configuration file using the `vendor:publish` command:
> {note} The `dispatch` helper function and `dispatch` method on the `Dispatchable` class depends on garbage collection to place the job on the queue. Therefore, when using tinker, you should use `Bus::dispatch` or `Queue::push` to dispatch jobs.
69
81
@@ -95,7 +107,9 @@ In addition to the commands provided with Artisan, you may build your own custom
95
107
96
108
To create a new command, you may use the `make:command` Artisan command. This command will create a new command class in the `app/Console/Commands` directory. Don't worry if this directory does not exist in your application - it will be created the first time you run the `make:command` Artisan command:
97
109
98
-
php artisan make:command SendEmails
110
+
```shell
111
+
php artisan make:command SendEmails
112
+
```
99
113
100
114
<aname="command-structure"></a>
101
115
### Command Structure
@@ -216,10 +230,10 @@ All user supplied arguments and options are wrapped in curly braces. In the foll
216
230
You may also make arguments optional or define default values for arguments:
217
231
218
232
// Optional argument...
219
-
mail:send {user?}
233
+
'mail:send {user?}'
220
234
221
235
// Optional argument with default value...
222
-
mail:send {user=foo}
236
+
'mail:send {user=foo}'
223
237
224
238
<aname="options"></a>
225
239
### Options
@@ -235,7 +249,9 @@ Options, like arguments, are another form of user input. Options are prefixed by
235
249
236
250
In this example, the `--queue` switch may be specified when calling the Artisan command. If the `--queue` switch is passed, the value of the option will be `true`. Otherwise, the value will be `false`:
237
251
238
-
php artisan mail:send 1 --queue
252
+
```shell
253
+
php artisan mail:send 1 --queue
254
+
```
239
255
240
256
<aname="options-with-values"></a>
241
257
#### Options With Values
@@ -251,46 +267,56 @@ Next, let's take a look at an option that expects a value. If the user must spec
251
267
252
268
In this example, the user may pass a value for the option like so. If the option is not specified when invoking the command, its value will be `null`:
253
269
254
-
php artisan mail:send 1 --queue=default
270
+
```shell
271
+
php artisan mail:send 1 --queue=default
272
+
```
255
273
256
274
You may assign default values to options by specifying the default value after the option name. If no option value is passed by the user, the default value will be used:
257
275
258
-
mail:send {user} {--queue=default}
276
+
'mail:send {user} {--queue=default}'
259
277
260
278
<aname="option-shortcuts"></a>
261
279
#### Option Shortcuts
262
280
263
281
To assign a shortcut when defining an option, you may specify it before the option name and use the `|` character as a delimiter to separate the shortcut from the full option name:
264
282
265
-
mail:send {user} {--Q|queue}
283
+
'mail:send {user} {--Q|queue}'
266
284
267
285
When invoking the command on your terminal, option shortcuts should be prefixed with a single hyphen:
268
286
269
-
php artisan mail:send 1 -Q
287
+
```shell
288
+
php artisan mail:send 1 -Q
289
+
```
270
290
271
291
<aname="input-arrays"></a>
272
292
### Input Arrays
273
293
274
294
If you would like to define arguments or options to expect multiple input values, you may use the `*` character. First, let's take a look at an example that specifies such an argument:
275
295
276
-
mail:send {user*}
296
+
'mail:send {user*}'
277
297
278
298
When calling this method, the `user` arguments may be passed in order to the command line. For example, the following command will set the value of `user` to an array with `foo` and `bar` as its values:
279
299
280
-
php artisan mail:send foo bar
300
+
```shell
301
+
php artisan mail:send foo bar
302
+
```
281
303
282
304
This `*` character can be combined with an optional argument definition to allow zero or more instances of an argument:
283
305
284
-
mail:send {user?*}
306
+
'mail:send {user?*}'
285
307
286
308
<aname="option-arrays"></a>
287
309
#### Option Arrays
288
310
289
311
When defining an option that expects multiple input values, each option value passed to the command should be prefixed with the option name:
290
312
291
-
mail:send {user} {--id=*}
313
+
'mail:send {user} {--id=*}'
292
314
293
-
php artisan mail:send --id=1 --id=2
315
+
Such a command may be invoked by passing multiple `--id` arguments:
316
+
317
+
```shell
318
+
php artisan mail:send --id=1 --id=2
319
+
```
294
320
295
321
<aname="input-descriptions"></a>
296
322
### Input Descriptions
@@ -642,7 +668,9 @@ As you might expect, the `getSubscribedSignals` method should return an array of
642
668
643
669
The Artisan console's `make` commands are used to create a variety of classes, such as controllers, jobs, migrations, and tests. These classes are generated using "stub" files that are populated with values based on your input. However, you may want to make small changes to files generated by Artisan. To accomplish this, you may use the `stub:publish` command to publish the most common stubs to your application so that you can customize them:
644
670
645
-
php artisan stub:publish
671
+
```shell
672
+
php artisan stub:publish
673
+
```
646
674
647
675
The published stubs will be located within a `stubs` directory in the root of your application. Any changes you make to these stubs will be reflected when you generate their corresponding classes using Artisan's `make` commands.
Copy file name to clipboardExpand all lines: authentication.md
+4-2
Original file line number
Diff line number
Diff line change
@@ -354,8 +354,10 @@ Once the middleware has been attached to the route, you will automatically be pr
354
354
355
355
If you are using PHP FastCGI and Apache to serve your Laravel application, HTTP Basic authentication may not work correctly. To correct these problems, the following lines may be added to your application's `.htaccess` file:
Copy file name to clipboardExpand all lines: authorization.md
+10-6
Original file line number
Diff line number
Diff line change
@@ -245,11 +245,15 @@ Policies are classes that organize authorization logic around a particular model
245
245
246
246
You may generate a policy using the `make:policy` Artisan command. The generated policy will be placed in the `app/Policies` directory. If this directory does not exist in your application, Laravel will create it for you:
247
247
248
-
php artisan make:policy PostPolicy
248
+
```shell
249
+
php artisan make:policy PostPolicy
250
+
```
249
251
250
252
The `make:policy` command will generate an empty policy class. If you would like to generate a class with example policy methods related to viewing, creating, updating, and deleting the resource, you may provide a `--model` option when executing the command:
251
253
252
-
php artisan make:policy PostPolicy --model=Post
254
+
```shell
255
+
php artisan make:policy PostPolicy --model=Post
256
+
```
253
257
254
258
<aname="registering-policies"></a>
255
259
### Registering Policies
@@ -663,7 +667,7 @@ Specifying the entire class name within a string middleware definition can becom
663
667
664
668
When writing Blade templates, you may wish to display a portion of the page only if the user is authorized to perform a given action. For example, you may wish to show an update form for a blog post only if the user can actually update the post. In this situation, you may use the `@can` and `@cannot` directives:
665
669
666
-
```html
670
+
```blade
667
671
@can('update', $post)
668
672
<!-- The current user can update the post... -->
669
673
@elsecan('create', App\Models\Post::class)
@@ -681,7 +685,7 @@ When writing Blade templates, you may wish to display a portion of the page only
681
685
682
686
These directives are convenient shortcuts for writing `@if` and `@unless` statements. The `@can` and `@cannot` statements above are equivalent to the following statements:
683
687
684
-
```html
688
+
```blade
685
689
@if (Auth::user()->can('update', $post))
686
690
<!-- The current user can update the post... -->
687
691
@endif
@@ -693,7 +697,7 @@ These directives are convenient shortcuts for writing `@if` and `@unless` statem
693
697
694
698
You may also determine if a user is authorized to perform any action from a given array of actions. To accomplish this, use the `@canany` directive:
695
699
696
-
```html
700
+
```blade
697
701
@canany(['update', 'view', 'delete'], $post)
698
702
<!-- The current user can update, view, or delete the post... -->
699
703
@elsecanany(['create'], \App\Models\Post::class)
@@ -706,7 +710,7 @@ You may also determine if a user is authorized to perform any action from a give
706
710
707
711
Like most of the other authorization methods, you may pass a class name to the `@can` and `@cannot` directives if the action does not require a model instance:
Copy file name to clipboardExpand all lines: billing.md
+37-13
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,9 @@ When upgrading to a new version of Cashier, it's important that you carefully re
82
82
83
83
First, install the Cashier package for Stripe using the Composer package manager:
84
84
85
-
composer require laravel/cashier
85
+
```shell
86
+
composer require laravel/cashier
87
+
```
86
88
87
89
> {note} To ensure Cashier properly handles all Stripe events, remember to [set up Cashier's webhook handling](#handling-stripe-webhooks).
88
90
@@ -91,11 +93,15 @@ First, install the Cashier package for Stripe using the Composer package manager
91
93
92
94
Cashier's service provider registers its own database migration directory, so remember to migrate your database after installing the package. The Cashier migrations will add several columns to your `users` table as well as create a new `subscriptions` table to hold all of your customer's subscriptions:
93
95
94
-
php artisan migrate
96
+
```shell
97
+
php artisan migrate
98
+
```
95
99
96
100
If you need to overwrite the migrations that ship with Cashier, you can publish them using the `vendor:publish` Artisan command:
If you would like to prevent Cashier's migrations from running entirely, you may use the `ignoreMigrations` method provided by Cashier. Typically, this method should be called in the `register` method of your `AppServiceProvider`:
101
107
@@ -150,19 +156,25 @@ Cashier assumes your billable model will be the `App\Models\User` class that shi
150
156
151
157
Next, you should configure your Stripe API keys in your application's `.env` file. You can retrieve your Stripe API keys from the Stripe control panel:
152
158
153
-
STRIPE_KEY=your-stripe-key
154
-
STRIPE_SECRET=your-stripe-secret
159
+
```ini
160
+
STRIPE_KEY=your-stripe-key
161
+
STRIPE_SECRET=your-stripe-secret
162
+
```
155
163
156
164
<aname="currency-configuration"></a>
157
165
### Currency Configuration
158
166
159
167
The default Cashier currency is United States Dollars (USD). You can change the default currency by setting the `CASHIER_CURRENCY` environment variable within your application's `.env` file:
160
168
161
-
CASHIER_CURRENCY=eur
169
+
```ini
170
+
CASHIER_CURRENCY=eur
171
+
```
162
172
163
173
In addition to configuring Cashier's currency, you may also specify a locale to be used when formatting money values for display on invoices. Internally, Cashier utilizes [PHP's `NumberFormatter` class](https://www.php.net/manual/en/class.numberformatter.php) to set the currency locale:
164
174
165
-
CASHIER_CURRENCY_LOCALE=nl_BE
175
+
```ini
176
+
CASHIER_CURRENCY_LOCALE=nl_BE
177
+
```
166
178
167
179
> {note} In order to use locales other than `en`, ensure the `ext-intl` PHP extension is installed and configured on your server.
168
180
@@ -194,7 +206,9 @@ For this feature to work properly, your customer's billing details, such as the
194
206
195
207
Cashier allows you to specify the log channel to be used when logging fatal Stripe errors. You may specify the log channel by defining the `CASHIER_LOGGER` environment variable within your application's `.env` file:
196
208
197
-
CASHIER_LOGGER=stack
209
+
```ini
210
+
CASHIER_LOGGER=stack
211
+
```
198
212
199
213
Exceptions that are generated by API calls to Stripe will be logged through your application's default log channel.
200
214
@@ -1347,19 +1361,27 @@ To ensure your application can handle Stripe webhooks, be sure to configure the
1347
1361
1348
1362
For convenience, Cashier includes a `cashier:webhook` Artisan command. This command will create a webhook in Stripe that listens to all of the events required by Cashier:
1349
1363
1350
-
php artisan cashier:webhook
1364
+
```shell
1365
+
php artisan cashier:webhook
1366
+
```
1351
1367
1352
1368
By default, the created webhook will point to the URL defined by the `APP_URL` environment variable and the `cashier.webhook` route that is included with Cashier. You may provide the `--url` option when invoking the command if you would like to use a different URL:
The webhook that is created will use the Stripe API version that your version of Cashier is compatible with. If you would like to use a different Stripe version, you may provide the `--api-version` option:
After creation, the webhook will be immediately active. If you wish to create the webhook but have it disabled until you're ready, you may provide the `--disabled` option when invoking the command:
1361
1381
1362
-
php artisan cashier:webhook --disabled
1382
+
```shell
1383
+
php artisan cashier:webhook --disabled
1384
+
```
1363
1385
1364
1386
> {note} Make sure you protect incoming Stripe webhook requests with Cashier's included [webhook signature verification](#verifying-webhook-signatures) middleware.
1365
1387
@@ -1861,7 +1883,9 @@ For more information on `incomplete` and `past_due` states, please refer to [our
1861
1883
1862
1884
Since SCA regulations require customers to occasionally verify their payment details even while their subscription is active, Cashier can send a notification to the customer when off-session payment confirmation is required. For example, this may occur when a subscription is renewing. Cashier's payment notification can be enabled by setting the `CASHIER_PAYMENT_NOTIFICATION` environment variable to a notification class. By default, this notification is disabled. Of course, Cashier includes a notification class you may use for this purpose, but you are free to provide your own notification class if desired:
To ensure that off-session payment confirmation notifications are delivered, verify that [Stripe webhooks are configured](#handling-stripe-webhooks) for your application and the `invoice.payment_action_required` webhook is enabled in your Stripe dashboard. In addition, your `Billable` model should also use Laravel's `Illuminate\Notifications\Notifiable` trait.
0 commit comments