topsitemakers/superglue 问题修复 & 功能扩展

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

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

topsitemakers/superglue

Composer 安装命令:

composer require topsitemakers/superglue

包简介

README 文档

README

Legacy PHP "microframework" for quick prototyping

This is basically a modified version of the existing Glue class for mapping URLs to classes. Its purpose is mainly for quick and dead-simple prototyping, with as little overhead as possible.
It does not use any of the PHP 5.3+ features, and should work everywhere with PHP 5.x+ installed.

Differences between this and the original class are:

  • Matching classes and methods instead of direct functions. This allows better app organization.
  • Using regex tokens for arguments (e.g. , , <alpha|case-insensitive>, , <alphanumeric|case-insensitive>).
  • Removed protocol functions (GET() and POST()).

Shipped with a very simple .htaccess for readable URLs.

Usage:

You first need to define URLs that will be accessible:

require 'superglue.php';

// Define URLs
$urls = array(
  
  // This will be binded to class "sample" and method "index"
  '/' => 'sample',
  // This will be binded to class "sample" and method "page"
  '/sample' => array('sample', 'page'),

  // RESTful example
  // If we do not pass an array here, superglue will check if the class has
  // method named as the request method (GET, POST, DELETE, PUSH)
  '/restful' => 'restful',

);

Define classes that will be called on appropriate routes:

// Our sample class
// Classes are better than direct functions for code organization and for
// avoiding name clashes.
class sample {
  function index() {
    print 'home page';
  }
  function page() {
    print 'sample page';
  }
}

// Example RESTful class
// Each method corresponds with the request method.
class restful {
  function GET() {
    print 'GET method.';
  }
  function POST() {
    print 'POST method.';
  }
  function PUSH() {
    print 'PUSH method.';
  }
  function DELETE() {
    print 'DELETE method.';
  }
}

That's it - start the app!

superglue::stick($urls);

Credits

Glue

By: topsitemakers.com.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2013-01-22