ivanamat/cakephp3-documents
Composer 安装命令:
composer require ivanamat/cakephp3-documents
包简介
CakePHP 3.x - Markdown Documents
README 文档
README
Installation
Composer {#composer}
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require ivanamat/cakephp3-documents
Git submodule {#gitsubmodule}
git submodule add git@github.com:ivanamat/cakephp3-documents.git plugins/Documents
git submodule init
git submodule update
Manual installation
Download the .zip or .tar.gz file, unzip and rename the plugin folder "cakephp3-documents" to "Documents" then copy the folder to your plugins folder.
Configuration
Load plugin
Plugin::load('Documents', ['bootstrap' => false, 'routes' => true]);
Database
Import documents.sql config/cheme/documents.sql or execute the SQL commands.
# documents.sql DROP TABLE IF EXISTS `categories`; CREATE TABLE `categories` ( `id` int(11) NOT NULL AUTO_INCREMENT, `parent_id` int(11) DEFAULT NULL, `lft` int(11) DEFAULT NULL, `rght` int(11) DEFAULT NULL, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `public` tinyint(1) NOT NULL DEFAULT '0', `created` datetime NOT NULL, `modified` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `slug` (`slug`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; DROP TABLE IF EXISTS `documents`; CREATE TABLE `documents` ( `id` int(11) NOT NULL AUTO_INCREMENT, `category_id` int(11) DEFAULT NULL, `user_id` int(11) NOT NULL, `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `body` text COLLATE utf8_unicode_ci, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Bootstrap
Set in your bootstrap file src/config/bootstrap.php.
Specify your homepage's URL.
Configure::write('Documents.home', ['plugin' => false, 'controller' => 'Pages', 'action' => 'display', 'home']);
Create your own INDEX.md and specify the path.
Configure::write('Documents.index', '../INDEX.md');
If the ACL plugin is loaded, you can set action's permissions.
/** * Allow CategoriesController actions * @actions: index, edit */ Configure::write('Categories.auth.allow', ['index','edit']); /** * Allow DocumentsController actions * @actions: index, view, add, edit, delete **/ Configure::write('Documents.auth.allow', ['index','view']);
Component and Helper
Documents has a component named DocsComponent and a helper named DocsHelper, both with the same methods.
Methods
slugCategory($id)
$id int Category id
return string Returns category slug
$slug = $this->Docs->slugCategory($id); # Example $slug value: 'proyectos/cakephp/plugins' echo '<a href="/' . $this->plugin . DS . $slug . '"><strong>'.$category->title.'</strong></a>';
slugDocument($id)
$id int
return string Returns document slug
$slug = $this->Docs->slugDocument($id); # Example $slug value: 'proyectos/cakephp/plugins/cakephp-3-x-markdown-documents' echo '<a href="/' . $this->plugin . DS . $slug . '"><strong>'.$document->title.'</strong></a>';
getCategory($id)
$id int Category id
return object Category
$category = $this->Docs->getCategory($id); echo '<h2>'.$category->title.'</h2>';
getParentSlug($slug)
$slug string Slug
return string Parent slug
# $slug = 'projects/cakephp/plugins/cakephp-3-x-markdown-documents' $parentSlug = $this->Docs->getParentSlug($slug); # $parentSlug will output 'projects/cakephp/plugins' echo '<a href="/' . $this->plugin . DS . $parentSlug . '"><strong>Parent category</strong></a>';
getRelatedDocuments($id)
$id int Category id
return array Array of documents from categories children of the specified category
$relatedDocuments = $this->Docs->getParentSlug($slug); foreach($relatedDocuments as $document) { echo '<h4>' . $document->title . '</h4>'; echo $this->Markdown->parse($document->body); }
About CakePHP 3.x - Markdown Documents
CakePHP 3.x - Markdown Documents require CakePHP 3.x - Markdown plugin.
Friendly URLs!
The URLs generated are all friendly.
Example: http://www.example.com/Documents/tutorials/cakephp/plugins/cakephp-3-x-documents
Author
Iván Amat on GitHub
www.ivanamat.es
ivanamat/cakephp3-documents 适用场景与选型建议
ivanamat/cakephp3-documents 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.22k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 08 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「markdown」 「cakephp」 「documents」 「extra」 「parsedown」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ivanamat/cakephp3-documents 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ivanamat/cakephp3-documents 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ivanamat/cakephp3-documents 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Adds more BBCode
Email Toolkit Plugin for CakePHP
Rhino, a CMS and Application-Framework plugin for CakePHP
A CakePHP plugin for sending mail via SparkPost's REST API
统计信息
- 总下载量: 1.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-12