thbighead/wordless-framework

Wordless Framework。

v8.2.8 2024-10-03 18:41 UTC

This package is auto-updated.

Last update: 2024-10-03 18:42:02 UTC


README

Wordless 项目框架。

目录和文件组织

主要目录和文件

| assets (Publishable directories)
| \
|  | config (Keep base configuration files)
|  | stubs (Keep files stubs to generate new ones)
| docker (Local development environment containers to work with framework changes)
| logs (Local development environment log files)
| src
| \
|  | Application (Classes implementation, just like in project app directory)
|  | \
|  |  | Cachers (Classes to keep internal caches)
|  |  | Commands (Wordless CLI commands. Make new as you wish, customize carefully)
|  |  | Guessers (Classes to guess values)
|  |  | Helpers (Keep helper classes)
|  |  | Libraries (Library directories with useful abstractions)
|  |  | Listeners (Keep listener classes for Wordpress hooks (Events))
|  |  | Mounters (Class implementations which mount files with dynamic contents from stubs)
|  |  | Providers (Classes which register any Application class as a group)
|  | Core (Core Wordless classes, they raise all framework functionalities)
|  | Infrastructure (Abstract classes used by Application and Wordpress)
|  | Wordpress (Wordpress adapted class abstractions)
|  |>ide_helper.php (File to help IDEs helping the developers using or improving this framework)
| tests (Automated tests)
| \
|  | coverage (files with test coverage results in any format)
|  | Unit (Class methods unitary tests)
|>composer.json (Composer)
|>console (Wordless CLI file)
|>docker-compose.yml (Docker Compose configurations for local environment to work with framework changes)
|>env.php (Adapted file to load environment variables needed when changing Frameworn into local development environment)
|>phpunit.xml (PHP Unit configuration)
|>wp-cli.yml (WP CLI configuration)
|>wp-config.php (Adapted Wordpress configuration for Framework local development environment)

相对目录

在任何一个 主目录 中,我们可能有以下目录

| Contracts (Useful Interfaces or abstract classes with abstract methods)
| DTO (Useful DTO implementations to avoid complex array data configuration)
| Enums (Useful Enums to avoid magic values)
| Exceptions (Keeps custom Exceptions. Better then if-else)
| Traits (Traits used to group methods, properties and constants in a scope or to be used in more than one specialized class.)

Docker

为了提供一个开发环境,Wordless Framework 提供以下容器

工作空间

这是主要容器,您可以通过它访问 PHP、Composer、NPM 和 Wordless CLI 控制台。通常,这是您将与应用程序交互的大部分时间。要访问它,请在 访问指南 中按照说明操作,在您已 启动容器 后。

MariaDB

这个容器负责创建和管理您的数据库。

Adminer

Adminer 是一个允许通过浏览器进行数据库交互的容器,提供了一个界面来执行与数据库相关开发所需的各种任务。通过浏览器在 localhost:8081 访问它。

命令

启动容器

要启动容器,使用 up 命令,该命令将启动每个容器。如果容器尚未创建,此命令还将构建它们。

使用 -d 标志可以在非详细模式下执行此命令。换句话说,您不会收到容器的输出,这将使终端可用于其他任务。

docker compose up -d

访问容器

一旦容器创建并启动,您可以使用 exec 命令在容器内导航。在每个容器内,您可以利用每个容器的特定功能。指定要执行的容器;在这种情况下,我们正在执行工作空间。

使用 --user 标志指示登录容器的用户。通常,laradock 是默认值,但在某些需要更高权限配置文件的情况下,您可以通过不使用此标志来使用 root

docker compose exec --user=laradock workspace bash
docker compose exec workspace bash # as root

异常代码

我们的异常类使用标准化的代码来提供有关抛出问题的信息。它们的意义如下

  1. 内部捕获:这些异常不应中断应用程序,因为它们(或应该总是)在每次抛出时被框架本身捕获;
  2. 开发错误:这是一种只有在开发错误发生时才会中断应用程序的异常;
  3. 逻辑控制:它控制任何应用程序逻辑。它可能被 try-catch 代码包裹,也可能没有,这取决于开发者的期望;
  4. 有意中断:不应捕获这些异常,这些异常是为了始终中断应用程序而创建的。