Skip to content

Commit 48d1cf2

Browse files
committed
various tweaks
1 parent 5a45d60 commit 48d1cf2

File tree

4 files changed

+40
-15
lines changed

4 files changed

+40
-15
lines changed

content/collections/extending-docs/addons.md

+23-5
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ php please make:addon example/my-addon
1818

1919
This will scaffold out everything you need to get started as a [private addon](#private-addons) within your site's `addons` directory.
2020

21-
Eventually, an addon will be available on Packagist and installable through Composer (and therefore live inside your `vendor` directory). During development however, you can keep it on your local filesystem as a path repository.
21+
Eventually, an addon may be available on Packagist and installable through Composer (and therefore live inside your `vendor` directory). During development however, you can keep it on your local filesystem as a path repository.
2222

2323
:::tip
2424
If you don't plan on distributing your addon or sharing it between multiple projects, you can take a simpler approach and just [add things to your Laravel application](/extending).
2525
:::
2626

27+
28+
### What's in an addon?
29+
2730
An addon consists of at least a `composer.json` and a service provider. Your directory may be placed anywhere, but for the sake of this example, we'll put it in `addons/acme/example`
2831

2932
``` files theme:serendipity-light
@@ -42,6 +45,13 @@ resources
4245
composer.json
4346
```
4447

48+
### Composer.json
49+
50+
The composer.json is used by (you guessed it) Composer in order to install your package.
51+
52+
The `extra.statamic` section is used by Statamic to know that it's an addon and not just a standard Composer package.
53+
The `extra.laravel.providers` section what Laravel uses to load your service provider.
54+
4555
``` json
4656
{
4757
"name": "acme/example",
@@ -73,6 +83,10 @@ composer.json
7383
}
7484
```
7585

86+
### Service Provider
87+
88+
The service provider is where all the various components of your addon get wired together.
89+
7690
You should make sure that your service provider extends Statamic's `Statamic\Providers\AddonServiceProvider`, and not `Illuminate\Support\ServiceProvider`. Statamic's `AddonServiceProvider` includes some bootstrapping and autoloading that isn't included with Laravel's service provider.
7791

7892
``` php
@@ -93,7 +107,11 @@ The `bootAddon` method should be used instead of `boot`. They are the same excep
93107
makes sure to boot _after_ Statamic has booted.
94108
:::
95109

96-
In your project root's `composer.json`, add your package to the `require` and `repositories` sections, like so:
110+
### Installing your freshly created addon
111+
112+
If you ran the `make:addon` command, this would have been taken care of for you.
113+
114+
Otherwise, in your project root's `composer.json`, add your package to the `require` and `repositories` sections, like so:
97115

98116
``` json
99117
{
@@ -128,7 +146,7 @@ Your addon is now installed. You should be able to go to `/cp/addons` and see it
128146

129147
### Public addons
130148

131-
A public addon is one available as a composer package on packagist.org. Simple require it with composer:
149+
A public addon is one available as a composer package on packagist.org. Simply require it with composer:
132150

133151
``` shell
134152
composer require vendor/package
@@ -227,7 +245,7 @@ protected $commands = [
227245
### CSS and Javascript
228246
The method of adding assets will differ slightly depending on whether you are using Vite or another build process. We recommend Vite.
229247

230-
#### Using Vite
248+
#### Using Vite (recommended) {#using-vite}
231249

232250
In your service provider, you may register your Vite config like this, adjusting the paths appropriately.
233251

@@ -604,7 +622,7 @@ An example use case is a custom fieldtype maintained by a third party vendor. Ev
604622

605623
### Starters Kits
606624

607-
- Starter kits are installed via `php please starter-kit:install`
625+
- Starter kits are installed via `statamic new` or `php please starter-kit:install`
608626
- Starter kits install pre-configured files and settings into your site
609627
- Starter kits do not live as updatable packages within your apps
610628
- Starter kit licenses are not tied to a specific site, and expire after a successful install

content/collections/extending-docs/tags.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ public function missing($tag)
166166
}
167167
```
168168

169-
170-
171-
You may have used the `__call()` magic method in Statamic v2 to handle wildcard tags. This still technically works, but we've
172-
introduced the `wildcard` method to prevent some infinite looping situations you may encounter.
169+
:::best-practice
170+
You may notice that the `wildcard` method seems very similar to the `__call()` magic method. It is! The `wildcard` method
171+
uses `__call` under the hood, but with additional smarts. Be sure to use `wildcard`!
172+
:::
173173

174174
## Generating a tag class
175175

content/collections/extending-docs/widgets.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ updated_at: 1569264107
66
id: 5900c99f-89b9-4ee3-834c-cb1b070146e4
77
---
88

9-
For widgets, start with `php please make:widget LocalWeather`.
9+
## Generating a widget
10+
11+
You can generate a widget with a console command:
12+
13+
```shell
14+
php please make:widget LocalWeather
15+
```
1016

1117
This will automagically set up the widget and create a base template file at `resources/views/widgets/local_weather.blade.php`.
1218

content/collections/sections/extending.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ section: extending_docs
88
---
99
## To addon, or not to addon?
1010

11-
In Statamic v2, practically every customization would need to be contained within an addon, even if you had no intention of distributing it.
11+
Since Statamic is a Laravel package, you are in control over your application code.
1212

13-
Since Statamic v3 is a Laravel package, you are in control over your application code. You're free to add whatever extra code you like.
14-
15-
This makes the distinction much clearer: **If you want to reuse, distribute, or sell your features; you should make an addon.** Otherwise, you can just add things to your Laravel application.
13+
**If you want to reuse, distribute, or sell your features; you should make an addon.** Otherwise, you can just add things to your Laravel application.
1614

1715
## How to extend Statamic
1816

19-
Some features can simply be placed in the right spot and they'll be wired up automatically. For example, placing a [tag](/extending/tags) class inside `app/Tags` will make it available to your templates without any extra wiring.
17+
Many features can simply be placed in the right spot and they'll be wired up automatically.
18+
19+
For example, placing a [Tag](/extending/tags) class inside `app/Tags` will make it available to your templates without any extra wiring.
20+
Or if you're building an addon, putting it in `src/Tags` will do the same.
2021

2122
Others could require some wiring, which would typically go in a service provider.
2223

0 commit comments

Comments
 (0)