cmouleyre/lunacms
Composer 安装命令:
composer require cmouleyre/lunacms
包简介
LunaCMS is a lightweight and high-performance content management system.
README 文档
README
Overview
LunaCMS is a lightweight and extensible PHP library for building content management system (CMS) websites. It leverages modern PHP components such as Twig for templating, Doctrine DBAL for database interactions, PHPMailer for email handling, and Redis for optional caching. LunaCMS is designed to help developers create modular, maintainable, and flexible small to medium-scale websites quickly and efficiently.
Features
- MVC Architecture: Implements the Model-View-Controller pattern for clear separation of logic, presentation, and data.
- Twig Templating: Offers a powerful and flexible templating engine for building dynamic web pages.
- Site Structure Generation: Automates the creation of the site structure using the
SiteGeneratorcommand-line tool. - Database Management: Uses Doctrine DBAL for handling database connections and queries.
- Email Integration: Built-in support for sending emails using PHPMailer.
- Routing System: A simplified routing system for handling HTTP requests and mapping them to controllers.
- Redis Integration: Optional support for Redis caching to enhance performance.
- Asset Management: Uses Gulp to compile SCSS and JavaScript assets for efficient delivery.
Requirements
- PHP: 7.4 or higher
- Composer: For managing PHP dependencies
- Node.js and npm: For Gulp and asset management
- PHP Extensions:
- PDO (with MySQL support)
- cURL
- PHPMailer
- (Optional) Redis PHP extension if using Redis caching
Installation
Prerequisites
- PHP 7.4 or higher
- Composer
- Node.js and npm
- Gulp CLI: Install globally using:
npm install --global gulp-cli
Steps
-
Clone the Repository
git clone https://github.com/yourusername/lunacms.git
-
Navigate to the Project Directory
cd lunacms -
Install PHP Dependencies
composer install
-
Install Node.js Dependencies
npm install
-
Generate the Site Structure Use the CLI script to generate the necessary directories and files.
cd vendor/cmouleyre/lunacms/ php create_site.php /path/to/new/site -
Configure the Project Edit the
config/config.jsonfile with your project-specific settings. -
Build Assets
npm install gulp sass gulp-sass gulp-uglify gulp-clean-css --save-dev gulp
Usage
Generating a New Site Structure
Use the command-line tool to create a new site structure. This will generate all the necessary directories and configuration files:
php create_site.php /path/to/new/site
Configuration
LunaCMS uses a configuration file located at config/config.json. This file contains:
- Database Settings: Configure the database connection (host, user, password, etc.).
- Mail Server Settings: For PHPMailer integration.
- Site Information: Such as the base URL and site name.
- Debug Settings: Enable or disable debug mode.
Controllers
LunaCMS follows an MVC architecture, using controllers to handle requests. Create new controllers by extending the Controller class:
namespace App\Controllers; use LunaCMS\Controller; class MyCustomController extends Controller { public function dataAssignment(): void { $this->template = 'custom_template'; $this->addVar('meta_title', 'Custom Page Title'); $this->addVar('meta_description', 'Custom Page Description'); } }
Redis Caching
LunaCMS supports Redis caching if the Redis PHP extension is installed. Example usage:
- Set a value in Redis:
$this->setRedisValue('key', 'value', $ttl);
- Get a value from Redis:
$value = $this->getRedisValue('key');
If Redis is not available, these methods will fail silently.
Sending Emails
You can send emails with PHPMailer using LunaCMS's built-in functionality:
$this->sendEmail('recipient@example.com', 'Recipient Name', 'Subject', 'HTML Body', 'Plain Text Alternative');
Make sure to configure the email settings in the config/config.json file.
Routing
Routing in LunaCMS is handled by the Routing class. Define your routes in config/routes.php:
use App\Controllers\PageController; return [ '' => PageController::class, '{slug}' => PageController::class, ];
This allows you to map URLs to specific controllers easily.
Project Structure
/your-project
│
├── assets
│ ├── js
│ │ └── script.js
│ └── scss
│ └── main.scss
│
├── cache
│ └── twig
│
├── config
│ ├── config.json
│ └── routes.php
│
├── public
│ ├── css
│ ├── js
│ ├── img
│ └── index.php
│
├── src
│ └── Controllers
│ └── PageController.php
│
├── templates
│ ├── includes
│ │ └── base.twig
│ └── index.twig
│
├── vendor
│
└── gulpfile.js
Key Directories and Files
- assets/: Contains JavaScript and SCSS source files.
- cache/twig/: Stores cached Twig templates. Ensure this directory is writable.
- config/: Configuration files.
- config.json: Main configuration file.
- routes.php: Defines the application routes.
- public/: The web root directory.
- index.php: The application entry point.
- css/, js/, img/: Compiled assets.
- src/Controllers/: Controller classes.
- PageController.php: Example controller.
- templates/: Contains Twig templates.
- includes/base.twig: Base template for reusability.
- index.twig: Example page template.
- vendor/: Composer dependencies.
- gulpfile.js: Gulp configuration for asset compilation.
License
LunaCMS is open source and licensed under the MIT License. You are free to use, modify, and distribute it in accordance with the license terms.
Contributing
Contributions are welcome! If you'd like to contribute, please fork the repository and submit a pull request with your changes.
Feel free to reach out if you need more guidance or if anything is unclear.
cmouleyre/lunacms 适用场景与选型建议
cmouleyre/lunacms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 09 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「cms」 「content-management」 「lunacms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cmouleyre/lunacms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cmouleyre/lunacms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cmouleyre/lunacms 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Pico is a flat file CMS, this means there is no administration backend and database to deal with. You simply create .md files in the "content" folder and that becomes a page.
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
Integrate with Snipcart.
A Laravel package to add follow/unfollow functionality to Eloquent models.
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-21