obsidian-moon / framework
一个开源、轻量级且100%模块化的PHP框架
2.1.0
2022-12-01 17:59 UTC
Requires
- php: >=8.1
- obsidian-moon/engine: ^2.1
Requires (Dev)
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-09-29 06:03:14 UTC
README
安装Obsidian Moon Framework
由于Obsidian Moon Engine使用了Composer,您需要在运行代码之前先安装它。安装Composer后,您可以通过以下命令安装它:
composer create-project obsidian-moon/framework
安装完成后,您可以通过在composer.json文件中输入以下内容来更改应用程序文件的命名空间:
{
"autoload": {
"class-map": ["app/"],
"files": ["app/mix.php"],
"psr-4": {
"ObsidianMoon\\Framework\\": "app/"
}
}
}
文件结构
安装完成后,您会发现应用程序将由以下结构组成。
.
|-- app/ // Application namespace root
| |-- Controllers/ // Controllers for handling routes
| |-- Entity/ // For storing entities, to be explained later
| |-- Modules/ // Modular classes for handling various functionality
|-- config/ // For the presession modifications used by OME
| |-- environment.php // Modifies system values if needed, before the session is started
| |-- routes.php // Routes for the application
|-- node_modules/ // If you use something like webpack, you would .gitignore this folder.
|-- public/ // Contains all the files that are available to user, eg. js, css, images, etc.
| |-- .htaccess // Look in examples for how to best set this
| |-- index.php // The primary entry point to your application.
| |-- ...
|-- src/ // Required library directory used by OME
| |-- js/ // Store your JS source files for webpack
| |-- scss/ // SCSS that will be processed by webpack
| |-- views/ // All view files will go in here
| |-- ...
|-- vendor/ // Composer files needed for application, you can gitignore this
|-- common.php
|-- composer.json
|-- ...
Apache支持
如果您使用Apache,您可以使用以下内容在应用程序的public文件夹中的.htaccess文件中开始设置路由:
<IfModule mod_rewrite.c> # Enabling the mod_rewrite module in this folder RewriteEngine On Options -Indexes # Redirects invalid locations to index RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule>
在public文件夹中包含了一个具有缓存的更完整的.htaccess文件。
基础方法概述
该框架使用Obsidian Moon Engine,您可以在其README.md中找到关于这些方法的更多详细信息。
致谢
Obsidian Moon Framework建立在Obsidian Moon Engine之上,并在其开发过程中使用了以下库和项目:
- PHP 8 和 Composer 包管理器。
- Symfony 6 Components 用于HTTP请求和路由。
- Node.js 和 NPM。
- Laravel Mix,webpack的包装器,用于编译资源。
- HTML5 Boilerplate,选择特性以创建模板和视图的HTML5基础。
- ESLint 和 StyleLint 用于确保源JS和SCSS中的编码正确。