ivanamat/cakephp3-documents 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 ivanamat/cakephp3-documents 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-12