Phalcon+ ist ein leichtes Zephir/C -Framework, das auf PhalconPhp basiert. Wir möchten eine einstufige Lösung für Phalcon-Entwickler aufbauen. Genau aufgrund der extrem hohen Flexibilität von Phalcon gibt es den Entwicklern zu viel Auswahl. Manchmal gibt es zu viele Kreuzungen und es ist einfach, sich zu verlieren. Nachdem ich diese Reihe von Auswahlmöglichkeiten getroffen habe, habe ich den Prozess aufgezeichnet und mich allmählich zu dem aktuellen Phalcon+entwickelt. Um zu verhindern, dass jeder Entwickler diese Entscheidungen wiederholt treffen, kann ich entschlossen von Phalcon+ für alle kommunizieren und lernen.
Zusammenfassend ist Phalcon+ kein brandneues Rahmen, sondern eine hervorragende Praxis des Phalcon -Frameworks. Es ist eine Wiederaufbereitung und Ergänzung zum Phalcon -Framework. Es kann es Phalcon -Entwicklern ermöglichen, loszulegen und leichter zu meistern und schließlich die höchste Einheit zwischen Mensch und Natur zu erreichen.
* PHP 7.0 or above
* cPhalcon 3.4.x,在官方发布3.4.6之前一定要下载此分支,通过`zephir build`手动编译phalcon - https://github.com/phalcon/cphalcon/tree/3.4.x
> 安装zephir之前,需要先安装扩展 https://github.com/phalcon/php-zephir-parser ,然后使用`composer`安装`zephir`
`composer global require phalcon/zephir`
Srv bietet RPC -Dienste Web kann erholsame Dienste anbietenApp::import("test") eingeführt werden. ➜ git clone https://github.com/bullsoft/phalconplus.git
➜ cd phalconplus/ext/
➜ /usr/bin/phpize
➜ ./configure --with-php-config=/usr/bin/php-configure
➜ make
➜ make install
Graph TD
A [phalconplus bootstrap :: __ construct] -> | sys :: init, initconf | A1 (Superapp :: Boot mit Env, Runmode)
A1 -> | SYS :: INIAPP, Definieren Sie globale Konstanten, das erste Modul ist primär | A2 (SuperApp :: BootprimaryModule)
A2 -> | Stellen Sie sicher, dass wir ein gültiges Modul haben: Web/CLI/SRV | A3 (Moduledef)
A3 -> | zuweisen superApp :: stooted -> true, machen Sie dies zu einem DefaultModule | A4 (SuperApp :: RegisterModule mit moduledef).
A4 -> | Stellen Sie sicher, dass dieses Modul nicht in SuperApp :: Modulen | A5 (Checkout -Modul) ausgeführt wird.
A5 -> | AbstractModule :: RegisterAutoloader/RegisterServices/RegisterEvents | A6 (sys :: composerautoloadpath)
A6 -> A7 (SuperApp :: Handle)
A7-> | params = func_get_args, Ereignis: superApp: voranexecmodule | b1 (SuperApp :: defaultModule-> exec mit Params)
B1 -> | Ereignis: SuperApp: Afterexecmodule | B2 (AbstractModule :: RegisterEgine)
B2 -> | Ereignis: Modul: BeforStellenEgine | B3 (AbstractModule :: EXEC With Params)
B3 -> B31 (Runmode: CLI) -> C1 (Phalcon Cli Console :: Handle) -> D1
B3 -> B32 (Runmode: Web)
B3 -> B33 (Runmode: SRV)
B32 -> C2 {Engine Web :: Handler ist}
C2 -> | Anfrage: GuzzleHttp \ PSR7 \ ServerRequest | C21 (psrhandler :: Handle) -> D1
C2 -> | Reqeuch: String | C22 (Phalcon MVC Application :: Handle) -> D1
C2 -> C23 (Außer: Ungültiger Handler)
B33 -> C3 {application.handler == yar?}
C3 -> | Ja | C31 (Yarservice :: Handle) -> D1
C3 -> | Nein | C32 (SimpleService :: Handle) -> D1
D1 (Ereignis: Modul: Afterstellengine) -> | Ereignis: SuperApp: Afterexecmodule | D2 (Rückgabe)
# 下载骨架
➜ composer create-project bullsoft/fp-project fp-app
# 生成模块,假设生成的模块名为test
➜ cd fp-app
➜ ./common/bin/fp-devtool module:create
现在开始引导您创建Phalcon+模块 ...
Step 1 请输入该模块的名称,如"api"
[Enter]: test
Step 2 ...
...
...
Die Struktur eines Webmoduls lautet wie folgt: Alle Modi sind in das Webmodul integriert, einschließlich CLI und RPCService.
test
.
├── app
│ ├── Module.php
│ ├── auth
│ │ ├── AclResources.php
│ │ ├── Model.php
│ │ ├── Resources
│ │ │ ├── Actions.php
│ │ │ └── Models.php
│ │ └── User.php
│ ├── config
│ │ └── dev.php
│ ├── controllers
│ │ ├── BaseController.php
│ │ ├── ErrorController.php
│ │ ├── IndexController.php
│ │ ├── UserController.php
│ │ └── apis
│ │ └── DemoController.php
│ ├── events
│ │ ├── Acl.php
│ │ ├── AppConsole.php
│ │ ├── AppHandler.php
│ │ ├── BackendServer.php
│ │ ├── Db.php
│ │ ├── EventProvider.php
│ │ ├── Model.php
│ │ ├── MvcDispatch.php
│ │ ├── Router.php
│ │ ├── SuperApp.php
│ │ └── View.php
│ ├── exceptions
│ │ ├── EnumExceptionCode.php
│ │ ├── Handler.php
│ │ ├── UnknownException.php
│ │ ├── UserAlreadyExistsException.php
│ │ └── UserNotExistsException.php
│ ├── plugins
│ │ └── Volt.php
│ ├── providers
│ │ ├── CookieServiceProvider.php
│ │ ├── CryptServiceProvider.php
│ │ ├── DatabaseServiceProvider.php
│ │ ├── DispatcherServiceProvider.php
│ │ ├── LoggerServiceProvider.php
│ │ ├── RedisServiceProvider.php
│ │ ├── RouterServiceProvider.php
│ │ ├── RpcServiceProvider.php
│ │ ├── ServiceProvider.php
│ │ ├── SessionServiceProvider.php
│ │ ├── UrlServiceProvider.php
│ │ └── ViewServiceProvider.php
│ ├── routes
│ │ ├── Api.php
│ │ └── Bare.php
│ └── views
│ ├── error
│ │ ├── show403.volt
│ │ ├── show404.volt
│ │ └── show500.volt
│ ├── index
│ │ └── index.volt
│ └── index.volt
├── cli
│ ├── init.php
│ └── tasks
│ └── HelloTask.php
├── public
│ ├── index.php
│ └── rpc.php
├── src
│ ├── models
│ │ └── UserModel.php
│ ├── protos
│ │ ├── Enums
│ │ │ └── UserStatus.php
│ │ └── Schemas
│ │ └── RegInfo.php
│ └── services
│ ├── BaseService.php
│ └── DemoService.php
└── var
└── cache
➜ ./common/bin/fp-devtool server:start test
正在为您启动服务器...
{
" command " : " { (php -S 0.0.0.0:8181 -t public/ .htrouter.php) <&3 3<&- 3>/dev/null & } 3<&0;pid= $! ; echo $pid > /path/to/test/var/run/server.pid " ,
" pid " : 8249,
" running " : true,
" signaled " : false,
" stopped " : false,
" exitcode " : -1,
" termsig " : 0,
" stopsig " : 0
}
... 启动成功,请使用 http://127.0.0.1:8181 访问 ➜ cd test
➜ ../vendor/bin/ppm start --bridge="PhalconPlus\Bridge" --bootstrap="PhalconPlus\Bootstrap" --static-directory=public/ --port=8181 --workers=2
Natürlich können Sie auch Konfigurationsdateien erstellen, um jedes Mal das Starten zu erleichtern
➜ cd test
➜ touch ppm.json
➜ ../vendor/bin/ppm start -c ppm.json
Der Inhalt von ppm.json lautet wie folgt:
{
"bridge" : " PhalconPlus \ Bridge " ,
"host" : " 127.0.0.1 " ,
"port" : 8181 ,
"workers" : 2 ,
"app-env" : " dev " ,
"debug" : 1 ,
"logging" : 1 ,
"static-directory" : " public/ " ,
"bootstrap" : " PhalconPlus \ Bootstrap " ,
"max-requests" : 1000 ,
"concurrent-requests" : 20 ,
"php-cgi" : " /usr/local/opt/[email protected]/bin/php "
} ➜ composer require spiral/roadrunner
➜ cd test
➜ touch .rr.json
➜ touch psr-worker.php
Der Inhalt von .rr.json lautet wie folgt:
{
"http" : {
"address" : " 0.0.0.0:8181 " ,
"workers" : {
"command" : " /usr/local/opt/[email protected]/bin/php psr-worker.php " ,
"relay" : " unix://rr.sock " ,
"pool" : {
"numWorkers" : 2
}
}
},
"static" : {
"enable" : true ,
"dir" : " public " ,
"forbid" : [ " .php " , " .htaccess " ]
}
}Der Inhalt von psr-Worker.php lautet wie folgt:
<?php
use Spiral Goridge ;
use Spiral RoadRunner ;
use PhalconPlus Http PsrResponseFactory ;
ini_set ( ' display_errors ' , ' stderr ' );
$ app = ( new PhalconPlus Bootstrap ( __DIR__ ))-> app ();
$ worker = new RoadRunner Worker (
new Goridge SocketRelay ( __DIR__ . " /rr.sock " , null , Goridge SocketRelay:: SOCK_UNIX )
);
$ psr7 = new RoadRunner PSR7Client ( $ worker );
while ( $ req = $ psr7 -> acceptRequest ()) {
try {
$ resp = $ app -> handle ( $ req );
} catch ( Throwable $ e ) {
Test Exceptions Handler:: catch ( $ e );
$ resp = $ app -> response ();
}
$ psr7 -> respond (PsrResponseFactory:: create ( $ resp ));
$ app -> terminate ();
unset( $ req , $ resp );
}Führen Sie dann im Modulverzeichnis aus
➜ rr serve -d -v
Konfigurationsdatei
server {
listen 8181 ;
server_name localhost;
access_log /var/log/nginx/test.access.log;
index index.php index.html index.htm;
set $root_path '/home/work/wwwroot/fp-app/test/public' ;
root $root_path ;
try_files $uri $uri / @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php last ;
}
location ~ .php {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name ;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path ;
}
location ~ /.ht {
deny all ;
}
}Jedes Feedback ist willkommen und ich hoffe, von allen Spenden und Unterstützung zu erhalten.
Ich wünsche dir alles Gute, kein Bruder 82 :)