Filament Title With Slug 项目教程
1. 项目目录结构及介绍
filament-title-with-slug/
├── config/
│ └── filament-title-with-slug.php
├── docs/
│ └── README.md
├── resources/
│ ├── lang/
│ └── views/
├── src/
│ ├── Components/
│ ├── Filament/
│ └── TitleWithSlugInput.php
├── tests/
├── .editorconfig
├── .gitattributes
├── .gitignore
├── LICENSE.md
├── README.md
├── composer.json
├── package-lock.json
├── package.json
├── phpstan-baseline.neon
├── phpstan.neon.dist
├── phpunit.xml.dist
├── pint.json
├── postcss.config.js
└── tailwind.config.js
目录结构介绍
- config/: 包含项目的配置文件
filament-title-with-slug.php
。 - docs/: 包含项目的文档文件,如
README.md
。 - resources/: 包含项目的语言文件和视图文件。
- lang/: 包含多语言翻译文件。
- views/: 包含视图模板文件。
- src/: 包含项目的源代码。
- Components/: 包含自定义组件的代码。
- Filament/: 包含与 Filament 相关的代码。
- TitleWithSlugInput.php: 主要功能实现文件。
- tests/: 包含项目的测试代码。
- .editorconfig: 编辑器配置文件。
- .gitattributes: Git 属性配置文件。
- .gitignore: Git 忽略文件配置。
- LICENSE.md: 项目许可证文件。
- README.md: 项目介绍文件。
- composer.json: Composer 依赖管理文件。
- package-lock.json: 锁定依赖版本文件。
- package.json: Node.js 依赖管理文件。
- phpstan-baseline.neon: PHPStan 静态分析配置文件。
- phpstan.neon.dist: PHPStan 配置文件。
- phpunit.xml.dist: PHPUnit 测试配置文件。
- pint.json: Pint 配置文件。
- postcss.config.js: PostCSS 配置文件。
- tailwind.config.js: Tailwind CSS 配置文件。
2. 项目启动文件介绍
项目的主要启动文件是 src/TitleWithSlugInput.php
。该文件定义了 TitleWithSlugInput
类,用于在 Filament 表单中添加标题和 slug 输入字段。
namespace Camya\Filament;
use Filament\Forms\Components\TextInput;
class TitleWithSlugInput extends TextInput
{
// 类实现代码
}
3. 项目配置文件介绍
项目的配置文件位于 config/filament-title-with-slug.php
。该文件包含了项目的各种配置选项,如标签、占位符、slug 生成规则等。
return [
'labels' => [
'title' => 'Title',
'slug' => 'Slug',
],
'placeholders' => [
'title' => 'Enter title here',
'slug' => 'Enter slug here',
],
'slug_generator' => 'default', // 默认 slug 生成器
'permalink_preview' => [
'hide_host' => false, // 是否隐藏主机名
],
];
通过修改该配置文件,可以自定义项目的各种行为和显示效果。