• No results found

zanphp-doc Documentation

N/A
N/A
Protected

Academic year: 2021

Share "zanphp-doc Documentation"

Copied!
25
0
0

Loading.... (view fulltext now)

Full text

(1)

zanphp-doc Documentation

Release 1.0

youzan

(2)
(3)

Contents

1 Zan PHP Framework 1 1.1 . . . 1 1.2 . . . 1 1.3 . . . 2 1.4 . . . 2 1.5 . . . 2 1.6 License . . . 2 2 Zan PHP 3 3 Web 5 3.1 . . . 5 3.1.1 . . . 5 3.1.2 . . . 5 3.1.3 . . . 5 3.2 . . . 6 3.2.1 zh . . . 7 3.3 . . . 7 3.4 . . . 7 3.4.1 ZanHttp . . . 7 3.4.2 Debug . . . 8 4 TCP 9 4.1 . . . 9 4.1.1 . . . 10 4.2 . . . 10 4.3 . . . 10 4.3.1 / . . . 11 5 Web 13 5.1 . . . 13 5.1.1 zan. . . 13 5.1.2 . . . 14 5.1.3 . . . 15 5.2 php.ini . . . 15

(4)

5.4.1 . . . 17 5.4.2 . . . 17 5.4.3 . . . 17 5.5 trace.php . . . 17 5.5.1 . . . 17 5.5.2 . . . 17 5.5.3 . . . 17 5.6 debug.php . . . 18 5.6.1 . . . 18 5.6.2 . . . 18 5.7 nova.php . . . 18 5.7.1 . . . 18 5.7.2 . . . 18 5.7.3 . . . 18 5.8 server.php. . . 19 5.8.1 . . . 19 5.8.2 . . . 19 5.8.3 . . . 19 5.9 log.php . . . 20 5.9.1 . . . 20 5.9.2 . . . 20 5.9.3 . . . 20 ii

(5)

CHAPTER

1

Zan PHP Framework

ZanPHPC10K+HTTPSOA 1. yield 2. Golang 3. swoole I/O 4. MySQLRedissyslog 5. Golang defer 6. ViewbigPipe/bigRender/ 7. SQLMapSQLshardingcache

8. Laravelmiddleware(Filters & Terminators) 9. Di

10.

Zan Web

Zan Golang Golang PHP Golang

(6)

Zan Golang PHP Golang Zan + Go + C/C++ codingJava Zan PHPzan-doc GitBookZan PHP GitBook/zan-doc • zan-doc- Zan PHP • zan-installer- Zan PHP • zanhttp- Zan PHP HTTP demo

• zan-hign-performance-mysql- Zan PHP MySQL

QQ115728122

License

Zan PHP MIT license

(7)

CHAPTER

2

Zan PHP

yz-swoole https://github.com/youzan/yz_swoole.git php-lz4 https://github.com/kjdev/php-ext-lz4.git php-apcu https://pecl.php.net/package/APCu

(8)
(9)

CHAPTER

3

Web

Zan PHPzan-installer

zan-installerComposerzan-installer Composer youzan/zan-installer

# Composer

curl -sS https://getcomposer.org/installer | php

ComposerComposer Getting Started

Composer zan-installer

composer global require youzan/zan-installer

zan-installer

composer global update

(10)

~/Sites zan __ __ /\ \ /\ \ \ `\`\\/'/ ___ __ __ ____ __ ___ `\ `\ /' / __`\/\ \/\ \/\_ ,`\ /'__`\ /' _ `\ `\ \ \/\ \L\ \ \ \_\ \/_/ /_/\ \L\.\_/\ \/\ \ \ \_\ \____/\ \____/ /\____\ \__/.\_\ \_\ \_\ \/_/\/___/ \/___/ \/____/\/__/\/_/\/_/\/_/ Create a new ZanPhp application.

Which type application would you create? (use <space> to select) HTTP

TCP

Your application name: (ex: zanphp-demo) demo

Your application namespace: (ex: zanphp/zanhttp) youzan/demo Please input a output directory:

~/Sites

Downloading the source code archive ... Extracting archive ...

Congratulations, your application has been generated to the following directory.

~/Sites/demo/

See ~/Sites/demo/README.md for information on how to run. Composer installing...

Loading composer repositories with package information Updating dependencies (including require-dev)

- Installing zanphp/zan (dev-master o1o0x2x4) Cloning b6d8d443a7a3545a3d1796b39e54fcbc2d276a10 Writing lock file

Generating autoload files

: - bin - init | - ServerStart | - WorkerStart - public - resource | - cache | - kvstore | - routing | - config | | - qatest | | | - connection | | | - ... | | - online | | | - connection | | | - ... | | - share | | | - table | | - test | | - connection | | - ... 6 Chapter 3. Web

(11)

zanphp-doc Documentation, Release 1.0 | - sql | - common | - ... - src | - Controller(http server) | - Bo | - Dao | - Service - tests | - Bo | - Dao | - Service - vendor - ...

zh

• bin: bin • init: • resource: • src: • tests: • vendor: composer Fig. 3.1:

ZanHttp

(12)

2. PageNotFoundException404 3. InvalidRouteException404 4. exception coderequestjsonhtml 5. 500 1~55

Debug

debugSTDOUT 8 Chapter 3. Web

(13)

CHAPTER

4

TCP

: - bin - init | - ServerStart | - WorkerStart - public - resource | - cache | - kvstore | - routing | - config | | - qatest | | | - connection | | | - ... | | - online | | | - connection | | | - ... | | - share | | | - table | | - test | | - connection | | - ... | - sql | - common | - ... - src | - Controller(http server) | - Bo | - Dao

(14)

| - Bo | - Dao | - Service - vendor - ... • bin: bin • init: • resource: • src: • tests: • vendor: composer Fig. 4.1: zanTcpthrift-Novathrift 10 Chapter 4. TCP

(15)

zanphp-doc Documentation, Release 1.0

/

Header message size 4 bytes magic 2 bytes header size 2 bytes version 1 bytes IP 4 bytes port 4 bytes service name size 4 bytes service name

method name size 4 bytes method name

request id/response id 8 bytes attachment size 4 bytes attachment

Body message body thrift serialize • message size: • magic:—-0xDABC • header size: • version: • IP:IP • port:socketport • service name: • method name:

• request id=response id: • attachment size: • attachment:json • message body:thrift

(16)
(17)

CHAPTER

5

Web

zan

- cache | - pf - config | - qatest | - share | - test - config.php - kvstore | - test.php - middleware | - middleware.php - routing | - route1.php | - route2.php - sql - demo.php zan$ROOTPATH/resource cacherediskey configshareshareshare middleware sqlsqldatasql

(18)

resource/config/test/ - connection | - kvstore.php | - mysql.php | - tcp.php - debug.php - haunt.php - hawk.php - monitor | - trace.php - server.php $ROOTPATH/resource/config/share - app.php - ServerStart | - .config.php | - LoadUrlConfig.php - WorkerStart - .config.php - LoadUrlConfig.php zaninit.config.php ServerStartWorkerStartserverworker .config.php <?php return [ \Scrm\Open\Init\WorkerStart\LoadUrlConfig::class, ]; LoadUrlConfig.php <?php namespace Scrm\Open\Init\WorkerStart; use Zan\Framework\Contract\Network\Bootable; use Zan\Framework\Foundation\Core\Config; use Zan\Framework\Utilities\Types\URL; class LoadUrlConfig implements Bootable {

public function bootstrap($server) {

$config = Config::get('url'); URL::setConfig($config); }

}

Zan:raw-latex:Framework:raw-latex:‘\Contract‘:raw-latex:‘\Network‘:raw-latex:‘\Bootable‘.config.php

(19)

zanphp-doc Documentation, Release 1.0

zan

namespace Zan\Framework\Foundation\Core; class Config {

//

public static function set($key, $value) //$default

public static function get($key, $default = null) } setgetkeyENV haunt.phpConfig::get(’haunt‘)haunt.phpitemConfig::get(’haunt.item‘)

php.ini

php.ini php -i|grep php.ini php.ini

date.timezone = "Asia/Chongqing"

kdt.RUN_MODE = test kdt.DEBUG = true • date.timezone • kdt.RUN_MODEresource/configkdt.RUN_MODE = testresource/config/testonline • kdt.DEBUGfalse

haunt

resource/config/$ENV/haunt.php <?php return [ // app nameapp_namesarray 'app_names' => [ 'scrm-api', 'pf-api', ], // appprotocol

(20)

'scrm-api' => [ 'protocol' => 'nova', 'namespace' => 'com.youzan.service', ], // com.youzan.test pf-api 'pf-api' => [ 'protocol' => 'nova', 'namespace' => 'com.youzan.test', ], ], // 'discovery' => [ 'host' => 'xxx.xxx.xxx.xxx', 'port' => xxxx, 'timeout' => 30000, 'uri' => '/xx/xxx', 'protocol' => 'nova', 'namespace' => 'com.xxx.service', // 'loop_time' => 1000, //worker ], // 'watch' => [ 'host' => 'xxx.xxx.xxx.xxx', 'port' => xxxx, 'timeout' => 30000, 'uri' => '/xx/xxx', 'protocol' => 'nova', 'namespace' => 'com.xxx.service', 'loop_time' => 5000, //workerwatchworkerlive ], // 'watch_store' => [ 'loop_time' => 1000, //worker() ], // 'register' => [ 'host' => '127.0.0.1', 'port' => 9000, 'uri' => 'uri', 'timeout' => 30000, 'protocol' => 'nova', 'namespace' => 'com.youzan.service', 'enable_register' => 1, //01enable_registerkey ], ]; 1.etcd 2.hauntetcdhttp://doc.qima-inc.com/display/engineer/Etcd 16 Chapter 5. Web

(21)

zanphp-doc Documentation, Release 1.0

hawk.php

resource/config/$ENV/hawk.php hawk <?php return [ //, pre 'run' => false, 'host' => '1.1.1.1', 'port' => 1234, 'uri' => '/monitor/push', // 'time' => 60000, ];

trace.php

resource/config/$ENV/monitor/trace.php <?php return [ // //tracetcp "run" => false, ]; resource/config/$ENV/connectiontcp.traceTcp

(22)

debug.php

resource/config/$ENV/debug.php <?php return [ //debug, test 'debug' => true, ];

nova.php

resource/config/$ENV/nova.php Nova nova api <?php return [ 'novaApi' => [ //nova-servicevendorgen-php 'path' => 'vendor/zanphp/novatcpdemo/gen-php', //gen-phpnamespace 'namespace' => 'Com\\Youzan\\NovaTcpDemo\\', ], ]; nova api <?php return [ 'novaApi' => [ [ 'path' => 'vendor/nova-service/scrm-base/gen-php', 18 Chapter 5. Web

(23)

zanphp-doc Documentation, Release 1.0

'namespace' => 'Com\\Youzan\\Scrm\\',

'domain' => 'com.youzan.service', // , com.youzan.service, 'appName' => 'scrm', // , Application::getName(),

'protocol' => 'nova', // , nova ],

[

'path' => 'vendor/nova-service/scrm-core/gen-php', 'namespace' => 'Com\\Youzan\\Scrm\\',

'domain' => 'com.youzan.service', // , com.youzan.service, 'appName' => 'scrm', // , Application::getName(),

'protocol' => 'nova', // , nova ],

], ];

• protocolappName namespace • haunt agent ip+port,

server.php

resource/config/$ENV/server.php Server <?php return [ //host, 0.0.0.0 'host' => '0.0.0.0', //ip 'port' => '8020', 'config' => [ //workercpu 'worker_num' => 2, //reactorcpu 'reactor_num' => 2, // 'open_length_check' => 1, 'package_length_type' => 'N',

(24)

'open_nova_protocol' => 1, 'package_max_length' => 2000000, ], //worker 'monitor' =>[ // 'max_request' => 100000, // // 'max_live_time' => 1800000, //30m // 'check_interval'=> 10000, //10s // 'memory_limit' => 1.5 * 1024 * 1024 * 1024, //1.50G //cpu 'cpu_limit' => 70, //monitor debug 'debug' => false, //worker() 'max_concurrency' => 2000, ], //, ms 'request_timeout' => 30000, // 'hawk_collection' => [ 'enable_hawk' => 0, // 10 'hawk_url' => 'http://api.hawk.qima-inc.com/report', ], //serveripipserverip 'proxy' => [ 'a.a.a.a', 'b.b.b.b', ], ];

log.php

resource/config/$ENV/log.php return [ // http://log.qima-inc.com 'default' => 'syslog://info/syslog_default?module=default', //zan 'zan_framework' => 'syslog://info/zan_framework?module=soa-framework', ]; debugurl 20 Chapter 5. Web

(25)

zanphp-doc Documentation, Release 1.0

• schemefilelogresource/logsyslogflume logblackhole; • host debuginfonoticewarningerrorcriticalalertemergency; • pathlogkeyresource/log/debug.log;

References

Related documents

Using the testFile.txt file we created in the File Write lesson , we are going to append on some more data.. The only thing that is different is that the file pointer is placed

Bullying partially mediated the relation of Honesty-Humility and Agreeableness with social outcomes, although both personality factors also had direct effects on material outcomes

Even more, while the installation makes use of some of the most pervasive mo- bile payment infrastructures like wireless networks and mobile devices, actually us- ing text messages

May return type declaration in php default value to function in many places of code that uses excess amounts of the function is to allow a cup of functions.. How an agreement

Hom pot comprovar, per tant, a tall de síntesi, que a Menorca, l’escoltis- me, tant a la primera època —compresa entre els anys 1913 i 1921— com a la segona —que anà des del

 Create a unique story for each attraction  Take time with your Haunt

It can be used on all major operating systems, including Linux, many Unix variants (including HP-UX, Solaris and OpenBSD), Microsoft Windows, Mac OS X, RISC OS, etc. It has

Based on this pluralism, a humanistic paradigm of Islamic education in Indonesia aims to realise human values based on Pancasila.. The principle of the Almighty Deity shows