Skip to content

Commit

Permalink
Torchlight Code Fences (laravel#7657)
Browse files Browse the repository at this point in the history
* working on fences

* more work on fences

* more fences

* working on fences

* update code fencing

* fences

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix upgrade guide and release notes
  • Loading branch information
taylorotwell authored Feb 7, 2022
1 parent a6703d4 commit c1438c8
Show file tree
Hide file tree
Showing 58 changed files with 2,343 additions and 1,409 deletions.
68 changes: 48 additions & 20 deletions artisan.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,24 @@

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:

php artisan list
```shell
php artisan list
```

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`:

php artisan help migrate
```shell
php artisan help migrate
```

<a name="laravel-sail"></a>
#### Laravel Sail

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:

./sail artisan list
```shell
./sail artisan list
```

<a name="tinker"></a>
### Tinker (REPL)
Expand All @@ -50,7 +56,9 @@ Laravel Tinker is a powerful REPL for the Laravel framework, powered by the [Psy

All Laravel applications include Tinker by default. However, you may install Tinker using Composer if you have previously removed it from your application:

composer require laravel/tinker
```shell
composer require laravel/tinker
```

> {tip} Looking for a graphical UI for interacting with your Laravel application? Check out [Tinkerwell](https://tinkerwell.app)!
Expand All @@ -59,11 +67,15 @@ All Laravel applications include Tinker by default. However, you may install Tin

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:

php artisan tinker
```shell
php artisan tinker
```

You can publish Tinker's configuration file using the `vendor:publish` command:

php artisan vendor:publish --provider="Laravel\Tinker\TinkerServiceProvider"
```shell
php artisan vendor:publish --provider="Laravel\Tinker\TinkerServiceProvider"
```

> {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.
Expand Down Expand Up @@ -95,7 +107,9 @@ In addition to the commands provided with Artisan, you may build your own custom

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:

php artisan make:command SendEmails
```shell
php artisan make:command SendEmails
```

<a name="command-structure"></a>
### Command Structure
Expand Down Expand Up @@ -216,10 +230,10 @@ All user supplied arguments and options are wrapped in curly braces. In the foll
You may also make arguments optional or define default values for arguments:

// Optional argument...
mail:send {user?}
'mail:send {user?}'

// Optional argument with default value...
mail:send {user=foo}
'mail:send {user=foo}'

<a name="options"></a>
### Options
Expand All @@ -235,7 +249,9 @@ Options, like arguments, are another form of user input. Options are prefixed by

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`:

php artisan mail:send 1 --queue
```shell
php artisan mail:send 1 --queue
```

<a name="options-with-values"></a>
#### Options With Values
Expand All @@ -251,46 +267,56 @@ Next, let's take a look at an option that expects a value. If the user must spec

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`:

php artisan mail:send 1 --queue=default
```shell
php artisan mail:send 1 --queue=default
```

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:

mail:send {user} {--queue=default}
'mail:send {user} {--queue=default}'

<a name="option-shortcuts"></a>
#### Option Shortcuts

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:

mail:send {user} {--Q|queue}
'mail:send {user} {--Q|queue}'

When invoking the command on your terminal, option shortcuts should be prefixed with a single hyphen:

php artisan mail:send 1 -Q
```shell
php artisan mail:send 1 -Q
```

<a name="input-arrays"></a>
### Input Arrays

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:

mail:send {user*}
'mail:send {user*}'

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:

php artisan mail:send foo bar
```shell
php artisan mail:send foo bar
```

This `*` character can be combined with an optional argument definition to allow zero or more instances of an argument:

mail:send {user?*}
'mail:send {user?*}'

<a name="option-arrays"></a>
#### Option Arrays

When defining an option that expects multiple input values, each option value passed to the command should be prefixed with the option name:

mail:send {user} {--id=*}
'mail:send {user} {--id=*}'

php artisan mail:send --id=1 --id=2
Such a command may be invoked by passing multiple `--id` arguments:

```shell
php artisan mail:send --id=1 --id=2
```

<a name="input-descriptions"></a>
### Input Descriptions
Expand Down Expand Up @@ -642,7 +668,9 @@ As you might expect, the `getSubscribedSignals` method should return an array of

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:

php artisan stub:publish
```shell
php artisan stub:publish
```

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.

Expand Down
6 changes: 4 additions & 2 deletions authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,10 @@ Once the middleware has been attached to the route, you will automatically be pr

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:

RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
```apache
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
```

<a name="stateless-http-basic-authentication"></a>
### Stateless HTTP Basic Authentication
Expand Down
16 changes: 10 additions & 6 deletions authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,15 @@ Policies are classes that organize authorization logic around a particular model

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:

php artisan make:policy PostPolicy
```shell
php artisan make:policy PostPolicy
```

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:

php artisan make:policy PostPolicy --model=Post
```shell
php artisan make:policy PostPolicy --model=Post
```

<a name="registering-policies"></a>
### Registering Policies
Expand Down Expand Up @@ -663,7 +667,7 @@ Specifying the entire class name within a string middleware definition can becom

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:

```html
```blade
@can('update', $post)
<!-- The current user can update the post... -->
@elsecan('create', App\Models\Post::class)
Expand All @@ -681,7 +685,7 @@ When writing Blade templates, you may wish to display a portion of the page only

These directives are convenient shortcuts for writing `@if` and `@unless` statements. The `@can` and `@cannot` statements above are equivalent to the following statements:

```html
```blade
@if (Auth::user()->can('update', $post))
<!-- The current user can update the post... -->
@endif
Expand All @@ -693,7 +697,7 @@ These directives are convenient shortcuts for writing `@if` and `@unless` statem

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:

```html
```blade
@canany(['update', 'view', 'delete'], $post)
<!-- The current user can update, view, or delete the post... -->
@elsecanany(['create'], \App\Models\Post::class)
Expand All @@ -706,7 +710,7 @@ You may also determine if a user is authorized to perform any action from a give

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:

```html
```blade
@can('create', App\Models\Post::class)
<!-- The current user can create posts... -->
@endcan
Expand Down
50 changes: 37 additions & 13 deletions billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ When upgrading to a new version of Cashier, it's important that you carefully re

First, install the Cashier package for Stripe using the Composer package manager:

composer require laravel/cashier
```shell
composer require laravel/cashier
```

> {note} To ensure Cashier properly handles all Stripe events, remember to [set up Cashier's webhook handling](#handling-stripe-webhooks).
Expand All @@ -91,11 +93,15 @@ First, install the Cashier package for Stripe using the Composer package manager

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:

php artisan migrate
```shell
php artisan migrate
```

If you need to overwrite the migrations that ship with Cashier, you can publish them using the `vendor:publish` Artisan command:

php artisan vendor:publish --tag="cashier-migrations"
```shell
php artisan vendor:publish --tag="cashier-migrations"
```

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`:

Expand Down Expand Up @@ -150,19 +156,25 @@ Cashier assumes your billable model will be the `App\Models\User` class that shi

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:

STRIPE_KEY=your-stripe-key
STRIPE_SECRET=your-stripe-secret
```ini
STRIPE_KEY=your-stripe-key
STRIPE_SECRET=your-stripe-secret
```

<a name="currency-configuration"></a>
### Currency Configuration

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:

CASHIER_CURRENCY=eur
```ini
CASHIER_CURRENCY=eur
```

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:

CASHIER_CURRENCY_LOCALE=nl_BE
```ini
CASHIER_CURRENCY_LOCALE=nl_BE
```

> {note} In order to use locales other than `en`, ensure the `ext-intl` PHP extension is installed and configured on your server.
Expand Down Expand Up @@ -194,7 +206,9 @@ For this feature to work properly, your customer's billing details, such as the

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:

CASHIER_LOGGER=stack
```ini
CASHIER_LOGGER=stack
```

Exceptions that are generated by API calls to Stripe will be logged through your application's default log channel.

Expand Down Expand Up @@ -1347,19 +1361,27 @@ To ensure your application can handle Stripe webhooks, be sure to configure the

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:

php artisan cashier:webhook
```shell
php artisan cashier:webhook
```

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:

php artisan cashier:webhook --url "https://example.com/stripe/webhook"
```shell
php artisan cashier:webhook --url "https://example.com/stripe/webhook"
```

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:

php artisan cashier:webhook --api-version="2019-12-03"
```shell
php artisan cashier:webhook --api-version="2019-12-03"
```

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:

php artisan cashier:webhook --disabled
```shell
php artisan cashier:webhook --disabled
```

> {note} Make sure you protect incoming Stripe webhook requests with Cashier's included [webhook signature verification](#verifying-webhook-signatures) middleware.
Expand Down Expand Up @@ -1861,7 +1883,9 @@ For more information on `incomplete` and `past_due` states, please refer to [our

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:

CASHIER_PAYMENT_NOTIFICATION=Laravel\Cashier\Notifications\ConfirmPayment
```ini
CASHIER_PAYMENT_NOTIFICATION=Laravel\Cashier\Notifications\ConfirmPayment
```

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.

Expand Down
Loading

0 comments on commit c1438c8

Please sign in to comment.