Skip to content

Commit c1307d3

Browse files
committed
feat: add new mvc documentation
1 parent bec5ec6 commit c1307d3

File tree

21 files changed

+1435
-119
lines changed

21 files changed

+1435
-119
lines changed

.vitepress/config/sidebar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const sidebar = [
125125
{ text: 'HTTP Cache', link: '/docs/http/caching' },
126126
{ text: 'Leaf Mail', link: '/docs/utils/mail/' },
127127
{ text: 'File System', link: '/docs/utils/fs' },
128-
// { text: 'Queues/Jobs', link: '/docs/utils/queues' },
128+
{ text: 'Queues/Jobs', link: '/docs/utils/queues' },
129129
],
130130
},
131131
{

.vitepress/theme/components/Home/Tooling.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ const tab = ref(tooling[0].title);
299299

300300
<p>Leaf auto-detects your frontend files and bundles them whenever you run the leaf serve command. This
301301
means you don't really have to do anything to get your frontend working correctly.</p>
302+
303+
<p>Find out more on the <a href="/docs/frontend/">Frontend documentation</a></p>
302304
</div>
303305
</div>
304306
</div>

src/docs/config/environment.md

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,6 @@ import Button from '@theme/components/shared/Button.vue';
99

1010
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.
1111

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-
4512
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.
4613

4714
## Environment Variables

src/docs/config/mvc.md

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

src/docs/database/files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ seeds:
2222
2323
## Creating a Schema File
2424
25-
Aloe comes with a `g:schema` command that you can use to generate a database file. You can generate a database file by running:
25+
Leaf MVC's console comes with a `g:schema` command that you can use to generate a database file. You can generate a database file by running:
2626

2727
```bash:no-line-numbers
2828
php leaf g:schema <table-name>

src/docs/database/models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ On top of all that, a single model corresponds to a single database table. This
1212

1313
## Creating a model
1414

15-
You can generate a model using the Aloe Console:
15+
You can generate a model using the MVC Console:
1616

1717
```bash:no-line-numbers
1818
php leaf g:model flight

src/docs/database/redis.md

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,9 @@ This will initialize a new Redis connection. From there, you can start storing a
5151

5252
## Usage with Leaf MVC
5353

54-
If you're using Leaf MVC, you can add on some extra features to your setup. Leaf Redis comes with a few commands that you can attach to your Aloe CLI. You can do this by heading over to the `app/console/Commands.php` file in your Leaf MVC app and adding the following line to the return array.
54+
If you're using Leaf MVC, you can add on some extra features to your setup. Leaf Redis comes with a few commands that you can attach to the MVC console. You can do this by heading over to the `leaf` file in your project root and adding the following line to the return array.
5555

56-
::: code-group
57-
58-
```php [Leaf MVC 3.8 and above]
56+
```php
5957
/*
6058
|--------------------------------------------------------------------------
6159
| Load Leaf configuration
@@ -72,32 +70,6 @@ Leaf\Core::loadConsole([
7270
]);
7371
```
7472

75-
```php [Leaf MVC 3.7 and below]
76-
<?php
77-
78-
namespace App\Console;
79-
80-
class Commands
81-
{
82-
/**
83-
* Register commands
84-
*
85-
* @param $console
86-
* @return void
87-
*
88-
*/
89-
public static function register($console): void
90-
{
91-
$console->register([
92-
ExampleCommand::class,
93-
Leaf\Redis::commands() // [!code ++]
94-
]);
95-
}
96-
}
97-
```
98-
99-
:::
100-
10173
Once you've done that, you should have access to a bunch of new commands from Leaf Redis. The available commands are:
10274

10375
```bash:no-line-numbers

src/docs/http/cors.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,6 @@ app()->cors([
108108

109109
This will allow `http://example.com`, `https://example.com`, `http://www.example.com`, and `https://some-subdomain.example.com` to access your app. Of course, you can also use a regular expression to match multiple domains. You can find a full list of options below.
110110

111-
## CORS + Leaf MVC
112-
113-
If you are using Leaf MVC, you can configure CORS using your environment variables in place of the configuration above:
114-
115-
```txt:no-line-numbers [.env]
116-
CORS_ALLOWED_ORIGINS='/\.example\.com$/'
117-
CORS_ALLOWED_METHODS='GET,HEAD,PUT,PATCH,POST,DELETE'
118-
CORS_ALLOWED_HEADERS='*'
119-
```
120-
121-
While this is easier and allows you to easily configure different environments, it can sometimes be limiting for example when you want to return a function for dynamically set your allowed origins. For this reason, you can publish your CORS configuration using the command below:
122-
123-
```bash:no-line-numbers
124-
php leaf config:publish cors
125-
```
126-
127-
This will create or update your CORS config in `config/cors.php`. You can then use the options below to configure the CORS module to suit your exact needs.
128-
129111
## Configuration Options
130112

131113
The `cors()` method takes in an array of options. Here are the available options:

0 commit comments

Comments
 (0)