{"id":13684445,"url":"https://github.com/usemuffin/webservice","last_synced_at":"2025-12-15T23:53:33.900Z","repository":{"id":31251889,"uuid":"34813423","full_name":"UseMuffin/Webservice","owner":"UseMuffin","description":"Bringing the power of the CakePHP ORM to your favourite webservices","archived":false,"fork":false,"pushed_at":"2024-05-13T06:02:50.000Z","size":541,"stargazers_count":89,"open_issues_count":11,"forks_count":43,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-10-20T10:10:25.773Z","etag":null,"topics":["cakephp","cakephp-plugin","php","webservice"],"latest_commit_sha":null,"homepage":"","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/UseMuffin.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":"2015-04-29T19:17:28.000Z","updated_at":"2024-02-07T10:46:50.000Z","dependencies_parsed_at":"2022-08-23T13:51:02.454Z","dependency_job_id":"bb4ee8e3-ae44-4f54-9710-ad6df2aedfd5","html_url":"https://github.com/UseMuffin/Webservice","commit_stats":{"total_commits":224,"total_committers":15,"mean_commits":"14.933333333333334","dds":0.6741071428571428,"last_synced_commit":"6376dc722529d888c4750793f0b286a8acd9fd71"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FWebservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FWebservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FWebservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FWebservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UseMuffin","download_url":"https://codeload.github.com/UseMuffin/Webservice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224224787,"owners_count":17276428,"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":["cakephp","cakephp-plugin","php","webservice"],"created_at":"2024-08-02T14:00:33.604Z","updated_at":"2025-12-15T23:53:33.823Z","avatar_url":"https://github.com/UseMuffin.png","language":"PHP","funding_links":[],"categories":["ORM / Database / Datamapping"],"sub_categories":[],"readme":"# Webservice\n\n[![Build Status](https://img.shields.io/travis/UseMuffin/Webservice/master.svg?style=flat-square)](https://github.com/UseMuffin/Webservice/actions?query=workflow%3ACI+branch%3Amaster)\n[![Coverage](https://img.shields.io/codecov/c/github/UseMuffin/Webservice/master.svg?style=flat-square)](https://codecov.io/github/UseMuffin/Webservice)\n[![Total Downloads](https://img.shields.io/packagist/dt/muffin/webservice.svg?style=flat-square)](https://packagist.org/packages/muffin/webservice)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)\n\nBringing the power of the CakePHP ORM to your favourite webservices.\n\n## Install\n\nUsing [Composer][composer]:\n\n```\ncomposer require muffin/webservice\n```\n\nYou then need to load the plugin. You can use the shell command:\n\n```\nbin/cake plugin load Muffin/Webservice\n```\n\n## Usage\n\n### Datasource Configuration\n\nIn your `app.php`, add a new `webservice` config under `Datasources`:\n\n```php\n    'Datasources' =\u003e [\n        // Other db config here\n        'webservice' =\u003e [\n            'className' =\u003e \\Muffin\\Webservice\\Datasource\\Connection::class,\n            'service' =\u003e 'Articles',\n            // Any additional keys will be set as Driver's config.\n        ],\n    ],\n```\n\nIf you are making a plugin then conventionally the datasource config key name\nshould be underscored version of plugin name.\n\n### As an ORM\n\n#### Create driver\n\n```php\n\u003c?php\nnamespace App\\Webservice\\Driver;\n\nuse Cake\\Http\\Client;\nuse Muffin\\Webservice\\Driver\\AbstractDriver;\n\nclass Articles extends AbstractDriver\n{\n    /**\n     * Initialize is used to easily extend the constructor.\n     */\n    public function initialize(): void\n    {\n        $this-\u003esetClient(new Client([\n            'host' =\u003e 'example.com'\n        ]));\n    }\n}\n```\n\n#### Create a webservice\n\n```php\n\u003c?php\nnamespace App\\Webservice;\n\nuse Muffin\\Webservice\\Datasource\\Query;\nuse Muffin\\Webservice\\Datasource\\ResultSet;\nuse Muffin\\Webservice\\Webservice\\Webservice;\n\nclass ArticlesWebservice extends Webservice\n{\n    /**\n     * Executes a query with the read action using the Cake HTTP Client\n     */\n    protected function _executeReadQuery(Query $query, array $options = [])\n    {\n        $response = $this-\u003egetDriver()-\u003egetClient()-\u003eget('/articles.json');\n\n        if (!$response-\u003eisOk()) {\n            return false;\n        }\n\n        $resources = $this-\u003e_transformResults($query-\u003eendpoint(), $response-\u003ejson['articles']);\n\n        return new ResultSet($resources, count($resources));\n    }\n}\n```\n\n#### Create an endpoint (optional)\n\n```php\n\u003c?php\nnamespace App\\Model\\Endpoint;\n\nuse Muffin\\Webservice\\Model\\Endpoint;\n\nclass ArticlesEndpoint extends Endpoint\n{\n}\n```\n\n#### Create a resource (optional)\n\n```php\n\u003c?php\nnamespace App\\Model\\Resource;\n\nuse Muffin\\Webservice\\Model\\Resource;\n\nclass Article extends Resource\n{\n}\n```\n\n#### Use it\n\n```php\n\u003c?php\nnamespace App\\Controller;\n\nuse Muffin\\Webservice\\Model\\EndpointLocator;\n\nclass ArticlesController extends AppController\n{\n    // Either set the default model type to \"Endpoint\" or explicitly specify\n    // model type in loadModel() call as shown below.\n    protected $_modelType = 'Endpoint';\n\n    public function index()\n    {\n        // This is required only if you haven't set `$_modelType` property to\n        // \"Endpoint\" as shown above.\n        $this-\u003eloadModel('Articles', 'Endpoint');\n\n        $articles = $this-\u003eArticles-\u003efind();\n    }\n}\n```\n\n### As base for a driver\n\nYou can also use this plugin as a base to a separate plugin or to manage custom webservice\ndrivers connections.\n\nUntil official documentation is written, [David Yell][1] wrote a good [post to get you started][2].\n\n[1]:https://github.com/davidyell\n[2]:https://github.com/davidyell/davidyell.github.com/blob/source/_posts/2015-09-11-connecting-to-a-web-service.markdown\n\n## Implementations of webservices\n\n### As an ORM\n\nThe following plugins use the Webservice ORM to give you easy access to all kinds of webservices:\n\n- [GitHub plugin](https://github.com/cvo-technologies/cakephp-github) - Provides access to the GitHub REST APIs.\n- [NS plugin](https://github.com/Qarox/cakephp-nsapi) - Provides access to the NS (Nederlandse Spoorwegen) APIs.\n- [Stagemarkt plugin](https://github.com/ICT-College/cakephp-stagemarkt) - Provides access to the SBB Stagemarkt REST APIs.\n- [Twitter plugin](https://github.com/cvo-technologies/cakephp-twitter) - Provides access to the Twitter REST and streaming APIs.\n\n### As a driver\n\nThe following plugins implement a Webservice driver with their own methods:\n\n- [GitHub plugin](https://github.com/UseMuffin/Github) - Provides access to the GitHub REST APIs.\n- [Pusher plugin](https://github.com/UseMuffin/Pusher) - Provides access to the Pusher APIs.\n- [TMDB plugin](https://github.com/drmonkeyninja/cakephp-tmdb) - Provides access to the TMDB APIs.\n\n## Patches \u0026 Features\n\n* Fork\n* Mod, fix\n* Test - this is important, so it's not unintentionally broken\n* Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of\ntheir own that I can ignore when I pull)\n* Pull request - bonus point for topic branches\n\nTo ensure your PRs are considered for upstream, you MUST follow the CakePHP coding standards.\n\n## Bugs \u0026 Feedback\n\nhttp://github.com/usemuffin/webservice/issues\n\n## License\n\nCopyright (c) 2015-Present, [Use Muffin] and licensed under [The MIT License][mit].\n\n[cakephp]:http://cakephp.org\n[composer]:http://getcomposer.org\n[mit]:http://www.opensource.org/licenses/mit-license.php\n[muffin]:http://usemuffin.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusemuffin%2Fwebservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fusemuffin%2Fwebservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusemuffin%2Fwebservice/lists"}