sml/sml-frame 问题修复 & 功能扩展

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

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

sml/sml-frame

Composer 安装命令:

composer require sml/sml-frame

包简介

A Tiny framework for handling api's the easy way

README 文档

README

Getting started

run composer install edit the .htaccess file to match your file structure

Basic setup

require_once 'vendor/autoload.php';

$app = new Sml\Sml();

# Run the application
$app->run();

ROUTING with request

require_once 'vendor/autoload.php';

$app = new Sml\Sml();

$app::get('/', function(){
  echo 'test';
});

# If you want to pass arguments to the function you do this with regEx values
# Supported values are for Strings and Ints

# String and int value

$app::get('/user/(\w+)/(\d+)', function( $string, $int ){

  # You can then use the params here

});


# POST

$app::post('/user', function() use( $app ) {

  # To get the post request you can do:

  # This recives a json encoded body for you, and returns as obj.
  # If you want a array you can pass true into the json( true )
  $app->request()->json();

  # This recives the x-www-form-urlencoded body ( normal POST )
  $app->request()->body();

});

# Run the application
$app->run();

Response

To use the response obj you need yo inject $app onto your functions

require_once 'vendor/autoload.php';

$app = new Sml\Sml();

$app::get('/', function() use( $app ){
  $app->response( 200, "it Works" )->send();
});

# You can also send back json_response by chaining the sendJson method onto the response method.
$app::get('/', function() use( $app ){
  $app->response( 200, "it Works" )->sendJson();
});

$app->run();

Changelog

version 0.0.2

  • Added support for POST, GET, PUT, DELETE routes
  • Added exception class for handling errors
  • Added Response obj
  • Added Request obj
  • Added the use of env file

version 0.0.1

  • Included simple get Route support.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固