Git Product home page Git Product logo

webworker's Introduction

WebWorker

基于Workerman实现的自带http server的web开发框架,用于开发高性能的api应用,例如app接口服务端等。

特性

  • 仅只支持php7
  • 天生继承workerman所拥有的特性
  • 只实现了简单路由功能的小巧框架,便于开发者使用和扩展.demo1中只是目录示例,开发者可自行定义自己的应用目录结构
  • slim风格添加路由
  • 集成了workerman-statistics项目,可以监控服务情况
  • 支持中间件

安装

composer require salamander/webworker

快速开始

demo.php

<?php
use Workerman\Worker;
use Workerman\Protocols\Http;
use WebWorker\Libs\Mredis;
use WebWorker\Libs\Mdb;
use WebWorker\Libs\Mmysqli;

define('APP_ROOT', str_replace('\\', '/', dirname(__FILE__)));
require_once __DIR__.'/vendor/autoload.php';

//加载配置文件
define("WORKERMAN_RUN",getenv("WORKERMAN_RUN"));

$containerConfig = [
    'settings' => [
        'displayErrorDetails' => true, // set to false in production
        'addContentLengthHeader' => false, // Allow the web server to send the content-length header,
        'determineRouteBeforeAppMiddleware' => true
    ]
];

$app = new WebWorker\App("http://0.0.0.0:8888", [], $containerConfig);

$app->name = "newSayu66";

$app->count = 30;

$app->max_request = 1000;

//设置监控
$app->statistic_server = "udp://127.0.0.1:55656";

$app->get('/', function ($req, $res) {
    $res->getBody()->write('hello salamander');
});

$app->get('/name', function ($req, $res) {
    $res->getBody()->write('hello name');
});

//初始化redis和mysqli连接
$app->onWorkerStart = function($worker) {

};

$app->onWorkerReload = function ($worker) {

};


// 如果不是在根目录启动,则运行runAll方法
if(!defined('GLOBAL_START'))
{
    Worker::runAll();
}

webworker's People

Contributors

pigloverabbit520 avatar

Watchers

James Cloos avatar singleZhang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.