Skip to content

Commit 614de03

Browse files
committed
feat: clean up v3 docs
1 parent 370af2f commit 614de03

File tree

15 files changed

+183
-78
lines changed

15 files changed

+183
-78
lines changed

.vitepress/theme/components/shared/TutorialNumber.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { number } = defineProps(['number'])
44

55
<template>
66
<span
7-
class="bg-[var(--vp-c-bg-alt)] inline-flex items-center justify-center rounded-full text-gray-700 dark:text-gray-300 text-lg h-10 w-10 mr-1 flex-none font-normal">
7+
class="bg-gray-900 dark:bg-[var(--vp-c-bg-alt)] outline outline-gray-100/10 inline-flex items-center justify-center rounded-full text-white dark:text-gray-300 text-lg h-10 w-10 mr-1 flex-none font-normal">
88
{{ number }}
99
</span>
1010
</template>

src/docs/auth/index.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,46 @@
22

33
<!-- markdownlint-disable no-inline-html -->
44

5+
<script setup>
6+
import Button from '@theme/components/shared/Button.vue';
7+
</script>
8+
59
Numerous web applications offer their users a means to authenticate and access the application by "logging in." Adding this functionality to web applications can be a challenging and potentially dangerous task.
610

711
Leaf provides a lightweight but very powerful authentication system to handle all the complexities of authentication in a few lines of code. We understand that authentication is a critical part of your application, so we've made it as simple and secure as possible.
812

9-
::: warning Docs version
10-
This documentation covers Auth v3 and above. If you're using an older version, you can check the documentation [hosted here](https://v3.leafphp.dev/modules/auth/).
11-
:::
13+
<div
14+
class="w-full relative text-white overflow-hidden rounded-3xl flex shadow-lg sm:max-w-[50%]"
15+
>
16+
<div
17+
class="w-full flex md:flex-col bg-gradient-to-br from-pink-500 to-rose-500"
18+
>
19+
<div
20+
class="sm:flex-none md:w-auto md:flex-auto flex flex-col items-start relative z-10 p-6"
21+
>
22+
<h3 class="text-xl font-semibold mb-2 text-shadow !mt-0">
23+
Using Leaf MVC?
24+
</h3>
25+
<p class="font-medium text-rose-100 text-shadow mb-4">
26+
We've crafted a specialized guide for auth in Leaf MVC. While it's similar to the basic routing in Leaf, it's more detailed and tailored for Leaf MVC.
27+
</p>
28+
<Button
29+
as="a"
30+
href="/docs/auth/mvc"
31+
class="mt-auto bg-rose-900 hover:!bg-rose-900 !text-white bg-opacity-50 hover:bg-opacity-75 transition-colors duration-200 rounded-xl font-bold py-2 px-4 inline-flex"
32+
>Start building</Button
33+
>
34+
</div>
35+
<!-- <div
36+
class="relative md:pl-6 xl:pl-8 hidden sm:block"
37+
>
38+
Hello
39+
</div> -->
40+
</div>
41+
<div
42+
class="absolute bottom-0 left-0 right-0 h-20 bg-gradient-to-t from-rose-500 hidden sm:block"
43+
></div>
44+
</div>
1245

1346
## Setting up
1447

src/docs/auth/mvc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# MVC Support
1+
# Auth in Leaf MVC

src/docs/config/environment.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,45 @@
33
<!-- markdownlint-disable no-inline-html -->
44

55
<script setup>
6-
import VideoModal from '@theme/components/shared/VideoModal.vue'
6+
import VideoModal from '@theme/components/shared/VideoModal.vue';
7+
import Button from '@theme/components/shared/Button.vue';
78
</script>
89

910
You can think of your application's environment as a set of configurations that define how your application behaves in different situations. For example, you may run a local database when developing your app, but will want your app to connect to a remote database when it's in production.
1011

12+
<div
13+
class="w-full relative text-white overflow-hidden rounded-3xl flex shadow-lg sm:max-w-[50%]"
14+
>
15+
<div
16+
class="w-full flex md:flex-col bg-gradient-to-br from-pink-500 to-rose-500"
17+
>
18+
<div
19+
class="sm:flex-none md:w-auto md:flex-auto flex flex-col items-start relative z-10 p-6"
20+
>
21+
<h3 class="text-xl font-semibold mb-2 text-shadow !mt-0">
22+
Using Leaf MVC?
23+
</h3>
24+
<p class="font-medium text-rose-100 text-shadow mb-4">
25+
We've crafted a specialized guide for config in Leaf MVC. While it's similar to the basic config in Leaf, it's more detailed and tailored for Leaf MVC.
26+
</p>
27+
<Button
28+
as="a"
29+
href="/docs/config/mvc"
30+
class="mt-auto bg-rose-900 hover:!bg-rose-900 !text-white bg-opacity-50 hover:bg-opacity-75 transition-colors duration-200 rounded-xl font-bold py-2 px-4 inline-flex"
31+
>Sync your config</Button
32+
>
33+
</div>
34+
<!-- <div
35+
class="relative md:pl-6 xl:pl-8 hidden sm:block"
36+
>
37+
Hello
38+
</div> -->
39+
</div>
40+
<div
41+
class="absolute bottom-0 left-0 right-0 h-20 bg-gradient-to-t from-rose-500 hidden sm:block"
42+
></div>
43+
</div>
44+
1145
Common environments include `development`, `testing`, and `production`. Leaf already has some pre-programmed bahaviours for these environments, but you can also create your own custom environments. One way to do this is to use environment variables.
1246

1347
## Environment Variables

src/docs/config/index.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/docs/config/mvc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Configuring Leaf MVC

src/docs/frontend/inertia.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Inertia + Leaf
22

3+
<!-- markdownlint-disable no-inline-html -->
4+
5+
<script setup>
6+
import TutorialNumber from '@theme/components/shared/TutorialNumber.vue';
7+
</script>
8+
39
[Inertia](https://inertiajs.com/) is a new approach to building classic server-driven web apps. It allows you to create fully client-side rendered, single-page apps, without the complexity that comes with modern SPAs.
410

511
In short, Inertia let's you use your favourite frontend framework together with Leaf, reaping the benefits of both. While it's still more popular to build completely separate frontend and backends, combining them lets you have your code in one place.
@@ -141,7 +147,7 @@ php leaf g:template pages/Home # app/views/pages/Home.view.php
141147

142148
If you don't want to use the Leaf CLI, you can manually setup inertia. This guide will show you how to setup inertia with Vite and React. You can use this guide to setup inertia with any frontend framework.
143149

144-
### 1. Setting up Vite
150+
### <TutorialNumber number="1" /> Setting up Vite
145151

146152
To get started, you need to setup Vite. We have a Leaf plugin that takes care of a lot of the heavy lifting for you. We have a detailed guide on how to setup vite with Leaf [here](/docs/frontend/vite).
147153

@@ -150,7 +156,7 @@ npm i -D vite @leafphp/vite-plugin
150156
leaf install vite
151157
```
152158

153-
### 2. Vite Config
159+
### <TutorialNumber number="2" /> Vite Config
154160

155161
The [Leaf Vite docs](/docs/frontend/vite#vite-config) have a detailed guide on how to setup vite config files. You should however note that for the best developer experience, you should point Vite to your view directory so you can enjoy hot module reloading.
156162

@@ -176,7 +182,7 @@ leaf({
176182
}),
177183
```
178184

179-
### 3. Setting up Inertia
185+
### <TutorialNumber number="3" /> Setting up Inertia
180186

181187
To setup inertia, you need to install the inertia package for whatever frontend framework you want to use, together with the Vite plugin for that framework. For example, if you want to use React, you should install the Inertia React package, React Vite plugin as well as React itself:
182188

@@ -215,7 +221,7 @@ export default defineConfig({
215221
});
216222
```
217223

218-
### 4. Setting up your base JavaScript file
224+
### <TutorialNumber number="4" /> Setting up your base JavaScript file
219225

220226
You should create a base JavaScript file that will be used to mount your app. This file should import your CSS and other assets. For example, if you're using React, your base JavaScript file should look like this:
221227

@@ -249,7 +255,7 @@ setup({ el, App, props }) {
249255
},
250256
```
251257

252-
### 5. Setting up your base PHP file
258+
### <TutorialNumber number="5" /> Setting up your base PHP file
253259

254260
You should create a base PHP file that will be used to render your app. By default, the Leaf Inertia PHP adapter will look for a file named `_inertia.view.php` in your views directory. You can change this by passing the path to your base PHP file to the `Inertia::setRoot` method.
255261

@@ -305,7 +311,7 @@ This might look pretty ugly, but you'll never have to touch this file again. You
305311
leaf view:install --inertia
306312
```
307313

308-
### 6. Setting up your frontend framework
314+
### <TutorialNumber number="6" /> Setting up your frontend framework
309315

310316
In the setup above, we told Inertia to look for our frontend framework files in `./DIRECTORYFORCOMPONENTS/`. You should create this directory and add your frontend framework files to it. For example, if you're using React, you should create a file named `Home.jsx` in this directory:
311317

src/docs/frontend/tailwind.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Tailwind + Leaf
22

3-
Tailwind is a utility-first CSS framework that provides a set of utility classes to help you build your UI. Leaf has first-class support for Tailwind CSS, and it's the recommended way to style your Inertia apps. This guide will show you how to set up Tailwind CSS in your Leaf project with minimal configuration.
4-
5-
## Using the CLI
3+
<!-- markdownlint-disable no-inline-html -->
64

7-
::: warning CLI Installation
5+
<script setup>
6+
import TutorialNumber from '@theme/components/shared/TutorialNumber.vue';
7+
</script>
88

9-
Tailwind 4 has been released, and it unfortunately breaks the current Leaf CLI installation. Leaf MVC works fine with Tailwind 4, but we are working on a fix for the CLI. For now, you can install Tailwind manually if you are not using Leaf MVC.
9+
Tailwind is a utility-first CSS framework that provides a set of utility classes to help you build your UI. Leaf has first-class support for Tailwind CSS, and it's the recommended way to style your Inertia apps. This guide will show you how to set up Tailwind CSS in your Leaf project with minimal configuration.
1010

11-
:::
11+
## Using the CLI
1212

1313
You can set up Tailwind CSS in your Leaf MVC project using the php leaf console. To do this, run the following command:
1414

@@ -42,13 +42,13 @@ npm install tailwindcss @tailwindcss/vite
4242

4343
And then configure Vite to include the Tailwind plugin:
4444

45-
```js{2,6} [vite.config.js]
45+
```js [vite.config.js]
4646
import { defineConfig } from 'vite';
47-
import tailwindcss from '@tailwindcss/vite';
47+
import tailwindcss from '@tailwindcss/vite'; // [!code ++]
4848

4949
export default defineConfig({
5050
plugins: [
51-
tailwindcss(),
51+
tailwindcss(), // [!code ++]
5252
//
5353
],
5454
});
@@ -66,14 +66,14 @@ Finally, you need to import Tailwind in your CSS file:
6666

6767
And then include your CSS file in your layout templates:
6868

69-
```blade{7,12-14}
69+
```blade{12-14}
7070
<!doctype html>
7171
<html>
7272
<head>
7373
<meta charset="utf-8" />
7474
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7575

76-
@vite('resources/css/app.css')
76+
@vite('css/app.css') // [!code ++]
7777

7878
...
7979
</head>
@@ -89,21 +89,21 @@ And then include your CSS file in your layout templates:
8989

9090
If you want to migrate from Tailwind v3 to v4 in Leaf MVC, you can do so by following these steps:
9191

92-
1. Update all your dependencies to the latest version:
92+
<TutorialNumber number="1" /> Update all your dependencies to the latest version:
9393

9494
```bash:no-line-numbers
9595
composer update
9696
```
9797

98-
2. Remove old tailwind config, autoprefixer, and postcss files
98+
<TutorialNumber number="2" /> Remove old tailwind config, autoprefixer, and postcss files. <br /><br />
9999

100-
3. Run the `view:install` command to install Tailwind v4:
100+
<TutorialNumber number="3" /> Run the `view:install` command to install Tailwind v4:
101101

102102
```bash:no-line-numbers
103103
php leaf view:install --tailwind
104104
```
105105

106-
4. Update your CSS file to remove @tailwind directives:
106+
<TutorialNumber number="4" /> Update your CSS file to remove @tailwind directives:
107107

108108
```css [app/views/css/app.css]
109109
@import "tailwindcss";
@@ -171,14 +171,15 @@ defineConfig({
171171
172172
The final step is to import your CSS file in your root layout file so that it gets included in your HTML.
173173
174-
```blade{7}
174+
```blade
175175
<!DOCTYPE html>
176176
<html lang="en">
177177
<head>
178178
<meta charset="UTF-8">
179179
<meta name="viewport" content="width=device-width, initial-scale=1.0">
180180
<title>Leaf</title>
181-
{{ vite('css/app.css') }}
181+
182+
@vite('css/app.css') // [!code ++]
182183
...
183184
```
184185

src/docs/http/cookies.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,25 @@ The `set()` method allows you to set cookies with more advanced options like exp
6868

6969
## Reading Cookies
7070

71-
When you send cookies to the client, they are stored in your users' browser and automatically sent back to your app on every request. You can read these cookies using the `get()` method.
71+
When you send cookies to the client, they are stored in your users' browsers and automatically sent back to your app on every request. You can read these cookies using the `cookies()` method on the incoming request.
7272

7373
```php:no-line-numbers
74-
$name = cookie()->get('name');
74+
$name = request()->cookies('name');
75+
76+
// You can also get multiple cookies at once
77+
$cookies = request()->cookies(['name', 'age']);
78+
// $cookies['name'] and $cookies['age']
7579
```
7680

77-
This method takes in the cookie name and returns the cookie value. If the cookie doesn't exist, it returns `null`.
81+
if a cookie doesn't exist, the `cookies()` method will return `null` for that cookie.
7882

79-
You can also get all cookies at once using the `all()` method.
83+
You can also get all cookies at once by calling `cookies()` without any parameters.
8084

8185
```php:no-line-numbers
82-
$cookies = cookie()->all();
86+
$cookies = request()->cookies();
8387
```
8488

85-
This method returns an array of all cookies sent to your app. Be careful when using this method as it can return a lot of data.
89+
This method returns an array of all cookies sent to your app. Be careful when using this method as it can return a lot of data, including cookies that you may not need.
8690

8791
## Deleting Cookies
8892

src/docs/http/cors.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<!-- markdownlint-disable no-inline-html -->
44

55
<script setup>
6-
import VideoModal from '@theme/components/shared/VideoModal.vue'
6+
import VideoModal from '@theme/components/shared/VideoModal.vue';
7+
import Button from '@theme/components/shared/Button.vue';
78
</script>
89

910
From Wikipedia, Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources on a web page to be accessed from another domain outside the domain from which the first resource was served.
@@ -21,6 +22,34 @@ Cross-Origin Resource Sharing or CORS is a mechanism that allows browsers to req
2122

2223
Since CORS is a common pain point for web developers, Leaf provides a first-party integration that takes care of all the heavy lifting for you.
2324

25+
<div
26+
class="w-full relative text-white overflow-hidden rounded-3xl flex shadow-lg sm:max-w-[50%]"
27+
>
28+
<div
29+
class="w-full flex md:flex-col bg-gradient-to-br from-pink-500 to-rose-500"
30+
>
31+
<div
32+
class="sm:flex-none md:w-auto md:flex-auto flex flex-col items-start relative z-10 p-6"
33+
>
34+
<h3 class="text-xl font-semibold mb-2 text-shadow !mt-0">
35+
Using Leaf MVC?
36+
</h3>
37+
<p class="font-medium text-rose-100 text-shadow mb-4">
38+
We've crafted a specialized guide for CORS in Leaf MVC. While it's similar to the base usage in Leaf, it's more detailed and tailored for Leaf MVC.
39+
</p>
40+
<Button
41+
as="a"
42+
href="/docs/http/cors/mvc"
43+
class="mt-auto bg-rose-900 hover:!bg-rose-900 !text-white bg-opacity-50 hover:bg-opacity-75 transition-colors duration-200 rounded-xl font-bold py-2 px-4 inline-flex"
44+
>Start building</Button
45+
>
46+
</div>
47+
</div>
48+
<div
49+
class="absolute bottom-0 left-0 right-0 h-20 bg-gradient-to-t from-rose-500 hidden sm:block"
50+
></div>
51+
</div>
52+
2453
## Setting Up
2554

2655
You can install the CORS module through the Leaf CLI or with composer.

0 commit comments

Comments
 (0)