{"id":23773887,"url":"https://github.com/kusanagi/katana-sdk-php7","last_synced_at":"2026-03-09T08:32:04.966Z","repository":{"id":18963715,"uuid":"64084556","full_name":"kusanagi/katana-sdk-php7","owner":"kusanagi","description":"PHP7 SDK for the KATANA Framework","archived":false,"fork":false,"pushed_at":"2022-03-10T09:03:30.000Z","size":341,"stargazers_count":5,"open_issues_count":8,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-09-05T18:48:32.625Z","etag":null,"topics":["framework","katana","kusanagi","php","php7","sdk"],"latest_commit_sha":null,"homepage":"https://kusanagi.io","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kusanagi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-24T20:37:01.000Z","updated_at":"2022-02-12T10:54:34.000Z","dependencies_parsed_at":"2022-08-07T09:01:03.751Z","dependency_job_id":null,"html_url":"https://github.com/kusanagi/katana-sdk-php7","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"purl":"pkg:github/kusanagi/katana-sdk-php7","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kusanagi%2Fkatana-sdk-php7","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kusanagi%2Fkatana-sdk-php7/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kusanagi%2Fkatana-sdk-php7/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kusanagi%2Fkatana-sdk-php7/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kusanagi","download_url":"https://codeload.github.com/kusanagi/katana-sdk-php7/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kusanagi%2Fkatana-sdk-php7/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30287833,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["framework","katana","kusanagi","php","php7","sdk"],"created_at":"2025-01-01T05:46:12.478Z","updated_at":"2026-03-09T08:32:04.944Z","avatar_url":"https://github.com/kusanagi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"KATANA SDK for PHP7\n=========================\n\n[![Build Status](https://travis-ci.org/kusanagi/katana-sdk-php7.svg?branch=master)](https://travis-ci.org/kusanagi/katana-sdk-php7)\n[![Coverage Status](https://coveralls.io/repos/github/kusanagi/katana-sdk-php7/badge.svg?branch=master)](https://coveralls.io/github/kusanagi/katana-sdk-php7?branch=master)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nPHP7 SDK to interface with the **KATANA**™ framework (https://kusanagi.io).\n\nRequirements\n------------\n\n* KATANA Framework 2.1\n* [libzmq](http://zeromq.org) 4.1.5+\n* [zmq extension](https://github.com/mkoppanen/php-zmq)\n* [msgpack extension](https://github.com/msgpack/msgpack-php)\n\nInstallation\n------------\n\nThe PHP7 SDK can be installed using [composer](https://getcomposer.org/).\n\n```\ncomposer require kusanagi/katana-sdk-php7\n```\n\nGetting Started\n---------------\n\nThe SDK allow both **Services** and **Middlewares** to be created. Both of them require a source file and a configuration file pointing to it.\n\nThe first step to create a **Service** or a **Middleware** is to generate the configuration file, which will define the behavior of the component. In both cases the configuration include name and version of the component and the engine and source file to run it.\n\nThe configuration file for a **Service** define the different actions it can respond to, and can include http configuration so it can interact with a **Gateway**.\n\n```yaml\n\"@context\": urn:katana:service\nname: service_name\nversion: \"0.1\"\nhttp-base-path: /0.1\ninfo:\n  title: Example Service\nengine:\n  runner: urn:katana:runner:php7\n  path: ./example_service.php\naction:\n  - name: action_name\n    http-path: /action/path\n```\n\nThe configuration of a **Middleware** defines which kind of action (*request*, *response* or both), it responds to.\n\n```yaml\n\"@context\": urn:katana:middleware\nname: middleware_name\nversion: \"0.1\"\nrequest: true\nresponse: true\ninfo:\n  title: Example Middleware\nengine:\n  runner: urn:katana:runner:php7\n  path: ./example_middleware.php\n```\n\nThe following example illustrates how to create a **Service**. Given the previous configuration file, the source file must be located at `./example_service.php`, define the actions and run the component:\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$service = new \\Katana\\Sdk\\Service();\n\n$service-\u003eaction('action_name', function (\\Katana\\Sdk\\Action $action) {\n    $action-\u003elog('Start action');\n\n    return $action;\n});\n\n$service-\u003erun();\n```\n\nThe following example illustrates how to create a request **middleware**. Given the previous configuration file, the source file must be located at `./example_middleware.php`, define the *request* and *response* and run the component:\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$middleware = new \\Katana\\Sdk\\Middleware();\n\n$middleware-\u003erequest(function (\\Katana\\Sdk\\Request $request) {\n    $request-\u003elog('Start Request');\n\n    return $request;\n});\n\n$middleware-\u003eresponse(function (\\Katana\\Sdk\\Response $request) {\n    $request-\u003elog('Start Response');\n\n    return $request;\n});\n\n$middleware-\u003erun();\n```\n\nExamples\n--------\n\nOne common responsibility of the request **Middlewares** is routing request to the **Service** actions. For this the **Middleware** should set the target **Service**, version and action.\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$middleware = new \\Katana\\Sdk\\Middleware();\n\n$middleware-\u003erequest(function (\\Katana\\Sdk\\Request $request) {\n    $request-\u003esetServiceName('service');\n    $request-\u003esetServiceVersion('1.0.0');\n    $request-\u003esetActionName('action');\n\n    return $request;\n});\n```\n\nResponse **Middleware** commonly format the data in the transport to present a response.\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$middleware = new \\Katana\\Sdk\\Middleware();\n\n$middleware-\u003eresponse(function (\\Katana\\Sdk\\Response $response) {\n    $httpResponse = $response-\u003egetHttpResponse();\n    $httpResponse-\u003esetBody(\n        json_encode(\n            $response-\u003egetTransport()-\u003egetData()\n        )\n    );\n    $httpResponse-\u003esetStatus(200, 'OK');\n\n    return $response;\n});\n```\n\nA **Service** can be used to group some related functionality, like a CRUD for a business model.\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$service = new \\Katana\\Sdk\\Service();\n\n$service-\u003eaction('read', function (\\Katana\\Sdk\\Action $action) {\n    $entity = $repository-\u003eget($action-\u003egetParam('id')-\u003egetValue());\n    $action-\u003esetEntity($entity);\n\n    return $action;\n});\n\n$service-\u003eaction('delete', function (\\Katana\\Sdk\\Action $action) {\n    $entity = $repository-\u003edelete($action-\u003egetParam('id')-\u003egetValue());\n\n    return $action;\n});\n\n$service-\u003eaction('create', function (\\Katana\\Sdk\\Action $action) {\n    $repository-\u003ecreate(array_map(function (\\Katana\\Sdk\\Param $param) {\n        return $param-\u003egetValue();\n    }, $action-\u003egetParams()));\n\n    return $action;\n});\n\n$service-\u003eaction('update', function (\\Katana\\Sdk\\Action $action) {\n    $repository-\u003eupdate(array_map(function (\\Katana\\Sdk\\Param $param) {\n        return $param-\u003egetValue();\n    }, $action-\u003egetParams()));\n\n    return $action;\n});\n\n$service-\u003erun();\n```\n\nDocumentation\n-------------\n\nSee the [API](https://app.kusanagi.io#katana/docs/sdk) for a technical reference of the SDK.\n\nFor help using the framework see the [documentation](https://app.kusanagi.io#katana/docs).\n\nSupport\n-------\n\nPlease first read our [contribution guidelines](https://app.kusanagi.io#katana/open-source/contributing).\n\n* [Requesting help](https://app.kusanagi.io#katana/open-source/help)\n* [Reporting a bug](https://app.kusanagi.io#katana/open-source/bug)\n* [Submitting a patch](https://app.kusanagi.io#katana/open-source/patch)\n* [Security issues](https://app.kusanagi.io#katana/open-source/security)\n\nWe use [milestones](https://github.com/kusanagi/katana-sdk-php7/milestones) to track upcoming releases inline with our [versioning](https://app.kusanagi.io#katana/docs/framework/versions) strategy, and as defined in our [roadmap](https://app.kusanagi.io#katana/docs/framework/roadmap).\n\nFor commercial support see the [solutions](https://kusanagi.io/solutions) available or [contact us](https://kusanagi.io/contact) for more information.\n\nContributing\n------------\n\nIf you'd like to know how you can help and support our Open Source efforts see the many ways to [get involved](https://app.kusanagi.io#katana/open-source).\n\nPlease also be sure to review our [community guidelines](https://app.kusanagi.io#katana/open-source/conduct).\n\nLicense\n-------\n\nCopyright 2016-2018 KUSANAGI S.L. (https://kusanagi.io). All rights reserved.\n\nKUSANAGI, the sword logo, KATANA and the \"K\" logo are trademarks and/or registered trademarks of KUSANAGI S.L. All other trademarks are property of their respective owners.\n\nLicensed under the [MIT License](https://app.kusanagi.io#katana/open-source/license). Redistributions of the source code included in this repository must retain the copyright notice found in each file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkusanagi%2Fkatana-sdk-php7","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkusanagi%2Fkatana-sdk-php7","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkusanagi%2Fkatana-sdk-php7/lists"}