{"id":13807232,"url":"https://github.com/vert-x-cn/vertx-lang-jphp","last_synced_at":"2025-09-29T08:30:28.840Z","repository":{"id":45150169,"uuid":"123551916","full_name":"vert-x-cn/vertx-lang-jphp","owner":"vert-x-cn","description":"vertx php support","archived":true,"fork":false,"pushed_at":"2022-01-05T01:23:30.000Z","size":6147,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-16T11:04:41.047Z","etag":null,"topics":["graphviz","java","maven","php","phpdoc","phpdocumentor","polyglot","vert-lang-php","verticle","vertx","vertx-lang-jphp","vertx3"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vert-x-cn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-02T08:24:43.000Z","updated_at":"2024-05-04T16:42:02.000Z","dependencies_parsed_at":"2022-09-09T05:10:32.381Z","dependency_job_id":null,"html_url":"https://github.com/vert-x-cn/vertx-lang-jphp","commit_stats":null,"previous_names":["okou19900722/vertx-lang-php"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vert-x-cn%2Fvertx-lang-jphp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vert-x-cn%2Fvertx-lang-jphp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vert-x-cn%2Fvertx-lang-jphp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vert-x-cn%2Fvertx-lang-jphp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vert-x-cn","download_url":"https://codeload.github.com/vert-x-cn/vertx-lang-jphp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234600846,"owners_count":18858545,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphviz","java","maven","php","phpdoc","phpdocumentor","polyglot","vert-lang-php","verticle","vertx","vertx-lang-jphp","vertx3"],"created_at":"2024-08-04T01:01:22.925Z","updated_at":"2025-09-29T08:30:22.696Z","avatar_url":"https://github.com/vert-x-cn.png","language":"Java","funding_links":[],"categories":["Language Support"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/vert-x-cn/vertx-lang-jphp.svg?branch=master)](https://travis-ci.org/vert-x-cn/vertx-lang-jphp)\n[![maven-central](https://img.shields.io/maven-central/v/tk.okou/vertx-lang-jphp.svg)](https://github.com/vert-x-cn/vertx-lang-jphp)\n[![vertx-lang-jphp](https://img.shields.io/badge/vert.x3-jphp-782B90.svg)](https://github.com/vert-x-cn/vertx-lang-jphp)\n[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/snapshots/https/oss.sonatype.org/tk.okou/vertx-lang-jphp.svg)](https://oss.sonatype.org/#nexus-search;gav~tk.okou~vertx-lang-jphp)\n[![license](https://img.shields.io/github/license/vert-x-cn/vertx-lang-jphp.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n[![](https://jitpack.io/v/vert-x-cn/vertx-lang-jphp.svg)](https://jitpack.io/#vert-x-cn/vertx-lang-jphp)\n\n\n# vertx-lang-jphp\nVert.x JPHP support \n\n[phpdoc](https://vertx.tk/docs/phpdoc/namespaces/io.html)\n\n### 怎么用 / How to use?\n\nMaven配置 / Maven pom.xml:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003etk.okou\u003c/groupId\u003e\n  \u003cartifactId\u003evertx-lang-jphp\u003c/artifactId\u003e\n  \u003cversion\u003e4.0.0-milestone1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nGradle配置 / Gradle build.gradle file:\n```groovy\ndependencies {\n  compile 'tk.okou:vertx-lang-jphp:4.0.0-milestone1'\n}\n```\n\n### Hello from Vert.x!\n\n```php\n$httpServer = $vertx-\u003ecreateHttpServer();\n$httpServer-\u003erequestHandler(function ($res) {\n    $res-\u003eresponse()-\u003eend(\"Hello from Vert.x!\");\n});\n$httpServer-\u003elisten(8998);\n```\n\n### 创建Vertx 实例 / Create a Vert.x instance\n\n如果你需要创建Vertx实例，可以按下面的代码创建:\n\n```php\nuse io\\vertx\\jphp\\core\\Vertx;\n\n//create a vertx instance\n$vertx = Vertx::vertx();\n```\n\n如果你是通过java来deploy一个php模块，那么你通常不需要自己创建，因为有一个全局的$vertx对象可以直接使用\n\n### Verticle\n\nphp脚本本身就是一个verticle，但如果你需要像java一样指定一个方法，那么你可以按下面方法：\n\n```php\n\nfunction vertxStart(){\n    //Called when verticle is deployed\n}\n\nfunction vertxStartAsync($future){\n    //Called when verticle is deployed\n}\n\nfunction vertxStop($future){\n    //Called when verticle is undeployed\n}\n\nfunction vertxStopAsync($future){\n    //Called when verticle is undeployed\n}\n\n```\n\n当Vert.x 部署这个Verticle脚本时，如果上下文环境中有`vertxStart`方法，会优先调用此方法，否则尝试调用异步的`vertxStartAsync`方法。`vertxStartAsync`方法接收一个`io\\vertx\\jphp\\core\\Future`类型的参数，在Verticle部署完成后，需要调用`complete`方法来显式的告诉Vert.x完成。\n\n同理，Vert.x在移除一个Verticle脚本时，优先判断`vertxStop`并执行，如果没有`vertxStop`方法，会尝试调用异步的`vertxStartAsync`方法。`vertxStartAsync`方法也有一个`io\\vertx\\jphp\\core\\Future`类型的参数。\n\n### 部署Verticle / Verticle Deployment\n\n你可以使用`php:`前缀或者`.php`后缀来部署一个php verticle\n\n```php\n    $vertx-\u003edeployVerticle(\"php:test\");\n    // 或者\n    $vertx-\u003edeployVerticle(\"php:test.php\");\n    // 或者\n    $vertx-\u003edeployVerticle(\"test.php\");\n```\n\n或者使用java\n```java\n    import io.vertx.core.Vertx;\n    Vertx vertx = Vertx.vertx();\n    vertx.deployVerticle(\"php:test\");\n    // 或者\n    vertx.deployVerticle(\"php:test.php\");\n    // 或者\n    vertx.deployVerticle(\"test.php\");\n```\n\n### DataObject\n你可以直接创建需要的DataObject对象，比如HttpServerOption:\n\n```php\nuse io\\vertx\\jphp\\core\\http\\HttpServerOptions;\n\n$httpServerOptions = new HttpServerOptions();\n$httpServerOptions-\u003esetPort(8080);\n$httpServerOptions-\u003esetHost(\"localhost\");\n```\n\n当然你也可以直接使用数组，比如`Hello Vert.x!`例子中\n```php\n$httpServerOptions = [\n    \"port\"  =\u003e  8998,\n    \"host\"  =\u003e  \"localhost\",\n];\n\n$httpServer = $vertx-\u003ecreateHttpServer($httpServerOptions);\n$httpServer-\u003erequestHandler(function ($res) {\n    $res-\u003eresponse()-\u003eend(\"Hello from Vert.x!\");\n});\n$httpServer-\u003elisten();\n```\n![Note](asset/note.png) 注意，DataObject目前只支持类和接口，所以java的api中参数为接口的，php中不支持数组写法，只能创建实现类的对象\n\n\n;TODO\n\n- [x] 使用vertx-codegen自动生成JPHP的Wrapper类以及php的api文件\n- [x] JPHPVerticleFactory和VerticleFactory\n- [x] VertxExtension 读取jphp-vertx-extension.properties文件并注册wrapper类\n- [x] 使用vertx-docgen自动生成对应的asciidoc文档\n- [ ] 测试\n\n\n# phpdoc\n\n生成phpdoc需要phpDocumentor2，使用的皮肤需要开启xsl功能并下载graphviz\n\n- 下载[phpDocumentor2](http://www.phpdoc.org/)改名为phpdoc放到vertx-lang-jphp目录下\n- 下载[graphviz](http://www.graphviz.org/download/) 并配置环境变量\n- 修改php.ini，开启xsl扩展(如果未开启)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvert-x-cn%2Fvertx-lang-jphp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvert-x-cn%2Fvertx-lang-jphp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvert-x-cn%2Fvertx-lang-jphp/lists"}