slimphp-api/slim-api 问题修复 & 功能扩展

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

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

slimphp-api/slim-api

Composer 安装命令:

composer require slimphp-api/slim-api

包简介

Tool for generating slim api controllers/models

README 文档

README

#slim-api Basic slim api project and generator

Coverage Status Code Climate Build Status

#Status

Alpha, init and create models/controllers/scaffolds is complete.

#What?

A simple command line app for producing simple controllers/models/migrations, routes and DI, using Slim and symfony console.

###External modules By default the app uses phinx and eloquent for migrations and ORM, these are provided by external modules: slim-eloquent and slim-phinx

#Why?

I wanted to be able to create API end points as easily as possible, and I love the simplicity of Slim, and after a sordid time with RoR this seemed like a fun thing to do!

#How?

###Installation

Install globally within your user account composer global require slimphp-api/slim-api dev-master
Make sure global composer is in your path export PATH=~/.composer/vendor/bin:$PATH in .bashrc

###Init

Basic useage is simple, we first have to initiate the project, this creates a default skeleton for the project and initiates the phinx configuration.

slimapi init <project name> [location]

Location defaults to the cwd if not specified.

If you use a different migration/orm/structure module you'll then have to re-init the appropriate source, such as:

slimapi init:db

This must be done from the root or your project after the init.

###Models

We can then generate a model, this creates a migration, a simple model class and DI configuration.

slimapi generate model <model name> <model definitions>

Model definitions are a space seperated list of column definitions, of the form name:type:limit:null:unique, so

slimapi generate model Foo bar:integer baz:string:128:false bazbar:string:128::true

Would create a migration of 3 columns, baz would have a character limit and can't be null, bazbar would have a character limit and must be unique.

###Controllers

We can create a controller, this creates a simple controller, route and DI configuration.

slimapi generate controller <controller name> [methods]

Methods defaults to index, get, post, put and delete and are empty by default. The controller name influences how the route is designed.

slimapi generate controller Foo index post

Would generate a controller named Foo with empty methods index and post. It would also create the GET/POST /foo route.

slimapi generate controller Foo

Would generate a controller named Foo with empty methods index, get, post, put, delete. It would also create the GET/POST /foo routes and the GET/PUT/DELETE /foo/{id} routes.

###Scaffold

Scaffolding combines controller and model generation but with added jazz. It configures the controller to receive the model as a constructor param, configures the DI to inject the model to the controller and finally populates the normally empty controller methods with basic CRUD functionality. You can't provide arguments to specify controller methods (it creates them all), but you can supply your model definition.

slimapi generate scaffold foo field1:integer field2:string

This would generate the Foo controller and appropriate routes, the Foo model/migration with field1/field2 as fillables and any required DI configuration.

slimphp-api/slim-api 适用场景与选型建议

slimphp-api/slim-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 358 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 08 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 slimphp-api/slim-api 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 358
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 15
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-27