Skip to content

Commit bec5ec6

Browse files
committed
feat: update mvc docs
1 parent 0661b18 commit bec5ec6

File tree

21 files changed

+393
-1389
lines changed

21 files changed

+393
-1389
lines changed

.vitepress/config/sidebar.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ const sidebar = [
150150
// collapsed: true,
151151
items: [
152152
// { text: 'Leaf + MVC', link: '/docs/mvc/' },
153-
{ text: 'Leaf MVC v4', link: '/docs/mvc/mvc4' },
153+
// { text: 'Leaf MVC v4', link: '/docs/mvc/mvc4' },
154154
{ text: 'Controllers', link: '/docs/mvc/controllers' },
155155
// { text: 'Views', link: '/docs/frontend/mvc' },
156156
{ text: 'Models', link: '/docs/database/models' },
157-
{ text: 'Migrations', link: '/docs/database/migrations' },
158-
{ text: 'JSON Schema', link: '/docs/database/schema' },
157+
// { text: 'Migrations', link: '/docs/database/migrations' },
158+
// { text: 'JSON Schema', link: '/docs/database/schema' },
159159
{ text: 'Schema Files', link: '/docs/database/files' },
160-
{ text: 'Seeders', link: '/docs/database/seeders' },
161-
{ text: 'Factories', link: '/docs/database/factories' },
160+
// { text: 'Seeders', link: '/docs/database/seeders' },
161+
// { text: 'Factories', link: '/docs/database/factories' },
162162
{ text: 'Writing Commands', link: '/docs/mvc/commands' },
163163
// { text: 'Mailing', link: '/docs/utils/mail/mvc' },
164164
{ text: 'MVC Globals', link: '/docs/mvc/globals' },

src/docs/auth/config.md

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

src/docs/auth/session.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/docs/cli/creating-an-app.md

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

src/docs/cli/index.md

Lines changed: 122 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ This tells Composer to install the Leaf CLI globally on your system. You can ver
4141
leaf --version
4242
```
4343

44-
## [Error] command not found: leaf
44+
::: details [Error] command not found: leaf
4545

4646
If you get an error saying `leaf: command not found`, you need to add Composer's global bin directory to your system's PATH. This directory contains every package installed through `composer global require`. Let's fix this by adding the directory to your PATH.
4747

@@ -57,7 +57,7 @@ If this command does not work, you can try these common locations:
5757
- macOS: `$HOME/.composer/vendor/bin`
5858
- GNU / Linux Distributions: `$HOME/.config/composer/vendor/bin` or `$HOME/.composer/vendor/bin`
5959

60-
## Adding to PATH
60+
**Adding to PATH:**
6161

6262
Once you have the location, you can add it to your PATH. On Mac and Linux, you can do this by running these in your terminal:
6363

@@ -72,3 +72,123 @@ Or if you're using Zsh:
7272
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.zshrc
7373
source ~/.zshrc
7474
```
75+
76+
:::
77+
78+
Besides creating apps, Leaf CLI also helps you manage your apps. This includes things like running your app, dependency management, running commands, and more. This guide covers all such features.
79+
80+
## Running your app
81+
82+
You can run your app by navigating into your app's directory and running the `leaf serve` command. This will start a development server and serve your app on `localhost:5500`.
83+
84+
```bash:no-line-numbers
85+
cd my-app
86+
leaf serve
87+
```
88+
89+
You can also specify a port to run your app on by passing the `--port` or `-p` flag:
90+
91+
```bash:no-line-numbers
92+
leaf serve --port=8080
93+
```
94+
95+
The serve command also has a `--watch` flag that watches your app for changes and automatically reloads your app when changes are detected:
96+
97+
```bash:no-line-numbers
98+
leaf serve --watch
99+
```
100+
101+
*Note: The `--watch` flag is only available when running your app in development mode and uses nodejs to watch your app for changes.*
102+
103+
If you want to run your application from a different directory, you can pass the path to the directory as an argument:
104+
105+
```bash:no-line-numbers
106+
leaf serve /path/to/your/app
107+
```
108+
109+
::: info Automatic dependency installation
110+
When running your app, Leaf will automatically try to install missing dependencies if no `vendor` directory is found in your app's directory.
111+
:::
112+
113+
## Running commands
114+
115+
Leaf CLI also allows you to run commands in your app's directory. If you have a command in your `composer.json` file, you can run it using the `leaf run` command:
116+
117+
```bash:no-line-numbers
118+
leaf run my-command
119+
```
120+
121+
## Dependency management
122+
123+
Leaf CLI also has commands built on top of Composer to help you manage your app's dependencies. Leaf has a whole ecosystem of packages that are treated as first-class citizens in the Leaf ecosystem, and are given special treatment by the CLI. This makes working with Leaf packages a breeze, but also allows you to work with any Composer package.
124+
125+
::: details Are you a visual learner?
126+
127+
This video will help you understand how to work with packages on the Leaf CLI.
128+
129+
<VideoModal
130+
subject="Working with packages on the Leaf CLI"
131+
description="Working with packages and the leaf cli"
132+
videoUrl="https://www.youtube.com/embed/K9jSl_xpr48"
133+
/>
134+
135+
:::
136+
137+
### Installing packages
138+
139+
This cli tool also adds a feature to install leaf packages from composer.
140+
141+
```bash:no-line-numbers
142+
leaf install leafs/ui
143+
```
144+
145+
If you are installing a leaf module or package, you can leave out the `leafs/` part.
146+
147+
```bash:no-line-numbers
148+
leaf install ui
149+
```
150+
151+
You can also pass in a bunch of packages to install at once.
152+
153+
```bash:no-line-numbers
154+
leaf install ui db illuminate/support
155+
```
156+
157+
***Versioning***
158+
159+
Leaf CLI also allows you to install a particular version of any package using `@`
160+
161+
```bash:no-line-numbers
162+
leaf install [email protected] illuminate/[email protected]
163+
```
164+
165+
### Uninstalling packages
166+
167+
This works the same way as installing packages, but you use the `uninstall` command instead.
168+
169+
```bash:no-line-numbers
170+
leaf uninstall ui
171+
leaf uninstall ui db illuminate/support
172+
```
173+
174+
## View commands
175+
176+
Leaf CLI also allows you to create and interact with frontend setups using the `view` commands. You can scaffold frontend setups like React, Vue, templating engines, build tools, and more.
177+
178+
### Scaffolding views
179+
180+
Leaf CLI ships with a `view:install` command that allows you to set up React, Vue, and templating engines like Blade and BareUI. You can use the `--react`, `--vue`, `--blade`, and `--svelte` options to scaffold your frontend setup.
181+
182+
```bash:no-line-numbers
183+
leaf view:install --react
184+
```
185+
186+
You can also use the `--vite` and `--tailwind` options to scaffold Vite and Tailwind respectively.
187+
188+
### Building frontend setups
189+
190+
You can also use the `view:build` command to build your frontend setup for production.
191+
192+
```bash:no-line-numbers
193+
leaf view:build
194+
```

0 commit comments

Comments
 (0)