You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/0-getting-started/01-introduction.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,10 @@ final class ConsoleCommandDiscovery implements Discovery
96
96
97
97
Discovery makes Tempest truly understand your codebase so that you don't have to explain the framework how to use it. Of course, discovery is heavily optimized for local development and entirely cached in production, so there's no performance overhead. Even better: discovery isn't just a core framework feature, you're encouraged to write your own project-specific discovery classes wherever they make sense. That's the Tempest way.
98
98
99
+
:::info
100
+
Read the [getting started with discovery](/blog/discovery-explained) guide if you are new to Tempest.
101
+
:::
102
+
99
103
Besides Discovery, Tempest is designed to be extensible. You'll find that any part of the framework can be replaced and hooked into by implementing an interface and plugging it into the container. No fighting the framework, Tempest gets out of your way.
Copy file name to clipboardExpand all lines: docs/1-essentials/01-routing.md
+8-33Lines changed: 8 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -336,44 +336,19 @@ Whenever a validation error occurs, Tempest will redirect back to the page the r
336
336
- As a JSON encoded string in the `{txt}X-Validation` header
337
337
- Within the session with the `Session::VALIDATION_ERRORS` key
338
338
339
-
The JSON encoded header is available for when you're building APIs with Tempest. The session errors are available for when you're building web pages. In the case of the latter, you need a way to actually show the errors on a web page. Tempest's recommended way to do so is by creating a custom [view component](/docs/essentials/views#view-components):
340
-
341
-
```html app/x-error.view.php
342
-
<?php
343
-
use Tempest\Http\Session\Session;
344
-
use Tempest\Validation\Validator;
345
-
use function Tempest\get;
346
-
347
-
/** @var Session $session */
348
-
$session = get(Session::class);
349
-
350
-
/** @var Validator $validator */
351
-
$validator = get(Validator::class);
352
-
353
-
$errors = $session->getErrorsFor($name ?? '');
354
-
355
-
?><ul:if="$errors !== []":class="$class ?? ''">
356
-
<li:foreach="$errors as $error">
357
-
{{ $validator->getErrorMessage($error) }}
358
-
</li>
359
-
</ul>
360
-
```
361
-
362
-
This view component will be discovered and can then be used to display validation errors likes so:
339
+
The JSON encoded header is available for when you're building APIs with Tempest. The session errors are available for when you're building web pages. For web pages, you also need a way to show the errors when they occur; Tempest comes with some built-in view components to help you with that.
Currently, Tempest doesn't include built-in view components to handle form validation. That's because we don't have a strategy yet for dealing with different frontend frameworks. We rather give control to the user to build their own form components for maximum flexibility. This is likely to change in the future, but for now you'll have to make your own `x-error` component.
376
-
:::
351
+
`{html}<x-form>` is a view component that will automatically include the CSRF token, as well as default to sending `POST` requests. `{html}<x-input>` is a view component that renders a label, input field, and validation errors all at once. In practice, you'll likely want to make changes to these built-in view components. That's why you can run `./tempest install view-components` and select the components you want to pull into your project. You can [read more about installing view components here](/2.x/essentials/views#built-in-components).
Copy file name to clipboardExpand all lines: docs/1-essentials/02-views.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -622,6 +622,23 @@ Tempest views are always compiled to plain PHP code before being rendered. Durin
622
622
623
623
During deployments, that cache must be cleared in order to not serve outdated views to users. You may do that by running `tempest view:clear` on every deploy.
624
624
625
+
## Separate view directories
626
+
627
+
View files can live in any directory that is discoverable by Tempest. That means: a directory with a PSR-4 namespace associated with it. If you want your view files to live outside of `src` or `app`, you can add a namespace for it in composer.json:
628
+
629
+
```json composer.json
630
+
"autoload": {
631
+
"psr-4": {
632
+
"App\\": "src/",
633
+
"Views\\": "views/"
634
+
},
635
+
}
636
+
```
637
+
638
+
Don't forget to run `composer up` after making changes to your composer.json file.
639
+
640
+
Note that view files themselves don't need a namespace; this namespace is only here to tell Tempest that `views/` is a directory it should scan. If you want to add a class in the `Views` namespace (like, for example, a [custom view object](/2.x/essentials/views#using-dedicated-view-objects)), then that is possible as well.
641
+
625
642
## Using other engines
626
643
627
644
While Tempest View is simple to use, it currently lacks tooling support from editors and IDEs. You may also simply prefer other templating engines. For these reasons, you may use any other engine of your choice.
Copy file name to clipboardExpand all lines: docs/2-features/15-datetime.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,10 @@ PHP provides multiple date and time implementations. There is [`DateTime`](https
10
10
11
11
Tempest provides an alternative to [`DateTimeInterface`](https://www.php.net/manual/en/class.datetimeinterface.php), partially based on [`IntlCalendar`](https://www.php.net/manual/en/class.intlcalendar.php). This implementation provides a better API with a more consistent interface. It was initially created by {x:azjezz} for the [PSL](https://github.com/azjezz/psl), and was ported to Tempest so it could be deeply integrated.
12
12
13
+
:::info
14
+
You're not required to use Tempest's DateTime implementation, and may as well use PHP's native datetime, Carbon, or any other. If you rely on third-party libraries like Carbon, you should read about [global casters and serializers](/2.x/features/mapper#registering-casters-and-serializers-globally) as well to ensure model support.
15
+
:::
16
+
13
17
## Creating date instances
14
18
15
19
The {`Tempest\DateTime\DateTime`} class provides a `DateTime::parse()` method to create a date from a string, a timestamp, or another datetime instance. This is the most flexible way to create a date instance.
Copy file name to clipboardExpand all lines: docs/4-internals/02-discovery.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,10 @@ title: Discovery
3
3
description: "Learn how Tempest automatically locates controller actions, event handlers, console commands, and other components of your application."
4
4
---
5
5
6
+
:::info
7
+
Read the [getting started with discovery](/blog/discovery-explained) guide if you are new to Tempest.
8
+
:::
9
+
6
10
## Overview
7
11
8
12
Tempest introduces a unique approach to bootstrapping an application. Instead of requiring manual registration of project code and packages, Tempest automatically scans the codebase and detects the components that should be loaded. This process is called **discovery**.
0 commit comments