jamisonbryant/cakephp-secureids-plugin 问题修复 & 功能扩展

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

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

jamisonbryant/cakephp-secureids-plugin

Composer 安装命令:

composer require jamisonbryant/cakephp-secureids-plugin

包简介

A CakePHP plugin for using secure, non-incremental IDs for entities

README 文档

README

A CakePHP plugin for using secure, non-incremental IDs for models.

Introduction

What are Secure IDs?

Secure IDs are a way to use non-incremental, non-guessable, randomly-generated unique identifiers to records in your database. This solves a whole host of problems, from usability to security and beyond. For more information, check out Tom Scott's great video Will YouTube Ever Run Out of Video IDs?

What is CakePHP?

CakePHP is a rapid-development PHP web application framework that uses the MVC (Models/Views/Controllers) architecture. It was first released in August 2005 and is now on version 3.0 and is more powerful than ever! One of CakePHP's great features is that it supports extending its own functionality via the use of plugins, of which this is one.

For more information about CakePHP, visit their website at CakePHP.org.

Installation

Prerequisites

  • PHP 7.x
  • CakePHP 3.x

Command-Line Installation

Using Composer is the recommended way of installing this plugin because it allows you to easily download the plugin and its dependencies and keep them up-to-date and make use of Composer's awesome class auto-loader.

To install the plugin using Composer:

  1. Open a terminal and cd to your CakePHP application's root directory.
  2. Run composer require jamisonbryant/cakephp-secureids-plugin to download the plugin and its dependencies.
  3. If you'd like, open composer.json for editing and modify the versioning schema for the plugin to your liking.

Manual Installation

You can also install the plugin manually by clicking the "Download ZIP" button above and unzipping it into your CakePHP application's plugins/ directory, however if you do this you will have to perform updates manually as well.

If you're familiar with git you can also download the repository directly to your hard drive using git clone. This allows you to stay on the bleeding-edge of the plugin's development, but be warned that it's called "bleeding-edge" for a reason.

Setup

To add the plugin to your application, activate the plugin in your application's bootstrap file:

Plugin::load('SecureIds');

Or use the Cake shell:

./bin/cake plugin load SecureIds

NOTE: You must add the columns bid (for Base64 ID) and uuid (for UUID) to the table schemas of each model you want to have secure IDs. You can do this easily by running the included migration (requires the CakePHP Migrations plugin):

./bin/cake migrations migrate -p SecureIds

Usage

Because the plugin's functionality is implemented as a Behavior, you need to apply the behavior (called the Identifiable behavior) to each model you want to use it on. To do this, you need to create a table definition class for each model that you want to be able to fetch secure IDs for:

// File: src/Model/Table/ArticlesTable.php

namespace App\Model\Table;

use Cake\ORM\Table;

class ArticlesTable extends Table
{
    public function initialize(array $config)
    {
        $this->addBehavior('SecureIds.Identifiable');
    }
}

The above code assumes that we are working with an Article model, obviously you should substitute your own model name. Note: You may (read: probably will) have to create a table definition file for each model, because CakePHP does not do this for you by default, preferring instead to infer what your table definition is like on-the-fly. This is great for most use cases, however when we want more control (to add a behavior, say), we need to create the files ourselves.

Testing

You can test the plugin using CakePHP's built-in support for PHPUnit, however this assumes two things:

  1. You have PHPUnit globally installed and the phpunit command available from the command-line
  2. You didn't delete the phpunit.xml.dist that is created with new CakePHP 3.x applications

To test the plugin, first add its test suites to the application's PHPUnit config file:

<?xml version="1.0" encoding="UTF-8"?>

<phpunit ...>
    ...
    <testsuites>
        <testsuite name="App Test Suite">
            <directory>tests/TestCase</directory>
        </testsuite>

        <!-- Add these lines -->
        <testsuite name="Secure IDs Plugin Test Suite">
            <directory>vendor/jamisonbryant/cakephp-secureids-plugin/tests/TestCase</directory>
        </testsuite>
    </testsuites>
    ...
</phpunit>

Next, cd to your application's root directory and run phpunit.

If that doesn't work, run composer dump-autoload and try again.

Contributing

Bug Reports

If you find a bug in the plugin, or know of a missing feature you'd like to see added, feel free to create an issue on the Issues page. When reporting a bug, be as descriptive as possible. Include what you were doing when the bug occurred, what might have caused it to occur, and how to reproduce it if possible. Screenshots are nice, too.

As a matter of courtesy, please use the search tool to verify that an issue has not already been reported before creating a new issue. Feel free to add your comments/+1's to an open bug/feature request, but duplicate issues take time to prune and crowd out new, important issues.

Pull Requests

Found a bug you think you can fix? By all means go ahead! Clone the affected branch, fix the bug, then create a pull request and I'll review and accept it as quickly as I can. However, before submitting a pull request, please be sure that your code follows the PSR-2 code style guidelines. PRs that don't follow the style guidelines will be rejected! (politely, of course)

Legal

License

Licensed under the MIT License (MIT). See LICENSE.md for details.

Copyright

Copyright (c) 2019 Jamison Bryant. All rights reserved.

jamisonbryant/cakephp-secureids-plugin 适用场景与选型建议

jamisonbryant/cakephp-secureids-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 328 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 04 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「security」 「plugin」 「cakephp」 「base64」 「uuid」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 jamisonbryant/cakephp-secureids-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jamisonbryant/cakephp-secureids-plugin 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 328
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-02