承接 memcrab/exceptions 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

memcrab/exceptions

Composer 安装命令:

composer require memcrab/exceptions

包简介

PHP based Exceptions lib for memCrab Core API

README 文档

README

Status

Build Status Dependency Status Total Downloads Latest Stable Version Latest Unstable Version License composer.lock available

It's php router based on yaml configuration file and support regular expressions in each route condition. Thats help build more accurate routes with only numbers in part of url or with required part of word etc.

Features

  • Support RegExp in any kind of route
  • Support multiple routings for single url throw different request methods (POST, GET, PUT, DELETE, ...)
  • Support full url or just request uri
  • All configurations in simple YAML file
  • Each route can return already named params (as many params as you want, or as you have in Regular Expression)
  • High performance yaml parse throw using updated pecl yaml-ext 2.0.0 for php 7.0
  • Strict standart coding with full Typing of params and returns (by php 7.1)
  • PSR-4 autoloading compliant structure
  • Unit-Testing with PHPUnit
  • Easy to use to any framework

Install

composer require memcrab/router

Dependencies

php extension YAML:

  • for Ubuntu/Debian
- apt-get update
- apt-get install php-pear
- apt-get install php-dev
- apt-get install php-xml php7.0-xml
- apt-get install libyaml-dev
- pecl channel-update pecl.php.net
- pecl install yaml-2.0.0
  • for OS X
- brew install php71 --with-pear
- brew install autoconf
- touch $(brew --prefix php71)/lib/php/.lock && chmod 0644 $(brew --prefix php71)/lib/php/.lock
- pecl install yaml-2.0.0

Usage

  • init Router: memCrab\Router()
  • load routes: ->loadRoutesFromYaml(string $filePath)
    • $filePath - Path to yaml files with routes
  • run matching: ->matchRoute(string $url, string $method)
    • $url - URL (http://example.com/posts) or just request URI of page (/post)
    • $method - http request method
  • use your router data with:
    • getService() - return component that we call
    • getAction() - return action that will be run from component
    • getParams() - return route regExp params

Yaml Config Example

routes:
  /:
    GET: [Index, getMain]
  /post/:
    GET:    [Post, get]
    POST:   [Post, add]
    PATCH:  [Post, save]
    DELETE: [Post, delete]
  /post/publish/:
    POST: [Post, setPublishing]
  /catalog/([a-zA-Z0-9]+)-([a-zA-Z0-9]+)/: 
    GET: [Catalog, filter, key1, value1]

Run Example

require_once __DIR__ . "/../vendor/autoload.php";

use memCrab\Router\Router;
use memCrab\Router\RouterException;

try {
  # Initialize Router
  $Router = new Router();
  $Router->loadRoutesFromYaml("../src/routs.example.yaml");
  
  # Routing
  $Router->matchRoute("http://example.com/post/", "POST");    
  
  # Run your Controller|Service|Component
  $ServiceName = $Router->getService();
  $Service = new $ServiceName();
  $Action = $Router->getAction();
  $Response = $Service->$Action($Router->getParams());
}
catch(RouterException $error){
  $Response = new \YourResponseClass();
  $Response->setErrorResponse($error);
}

$Response->sendHeaders();
$Response->sendContent();

TODOS

  • Add support for suffixes - right part of uri that not involved in routing like .html, .php, last "/", etc
  • Add support for prefixes - left part of uri that not involved in routing like lang part (uk/us/fr/ru) or geo part (europe/asia), etc

MIT Licensed

memcrab/exceptions 适用场景与选型建议

memcrab/exceptions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52.32k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 02 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 memcrab/exceptions 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 52.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 18
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-16