ginger-tek/jerpy
Composer 安装命令:
composer create-project ginger-tek/jerpy
包简介
Simple, extendable, flat-file PHP website
关键字:
README 文档
README
jerpySimple - Extendable - Flat-file
Jerpy a simple, extendable, flat-file simple website system built for control and ease-of-use that is easy to install, customize, and maintain.
NOTE: Jerpy isn't a traditional CMS and doesn't have a management interface or web portal (but there could be a plugin for that...). Everything is managed directly via the files themselves.
Getting Started
Composer
composer create-project ginger-tek/jerpy <directory>
Files & Folders
-
Set the timezone override, selected layout, enabled global plugins, and page routes here.config.php -
Stores layout templates, each their ownlayouts.phpfile. The default global theme is set inconfig.phpvia the$layoutproperty. The value is just the file name with no extension. -
Organize your CSS, JavaScript, fonts, and images to use in your layouts and pages via absolute URI hereassets -
For all your embedded content files, such as Markdown text files, and is not URL-accessible.content
Pages & Routes
Routes are configured in an associative array of a route key and page value. The value can be either a string or an associative array. If a string, the value is rendered using the default template, and the string is expected to be the filename of a page in the pages folder. If an associative array, there must be at least a page key and value. Optionally, a meta key and value can be set to include metadata for the given route, as well as a layout key and value to override the default layout, or not use one at all.
Example routes config:
$routes = [ '/' => [ 'page' => 'home.php', 'meta' => [ 'title' => 'Welcome to my site!' ] ], '/about' => [ 'page' => 'about.php', 'meta' => [ 'title' => 'About Us', 'thumbnail' => '/assets/my_thumbnail.png' ], 'layout' => 'layout_2' ], '/simple/page' => 'simple_page.php', '/page/without/layout' => [ 'page' => 'some_page.php', 'layout' => false ] ]
When implementing metadata, use null coalescing syntax to avoid warnings when a route does't have that metadata property specified:
<head> ... <meta name="og:title" content="<?= $meta['title'] ?? '' ?>"> <meta name="og:description" content="<?= $meta['description'] ?? '' ?>"> <meta name="og:image" content="<?= $meta['thumbnail'] ?? '' ?>"> ... </head>
Dynamic Routes
To use dynamic route parameters, use the :param syntax in the route key string. All matches values will be accessible from the $params variable:
$routes = [ '/products/:id' => [ 'page' => 'product.php' ] ];
product.php:
<p>ID: <?= $params['id'] ?></p>
Templating
PHP's built-in templating is sufficient for most websites. As such, just use include and require as you would normally for templating your site, parsing content as needed (see plugins).
Global Variables
| Name | Data Type | Note |
|---|---|---|
$uri |
object |
Clean URI value |
$params |
array |
Any metadata key/values specified for the matched route |
$page |
string |
Path to the page file being rendered |
$meta |
array |
Any metadata key/values specified for the matched route |
$layout |
array |
Current layout |
Plugins
Plugins can be created to extend or add functionality to Jerpy. They do not require any specific framework nor follow any particular design pattern. The only requirement for plugins is that the entrypoint is a .php file with the same name as the plugin's folder. From there, you can use whatever preferred tools and package managers to create the plugin code, such as Composer.
🗀 plugins
🗀 myPlugin <-- plugin dir
🗋 composer.json
🗋 myPlugin.php <-- entrypoint (same name as plugin dir)
🗀 vendor
🗀 someSupportingPackage
Enabling Plugins
Plugins can be included/required on a given page file as needed, or you can load it globally to be used on every page. To add a plugin, simply copy/upload the plugin's folder to the plugins directory.
To enable a plugin globally, add it's folder name to the $plugins array in config.php:
$plugins = [ 'md' ];
To enable a plugin only when a certain URI is matched, set a string key to check if the incoming URI starts with it:
$plugins = [ '/admin' => 'admin' // only loaded when /admin* is requested ];
Plugin Example
Below is an example plugin for using Parsedown via a wrapper method:
NOTE: When including/requiring files within a plugin, make sure to use the __DIR__ global to ensure PHP looks within the plugin directory and not in the root directory of the site
plugins/md/md.php
<?php require __DIR__ . '/vendor/autoload.php'; function md(string $path): string { return (new Parsedown)->text(file_get_contents($path)); }
config.php
$plugins = [ 'md' ];
pages/some-page.php
<?= md('content/markdown-file.md') ?>
ginger-tek/jerpy 适用场景与选型建议
ginger-tek/jerpy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 32 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「cms」 「website」 「flat-file」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ginger-tek/jerpy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ginger-tek/jerpy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ginger-tek/jerpy 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
Platine Database is the abstraction layer using PDO with support of query and schema builder
Integrate with Snipcart.
Follow, Favourite, Bookmark, Like & Subscribe.
统计信息
- 总下载量: 32
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: ISC
- 更新时间: 2024-01-22