iddqdby/tinyapp 问题修复 & 功能扩展

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

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

iddqdby/tinyapp

Composer 安装命令:

composer require iddqdby/tinyapp

包简介

Microframework for small command line applications.

README 文档

README

Build Status Latest Stable Version Total Downloads License

Description

Install the library

To install the library, run composer require iddqdby/tinyapp.

Create an application

To create the application:

  • Extend abstract class TinyApp\App
  • Implement method init() to initialize your application
  • Implement method get($key) to get services and other stuff from any dependency injection container you like
  • Create a controller class that extends one of abstract classes in TinyApp\Controller namespace
  • Create public action methods like "somethingAction"
  • Define your controller in the dependency injection container under App::CONTROLLER_PREFIX.App::CONTROLLER_MAIN key
  • Use protected method get($key) inside your actions to get services and other stuff from your dependency injection container
  • Instantiate your app and call method $app->run($action, $arguments) to invoke an action once, or $app->loop() to run your application in interactive mode

Example

Example of a script to run from CLI:

<?php

require '/path/to/vendor/autoload.php';

$action = $argv[1];
$arguments = array_slice($argv, 2);

$app = new MyApp(); // MyApp extends TinyApp\App
$result = $app->run($action, $arguments);
printf("%s\n", $result);

The $action in the example above must match the regular expression "/((?<CONTROLLER>[\w\d\_]+):)?(?<ACTION>[\w\d\_]+)/i".

Prefix App::CONTROLLER_PREFIX will be prepended to CONTROLLER. CONTROLLER will be set to App::CONTROLLER_MAIN if it is omitted.

Postfix App::ACTION_POSTFIX will be appended to ACTION.

The action of the controller will be invoked with passed arguments, and its result will be returned. The \BadMethodCallException exception will be thrown if no controller is registered under the given key, or if there is no such action in the controller.

Requirements

PHP 5.4 or later.

License

This program is licensed under the MIT License. See LICENSE.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固