{"id":20963867,"url":"https://github.com/codemix/restyii","last_synced_at":"2025-05-14T09:31:55.015Z","repository":{"id":9294589,"uuid":"11130555","full_name":"codemix/restyii","owner":"codemix","description":"A RESTful extension for Yii.","archived":false,"fork":false,"pushed_at":"2014-10-04T13:29:17.000Z","size":830,"stargazers_count":15,"open_issues_count":7,"forks_count":11,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-04-23T04:14:39.077Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codemix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-02T17:23:02.000Z","updated_at":"2024-04-23T04:14:39.077Z","dependencies_parsed_at":"2022-09-02T19:41:46.409Z","dependency_job_id":null,"html_url":"https://github.com/codemix/restyii","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Frestyii","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Frestyii/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Frestyii/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Frestyii/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemix","download_url":"https://codeload.github.com/codemix/restyii/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225284593,"owners_count":17449932,"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-11-19T02:48:41.012Z","updated_at":"2024-11-19T02:48:41.549Z","avatar_url":"https://github.com/codemix.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Restyii\n\nA RESTful [HATEOAS](http://en.wikipedia.org/wiki/HATEOAS) compliant extension for Yii.\nAllows your application to serve and accept JSON, JSONP, XML, CSV or HTML using the same code.\nThe JSON and XML variants are based on the [HAL](http://stateless.co/hal_specification.html) media type.\n\n\n## WARNING: Pre-alpha software, use at your own risk.\n\n# Installation.\n\nInstall using composer. Requires php 5.3 or later.\n\nRestyii makes use of a custom `WebApplication` that replaces the Yii default. For this reason it's\nnecessary to replace existing calls to\n\n    Yii::createWebApplication($config)\n\nwith\n\n    Yii::createApplication('Restyii\\\\Web\\\\Application', $config)\n\nin your `index.php` file.\n\n\n# Server Configuration.\n\nExample Restyii server application config\n\n    \u003c?php\n    Yii::setPathOfAlias('vendor', __DIR__.'/../../vendor'); // the path to the composer vendors dir\n    return array(\n      'name' =\u003e 'Restyii Demo',\n      'description' =\u003e 'This is a description of the application!',\n      'import' =\u003e array(\n        'application.resources.*',\n      ),\n      'modules' =\u003e array(\n          'gii'=\u003earray(\n              'class'=\u003e'system.gii.GiiModule',\n              'password'=\u003e'yourSecretPassword',\n              // If removed, Gii defaults to localhost only. Edit carefully to taste.\n              'ipFilters'=\u003earray('127.0.0.1','::1'),\n              'generatorPaths'=\u003earray(\n                  'vendor.codemix.restyii.gii-templates',\n              ),\n          ),\n      ),\n      'components' =\u003e array(\n            'urlManager' =\u003e array(\n                'rules' =\u003e array(\n                    '' =\u003e array('/default/index'),\n                    array('class' =\u003e 'Restyii\\\\Web\\\\UrlRule'),\n                 ),\n            ),\n      ),\n    );\n\n\nRestyii comes with a Gii code generator that makes generating resources easy.\n\n\n# Client Configuration.\n\nExample Restyii client application config\n\n    \u003c?php\n    return array(\n      'name' =\u003e 'Restyii Client Demo',\n      'import' =\u003e array(\n        'application.resources.*',\n      ),\n      'components' =\u003e array(\n            'api' =\u003e array(\n                'class' =\u003e 'Restyii\\\\Client\\\\Connection',\n                'baseUrl' =\u003e 'http://yourapihostname/',\n            ),\n            ...\n      ),\n    );\n\n\n\n\n# RAVE\n\nRestyii follows the RAVE application architecture. RAVE is quite similar to MVC,  but there are some important differences,\nRAVE stands for:\n\n* __Resources__\n* __Actions__\n* __Views__\n* __Events__\n\n\nImportantly, Resources, Actions, Views and Events all __describe__ themselves.\nThis allows the RAVE application to be self-documenting.\n\n\n## Resources\n\nResources are analogous to the Model in MVC, but they have some key differences.\n\n* Individual resources are explicitly tied to particular URLs.\n* Resources know how to link to themselves and to related resources.\n* Resources know how to *describe* themselves and their attributes.\n* Resources know how to *format* their own attributes.\n\n\nIn RAVE, the bulk of your business logic should be placed in resources, RAVE embraces the __fat__ model approach.\n\n\n## Actions\n\nActions are analogous to the operations performed by a Controller in MVC.\n\n* Actions *should* accept any kind of resource. This promotes code reuse and is made possible by the rich meta data resources provide.\n* Actions know which http headers and query string parameters to expect and how to describe them.\n* Actions are associated with a specific HTTP verb that is used to perform an action, e.g. DELETE for delete actions.\n* Actions return a HTTP status code along with their data.\n\nActions usually operate either on individual resources or collections of resources.\n\n## Views\n\nRAVE Views are effectively identical to views in MVC. In Restyii they are used to decorate data (usually as HTML) when the client requests something other than XML, JSON etc.\n\n## Events\n\nEvents are triggered by resources when they change state in some way, such as when a particular model is created or updated.\nRAVE events are usually published to a message bus or a pub/sub channel to allow communication with other processes in the application,\nfor example, to allow 'realtime' notifications in the browser.\n\n# Differences from standard Yii applications\n\nIn order to implement RAVE, Restyii applications require several changes to the standard Yii way of doing things.\n\nSome important ones:\n\n* The web application must be an instance of `Restyii\\Web\\Application`.\n\n* The default controller for all modules, including the main application, should be called `DefaultController`. This means\nthe normal `SiteController` should be renamed. `DefaultController` should extend the `Restyii\\Controller\\Root` class.\n\n* The request (`Yii::app()-\u003erequest`) now has a `getResponse()` method that returns a `Restyii\\Web\\Response`\n  instance. This response instance is responsible for formatting and sending the data to the client.\n\n* Controllers __always__ use class based actions, and controllers are explicitly tied to resource types. Resource controllers extend `Restyii\\Controller\\Model`\n\n* Actions __always__ extend the `Restyii\\Action\\Base` class\n\n* Rather than implementing `run()`, actions should implement `present()` and `perform()` methods.\n\n* Rather than calling `$this-\u003erender(...)`, actions should return the data for the response from within the `present()` and `perform()` methods, along with the appropriate HTTP status code.\n\n* Application has a `schema` component that introspects the application and determines the available resources, actions etc.\n\n* Resources extend `Restyii\\Model\\ActiveRecord`.\n\n* Resources have a `links()` method that returns the appropriate links for the current resource.\n\n* Resources have `classLabel()` and `instanceLabel()` methods that return the appropriate labels for the resource type and a particular resource instance.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemix%2Frestyii","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemix%2Frestyii","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemix%2Frestyii/lists"}