{"id":13417976,"url":"https://github.com/CopernicaMarketingSoftware/PHP-CPP","last_synced_at":"2025-03-15T02:32:15.366Z","repository":{"id":10236578,"uuid":"12339519","full_name":"CopernicaMarketingSoftware/PHP-CPP","owner":"CopernicaMarketingSoftware","description":"Library to build PHP extensions with C++","archived":false,"fork":false,"pushed_at":"2024-10-21T09:28:04.000Z","size":2057,"stargazers_count":1424,"open_issues_count":116,"forks_count":332,"subscribers_count":119,"default_branch":"master","last_synced_at":"2024-10-21T13:29:47.556Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.php-cpp.com/","language":"C++","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/CopernicaMarketingSoftware.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-08-24T06:55:45.000Z","updated_at":"2024-10-21T09:27:03.000Z","dependencies_parsed_at":"2024-05-16T09:48:37.743Z","dependency_job_id":null,"html_url":"https://github.com/CopernicaMarketingSoftware/PHP-CPP","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CopernicaMarketingSoftware%2FPHP-CPP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CopernicaMarketingSoftware%2FPHP-CPP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CopernicaMarketingSoftware%2FPHP-CPP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CopernicaMarketingSoftware%2FPHP-CPP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CopernicaMarketingSoftware","download_url":"https://codeload.github.com/CopernicaMarketingSoftware/PHP-CPP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221532181,"owners_count":16838913,"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":[],"created_at":"2024-07-30T22:00:56.562Z","updated_at":"2025-03-15T02:32:15.352Z","avatar_url":"https://github.com/CopernicaMarketingSoftware.png","language":"C++","funding_links":[],"categories":["TODO scan for Android support in followings","Scripting","Miscellaneous","C++ (70)","C++","正则表达式","多项混杂","扩展编写"],"sub_categories":["脚本"],"readme":"PHP-CPP\n=======\n\n[![Build Status](https://travis-ci.org/CopernicaMarketingSoftware/PHP-CPP.svg?branch=master)](https://travis-ci.org/CopernicaMarketingSoftware/PHP-CPP)\n\nThe PHP-CPP library is a C++ library for developing PHP extensions. It offers a collection\nof well documented and easy-to-use classes that can be used and extended to build native\nextensions for PHP. The full documentation can be found on http://www.php-cpp.com.\n\nABOUT\n=====\n\nPHP-CPP is created and maintained by Copernica (www.copernica.com). We write \nour code mostly in PHP and C++ and needed an effective way \nto combine these two languages. That's where PHP-CPP comes in.\nDo you appreciate our work and are you looking for other high quality solutions? \n\nThen check out our other solutions:\n\n* PHP-JS (www.php-js.com)\n* Copernica Marketing Suite (www.copernica.com)\n* MailerQ MTA (www.mailerq.com)\n* Responsive Email web service (www.responsiveemail.com)\n\nThe power of PHP-CPP\n====================\n\nUnlike regular PHP extensions - which are really hard to implement and require a deep\nknowledge of the Zend engine and pointer manipulation - extensions built with PHP-CPP\nare not difficult to develop at all. In fact, the only thing you need to do is write a function in\nC++, and the PHP-CPP library uses all the power offered by C++11 to convert the parameters and return\nvalues from your functions to/and from PHP:\n\n```c\nPhp::Value hello_world()\n{\n    return \"hello world!\";\n}\n```\n\nThe function above is a native C++ function. With PHP-CPP you can export this function\nto PHP with only one single C++ method call:\n\n```c\nextension.add(\"hello_world\", hello_world);\n```\n\nWorking with parameters and return values is just as easy:\n\n```c\nPhp::Value my_plus(Php::Parameters \u0026params)\n{\n    return params[0] + params[1];\n}\n```\n\nThe method call to export the above C++ function:\n\n```c\nextension.add\u003cmy_plus\u003e(\"my_plus\", {\n    Php::ByVal(\"a\", Php::numericType),\n    Php::ByVal(\"b\", Php::numericType)\n});\n```\n\nThe PHP-CPP library ensures that the variables\nfrom PHP (which internally are complicated C structures), are automatically converted into \nintegers, passed to your function, and that the return value of your \"my_plus\" function is \nalso converted back into a PHP variable.\n\nType conversion between native C/C++ types and PHP variables is handled by PHP-CPP, using\nfeatures from the C++11 language. It does not matter if your functions accept strings,\nintegers, booleans or other native parameters: PHP-CPP takes care of the conversion. \nThe return value of your function is also transformed by PHP-CPP into PHP.\n\nMore complicated structures can be handled by PHP-CPP as well. If you would like to return\na nested associative array from your function, you can do so too:\n\n```c\nPhp::Value get_complex_array()\n{\n    Php::Value r;\n    r[\"a\"] = 123;\n    r[\"b\"] = 456;\n    r[\"c\"][0] = \"nested value\";\n    r[\"c\"][1] = \"example\";\n    return r;\n}\n```\n\nThe C++ function above is equivalent to the following function in PHP:\n\n```php\nfunction get_complex_array()\n{\n    return array(\n        \"a\" =\u003e 123,\n        \"b\" =\u003e 456,\n        \"c\" =\u003e array(\"nested_value\",\"example\")\n    );\n}\n```\n\nMore information and more examples are available on the official website:\nhttp://www.php-cpp.com.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCopernicaMarketingSoftware%2FPHP-CPP","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCopernicaMarketingSoftware%2FPHP-CPP","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCopernicaMarketingSoftware%2FPHP-CPP/lists"}