Skip to content

Commit f1f5dae

Browse files
authored
Merge pull request #5 from dotkernel/file-structure
updated admin usage page
2 parents e34be06 + 72fed9b commit f1f5dae

5 files changed

Lines changed: 96 additions & 9 deletions

File tree

docs/book/v1/admin/usage.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
# Usage
22

3-
Dotkernel API can be installed independently or together with other applications in the Dotkernel suite, based on your business requirements.
3+
Dotkernel Admin can be installed independently or together with other applications in the Dotkernel suite, based on your business requirements.
44
These components are designed to complement each other (out-of-box they are separate codebases):
55

66
- **Dotkernel API** exposes the content to 3rd-party frontends or backends.
77
- **Dotkernel Admin** (optional) manages the data (create, edit, delete).
88
- **Dotkernel Queue** (optional) queue management microservice.
99

10-
A safe bet is to start with Dotkernel API and integrate it into your existing platform.
11-
The API can manage the access permissions to keep your data secure:
12-
13-
- Admin-level users create and edit the data for your existing backend.
14-
- Regular users read the data for your frontend.
10+
You can start with Dotkernel Admin and integrate it into your existing platform.
11+
The Admin has built-in reports and graphs that can be configured and customized based on your needs.
1512

1613
Later on you can add:
1714

18-
- Dotkernel Admin for its simple table-based approach, its reports and graphs.
15+
- Dotkernel API to handle all data manipulation.
1916
- Dotkernel Queue for its asynchronous task processing.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Benefits
2+
3+
- **Centralized setup** – Instead of hardcoding bootstrap code, you declare it in a config provider so it's easy to read, change, or extend.
4+
- **Modular** – Each package can ship with its own config without interfering with others.
5+
- **Container-friendly** – It works well with frameworks using DI containers like Laminas ServiceManager, PHP-DI, or Pimple.
6+
- **Standardized service definitions** - It has consistent rules for object creation that are separate from business logic.
7+
- **Environment-agnostic** - It returns an array that defines dev, test, or prod environments.
8+
- **Testability** - The consistent, central configuration promotes isolated (e.g. per-module) testing, easier swapping of dependencies and the assertion of pipeline setup (e.g. check if a config key is present).
9+
10+
> **Dotkernel ConfigProviders** have to be **added manually** in `config/config.php`, because all the initial ConfigProviders required to install the applications are already injected.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# How the ConfigProvider works
2+
3+
The ConfigProvider is automatically picked up by the framework during application bootstrap.
4+
Let's look at it step by step:
5+
6+
- **Merge the global configuration** - All ConfigProviders are merged into one array.
7+
- **Read the configuration array** - The call is similar to the below and expects an array of entries:
8+
9+
```php
10+
$config = $container->get('config')['key'] ?? [];
11+
```
12+
13+
- **Resolve item** - `$app->pipe()` is called to resolve one of the below instances:
14+
- Resolve the service name from the container
15+
- Wrap the middleware, if an array is provided
16+
- Call the closure or invokable object.
17+
- **Handle errors** - This middleware is the last one in the pipeline to make sure it handles any exceptions.
18+
- **Execute at runtime** - [Laminas Stratigility](https://docs.laminas.dev/laminas-stratigility/) iterates over the pipeline in the order it was registered.
19+
- Each middleware can **handle** the request and return a response, or **delegate** execution to the next middleware in the pipeline, until a `ResponseInterface` is returned to the client.
20+
21+
Below you can see how Mezzio and Dotkernel merge and use ConfigProviders to build the middleware pipeline and dependencies.
22+
23+
![Headless Platform with Core Submodule](https://docs.dotkernel.org/img/headless-platform/ConfigProvider.png)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Introduction
2+
3+
In PHP, the `ConfigProvider` is a class that is part of an application's bootstrap process.
4+
It returns an array of configuration, settings, or anything else your application needs.
5+
In Dotkernel, each application module and package contains a `ConfigProvider` that normally returns:
6+
7+
- Dependency injection mappings.
8+
- Request Handlers.
9+
- Template file paths.
10+
11+
Here is an example in Dotkernel, which is an approach similar to Laminas/Mezzio:
12+
13+
```php
14+
class ConfigProvider
15+
{
16+
public function __invoke(): array
17+
{
18+
return [
19+
'dependencies' => $this->getDependencies(),
20+
'templates' => $this->getTemplates(),
21+
];
22+
}
23+
24+
public function getDependencies(): array
25+
{
26+
return [
27+
'factories' => [
28+
Handler\HomepageHandler::class => Handler\HomepageHandlerFactory::class,
29+
Handler\SearchHandler::class => Handler\SearchHandlerFactory::class,
30+
],
31+
'invokables' => [
32+
Console\GenerateSearchData::class => Console\GenerateSearchData::class,
33+
],
34+
];
35+
}
36+
37+
public function getTemplates(): array
38+
{
39+
return [
40+
'app' => [__DIR__ . '/../templates/app'],
41+
'error' => [__DIR__ . '/../templates/error'],
42+
];
43+
}
44+
}
45+
```
46+
47+
All Dotkernel applications and packages use ConfigProviders:
48+
49+
- [Dotkernel API](https://docs.dotkernel.org/api-documentation/)
50+
- [Dotkernel Admin](https://docs.dotkernel.org/admin-documentation/)
51+
- [Dotkernel Frontend](https://docs.dotkernel.org/frontend-documentation/)
52+
- [Dotkernel Light](https://docs.dotkernel.org/light-documentation/)
53+
- [Dotkernel Packages](https://docs.dotkernel.org/packages/)

mkdocs.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ nav:
2020
- "Creation": v1/core/creation.md
2121
- "Usage": v1/core/usage.md
2222
- "Benefits": v1/core/benefits.md
23-
site_name: headless
24-
site_description: "Headless Platform"
23+
- "ConfigProvider":
24+
- "Introduction": v1/config-provider/introduction.md
25+
- "Functionality": v1/config-provider/functionality.md
26+
- "Benefits": v1/config-provider/benefits.md
27+
site_name: "Dotkernel Headless Platform"
28+
site_description: "Dotkernel Headless Platform"
2529
repo_url: "https://github.com/dotkernel/headless-documentation"
2630
plugins:
2731
- search

0 commit comments

Comments
 (0)