{"id":18784155,"url":"https://github.com/kdevelopement/ci-restserver","last_synced_at":"2026-05-27T18:31:21.982Z","repository":{"id":62485989,"uuid":"471354226","full_name":"KDevelopement/ci-restserver","owner":"KDevelopement","description":"A fully RESTful server implementation for CodeIgniter using one library, one config file and one controller.","archived":false,"fork":false,"pushed_at":"2022-11-08T08:42:53.000Z","size":40,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-14T08:44:56.862Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KDevelopement.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":"2022-03-18T12:12:01.000Z","updated_at":"2025-09-11T14:43:25.000Z","dependencies_parsed_at":"2022-11-02T10:16:03.349Z","dependency_job_id":null,"html_url":"https://github.com/KDevelopement/ci-restserver","commit_stats":null,"previous_names":["klicense/ci-restserver","kdevelopement/ci-restserver"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/KDevelopement/ci-restserver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KDevelopement%2Fci-restserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KDevelopement%2Fci-restserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KDevelopement%2Fci-restserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KDevelopement%2Fci-restserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KDevelopement","download_url":"https://codeload.github.com/KDevelopement/ci-restserver/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KDevelopement%2Fci-restserver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33579665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-07T20:42:09.042Z","updated_at":"2026-05-27T18:31:21.964Z","avatar_url":"https://github.com/KDevelopement.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodeIgniter RestServer\n\n[![StyleCI](https://github.styleci.io/repos/471354226/shield?branch=master)](https://github.styleci.io/repos/471354226)\n\nA fully RESTful server implementation for CodeIgniter using one library, one config file and one controller.\n\n## Requirements\n\n- PHP 7.2 or greater\n- CodeIgniter 3.1.11+\n\n## Installation\n\n```sh\ncomposer require kseven/ci-restserver\n```\n\n## Usage\n\nCodeIgniter Rest Server is available on [Packagist](https://packagist.org/packages/kseven/ci-restserver) (using semantic versioning), and installation via composer is the recommended way to install Codeigniter Rest Server. Just add this line to your `composer.json` file:\n\n```json\n\"kseven/ci-restserver\": \"^3.1.4\"\n```\n\nor run\n\n```sh\ncomposer require kseven/ci-restserver\n```\n\nNote that you will need to copy `rest.php` to your `config` directory (e.g. `application/config`)\n\nStep 1: Add this to your controller (should be before any of your code)\n\n```php\nuse kseven\\CIRestServer\\RestController;\n```\n\nStep 2: Extend your controller\n\n```php\nclass Example extends RestController\n```\n\n## Basic GET example\n\nHere is a basic example. This controller, which should be saved as `Api.php`, can be called in two ways:\n\n* `http://domain/api/users/` will return the list of all users\n* `http://domain/api/users/id/1` will only return information about the user with id = 1\n\n```php\n\u003c?php\ndefined('BASEPATH') OR exit('No direct script access allowed');\n\nuse kseven\\CIRestServer\\RestController;\n\nclass Api extends RestController {\n\n    function __construct()\n    {\n        // Construct the parent class\n        parent::__construct();\n    }\n\n    public function users_get()\n    {\n        // Users from a data store e.g. database\n        $users = [\n            ['id' =\u003e 0, 'name' =\u003e 'John', 'email' =\u003e 'john@example.com'],\n            ['id' =\u003e 1, 'name' =\u003e 'Jim', 'email' =\u003e 'jim@example.com'],\n        ];\n\n        $id = $this-\u003eget( 'id' );\n\n        if ( $id === null )\n        {\n            // Check if the users data store contains users\n            if ( $users )\n            {\n                // Set the response and exit\n                $this-\u003eresponse( $users, 200 );\n            }\n            else\n            {\n                // Set the response and exit\n                $this-\u003eresponse( [\n                    'status' =\u003e false,\n                    'message' =\u003e 'No users were found'\n                ], 404 );\n            }\n        }\n        else\n        {\n            if ( array_key_exists( $id, $users ) )\n            {\n                $this-\u003eresponse( $users[$id], 200 );\n            }\n            else\n            {\n                $this-\u003eresponse( [\n                    'status' =\u003e false,\n                    'message' =\u003e 'No such user found'\n                ], 404 );\n            }\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkdevelopement%2Fci-restserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkdevelopement%2Fci-restserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkdevelopement%2Fci-restserver/lists"}