Skip to content

Commit c491f17

Browse files
authoredMay 2, 2024
updated installation code samples to use 'Stimulus' naming
in v1.x the application constant was renamed to Stimulus, but this was not yet reflected in the README.
1 parent 350cc56 commit c491f17

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed
 

‎README.md

+16-14
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,26 @@ composer require hotwired-laravel/stimulus-laravel
8787
2. Create `resources/js/controllers/index.js` and load your controllers like this:
8888

8989
```js
90-
import { application } from 'libs/stimulus'
90+
import { Stimulus } from 'libs/stimulus'
9191

9292
// Eager load all controllers defined in the import map under controllers/**/*_controller
9393
import { eagerLoadControllersFrom } from '@hotwired/stimulus-loading'
94-
eagerLoadControllersFrom('controllers', application)
94+
eagerLoadControllersFrom('controllers', Stimulus)
9595
```
9696

9797
3. Create a `resources/js/libs/stimulus.js` with the following content:
9898

9999
```js
100100
import { Application } from '@hotwired/stimulus'
101101

102-
const application = Application.start()
102+
const Stimulus = Application.start()
103103

104104
// Configure Stimulus development experience
105-
application.debug = false
106-
window.Stimulus = application
105+
Stimulus.debug = false
107106

108-
export { application }
107+
window.Stimulus = Stimulus
108+
109+
export { Stimulus }
109110
```
110111

111112
4. Create a `resources/js/libs/index.js` file with the following content (or add it to an existing file if you have one):
@@ -149,10 +150,10 @@ Importmap::pin("@hotwired/stimulus-loading", to: "vendor/stimulus-laravel/stimul
149150
// Run that command whenever you add a new controller or create them with
150151
// `php artisan stimulus:make controllerName`
151152

152-
import { application } from '../libs/stimulus'
153+
import { Stimulus } from '../libs/stimulus'
153154

154155
import HelloController from './hello_controller'
155-
application.register('hello', HelloController)
156+
Stimulus.register('hello', HelloController)
156157
```
157158

158159
#### Register controllers automatically
@@ -162,12 +163,12 @@ Importmap::pin("@hotwired/stimulus-loading", to: "vendor/stimulus-laravel/stimul
162163
```js
163164
// resources/js/controllers/index.js
164165
165-
import { application } from '../libs/stimulus'
166+
import { Stimulus } from '../libs/stimulus'
166167
import { registerControllers } from 'stimulus-vite-helpers'
167168
168169
const controllers = import.meta.glob('./**/*_controller.js', { eager: true })
169170
170-
registerControllers(application, controllers)
171+
registerControllers(Stimulus, controllers)
171172
```
172173

173174
And install the NPM package:
@@ -181,13 +182,14 @@ Importmap::pin("@hotwired/stimulus-loading", to: "vendor/stimulus-laravel/stimul
181182
```js
182183
import { Application } from '@hotwired/stimulus'
183184
184-
const application = Application.start()
185+
const Stimulus = Application.start()
185186
186187
// Configure Stimulus development experience
187-
application.debug = false
188-
window.Stimulus = application
188+
Stimulus.debug = false
189+
190+
window.Stimulus = Stimulus
189191
190-
export { application }
192+
export { Stimulus }
191193
```
192194

193195
3. Create a `resources/js/libs/index.js` file (if it doesn't exist) and add the following line to it:

0 commit comments

Comments
 (0)