|
1 |
| -# PrimeVue SPA & Laravel API Starter Kit |
| 1 | +# PrimeVue SPA + Laravel API Starter Kit |
2 | 2 |
|
3 | 3 | >) >) 
|
4 | 4 |
|
5 | 5 | A [PrimeVue](https://primevue.org/) SPA starter kit meant for use with a [Laravel Breeze](https://github.com/laravel/breeze) API stack backend.
|
6 | 6 |
|
7 |
| -An alternative to using the [Laravel & PrimeVue (Inertia.js) Starter Kit](https://github.com/connorabbas/laravel-primevue-starter-kit). |
| 7 | +An alternative to using the [Laravel + PrimeVue (Inertia.js) Starter Kit](https://github.com/connorabbas/laravel-primevue-starter-kit). |
8 | 8 |
|
9 |
| -## Setup |
10 |
| - |
11 |
| -1. Clone the repo (or download the zip) |
12 |
| -2. Create a new `.env` file in the root directory, reference the `.env.example` file for the vars/values |
13 |
| -3. Create a [new Laravel application](https://laravel.com/docs/master/installation) |
14 |
| -4. Install [Laravel Breeze](https://laravel.com/docs/11.x/starter-kits#laravel-breeze-installation) using the [API Stack](https://laravel.com/docs/11.x/starter-kits#breeze-and-next) option |
15 |
| -5. Setup necessary `.env` configuration values in the Laravel API project |
16 |
| - ``` |
17 |
| - # Example implementation |
18 |
| - # Remember, your SPA and API must share the same top-level domain |
19 |
| - APP_URL=http://api.vue-spa.localhost # Match this value with VITE_API_BASE_URL in the Vue app |
20 |
| - FRONTEND_URL=http://vue-spa.localhost # Add app.frontend_url config entry as needed |
21 |
| - SANCTUM_STATEFUL_DOMAINS="vue-spa.localhost" |
22 |
| - SESSION_DOMAIN="vue-spa.localhost" |
23 |
| - ``` |
24 |
| -6. Setup additional routes and controllers for profile settings in the Laravel API project: |
25 |
| -
|
26 |
| - ``` |
27 |
| - php artisan make:controller ProfileController |
28 |
| - ``` |
29 |
| -
|
30 |
| - ```php |
31 |
| - <?php |
32 |
| -
|
33 |
| - namespace App\Http\Controllers; |
34 |
| -
|
35 |
| - use App\Models\User; |
36 |
| - use Illuminate\Http\Request; |
37 |
| - use Illuminate\Http\Response; |
38 |
| - use Illuminate\Support\Facades\Auth; |
39 |
| - use Illuminate\Validation\Rule; |
40 |
| - use Illuminate\View\View; |
41 |
| -
|
42 |
| - class ProfileController extends Controller |
43 |
| - { |
44 |
| - /** |
45 |
| - * Update the user's profile information. |
46 |
| - */ |
47 |
| - public function update(Request $request): Response |
48 |
| - { |
49 |
| - $validated = $request->validate([ |
50 |
| - 'name' => ['required', 'string', 'max:255'], |
51 |
| - 'email' => [ |
52 |
| - 'required', |
53 |
| - 'string', |
54 |
| - 'lowercase', |
55 |
| - 'email', |
56 |
| - 'max:255', |
57 |
| - Rule::unique(User::class)->ignore($request->user()->id), |
58 |
| - ], |
59 |
| - ]); |
60 |
| -
|
61 |
| - $request->user()->fill($validated); |
62 |
| -
|
63 |
| - if ($request->user()->isDirty('email')) { |
64 |
| - $request->user()->email_verified_at = null; |
65 |
| - } |
66 |
| -
|
67 |
| - $request->user()->save(); |
68 |
| -
|
69 |
| - return response()->noContent(); |
70 |
| - } |
71 |
| -
|
72 |
| - /** |
73 |
| - * Delete the user's account. |
74 |
| - */ |
75 |
| - public function destroy(Request $request): Response |
76 |
| - { |
77 |
| - $request->validate([ |
78 |
| - 'password' => ['required', 'current_password'], |
79 |
| - ]); |
80 |
| -
|
81 |
| - $user = $request->user(); |
82 |
| -
|
83 |
| - Auth::logout(); |
84 |
| -
|
85 |
| - $user->delete(); |
86 |
| -
|
87 |
| - $request->session()->invalidate(); |
88 |
| - $request->session()->regenerateToken(); |
89 |
| -
|
90 |
| - return response()->noContent(); |
91 |
| - } |
92 |
| - } |
93 |
| -
|
94 |
| - ``` |
95 |
| -
|
96 |
| - ``` |
97 |
| - php artisan make:controller Auth/PasswordController |
98 |
| - ``` |
99 |
| -
|
100 |
| - ```php |
101 |
| - <?php |
102 |
| -
|
103 |
| - namespace App\Http\Controllers\Auth; |
104 |
| -
|
105 |
| - use App\Http\Controllers\Controller; |
106 |
| - use Illuminate\Http\Request; |
107 |
| - use Illuminate\Http\Response; |
108 |
| - use Illuminate\Support\Facades\Auth; |
109 |
| - use Illuminate\Support\Facades\Hash; |
110 |
| - use Illuminate\Validation\Rules\Password; |
111 |
| -
|
112 |
| - class PasswordController extends Controller |
113 |
| - { |
114 |
| - /** |
115 |
| - * Update the user's password. |
116 |
| - */ |
117 |
| - public function update(Request $request): Response |
118 |
| - { |
119 |
| - $validated = $request->validate([ |
120 |
| - 'current_password' => ['required', 'current_password'], |
121 |
| - 'password' => ['required', Password::defaults(), 'confirmed'], |
122 |
| - ]); |
123 |
| -
|
124 |
| - $request->user()->update([ |
125 |
| - 'password' => Hash::make($validated['password']), |
126 |
| - ]); |
127 |
| -
|
128 |
| - if ($request->session()->has('password_hash_web')) { |
129 |
| - $user = Auth::user(); |
130 |
| - $request->session()->forget('password_hash_web'); |
131 |
| - Auth::login($user); |
132 |
| - } |
133 |
| -
|
134 |
| - return response()->noContent(); |
135 |
| - } |
136 |
| - } |
137 |
| -
|
138 |
| - ``` |
139 |
| -
|
140 |
| - ```php |
141 |
| - Route::controller(App\Http\Controllers\ProfileController::class) |
142 |
| - ->middleware('auth') |
143 |
| - ->group(function () { |
144 |
| - Route::patch('/profile', 'update')->name('profile.update'); |
145 |
| - Route::delete('/profile', 'destroy')->name('profile.destroy'); |
146 |
| - }); |
147 |
| -
|
148 |
| - Route::put('password', [App\Http\Controllers\Auth\PasswordController::class, 'update']) |
149 |
| - ->middleware('auth') |
150 |
| - ->name('password.update'); |
151 |
| - ``` |
152 |
| -
|
153 |
| -## TypeScript |
154 |
| -
|
155 |
| -TypeScript is configured and ready for use if desired, but is not required. |
156 |
| -
|
157 |
| -## Theme |
158 |
| -
|
159 |
| -This starter kit provides a collection of custom theme presets to choose from, built using the powerful **PrimeVue V4** theming system. It leverages styled mode and custom design token values to create flexible and cohesive UI designs. |
160 |
| -
|
161 |
| -### Provided Theme Presets |
162 |
| -
|
163 |
| -The theme presets are located in the `/resources/js/theme` directory. Each preset offers a distinct visual style: |
164 |
| -
|
165 |
| -- **bootstrap** |
166 |
| - Emulates the look and feel of [Bootstrap](https://getbootstrap.com/). |
167 |
| -
|
168 |
| -- **breeze** |
169 |
| - Captures the aesthetic of [Laravel Breeze](https://github.com/laravel/breeze). (R.I.P. :pray:) |
170 |
| -
|
171 |
| -- **enterprise** |
172 |
| - Provides a clean, no-nonsense corporate design. |
173 |
| -
|
174 |
| -- **noir** |
175 |
| - A minimal & clean monochromatic style that serves as the default theme. |
176 |
| -
|
177 |
| -- **warm** |
178 |
| - A boxy design with a warmer color pallette. |
179 |
| -
|
180 |
| -### Customizing Your Own Theme |
181 |
| -
|
182 |
| -Creating your own theme preset is simple. You can: |
183 |
| -
|
184 |
| -- Swap the [primary](https://primevue.org/theming/styled/#primary) values with a different set of [colors](https://primevue.org/theming/styled/#colors). |
185 |
| -- Adjust the `colorScheme` [surface](https://primevue.org/theming/styled/#surface) values (e.g., slate, gray, neutral). |
186 |
| -- Change the extended [preset theme](https://primevue.org/theming/styled/#presets). |
187 |
| -
|
188 |
| -For detailed guidance on customization, please refer to the [PrimeVue Styled Mode Docs](https://primevue.org/theming/styled/). |
189 |
| -
|
190 |
| -## PrimeVue v4 w/ Tailwind CSS |
191 |
| -
|
192 |
| -To clarify, Tailwind is **not** used for any component styling in this starter kit; instead, we use PrimeVue's styled mode with a custom theme preset implementation for component styling. Tailwind is applied solely for layout purposes **around** PrimeVue components and for minimal styling when needed. |
| 9 | +[📚 **Documentation**](https://connorabbas.github.io/laravel-primevue-starter-kit-docs/alt/api-spa.html) |
0 commit comments