{"id":15470527,"url":"https://github.com/presttec/codeigniter-restserver","last_synced_at":"2025-06-11T22:08:11.535Z","repository":{"id":57044510,"uuid":"275250858","full_name":"presttec/codeigniter-restserver","owner":"presttec","description":null,"archived":false,"fork":false,"pushed_at":"2020-06-26T21:36:52.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T12:44:18.107Z","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/presttec.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":"2020-06-26T21:27:11.000Z","updated_at":"2020-06-26T21:36:54.000Z","dependencies_parsed_at":"2022-08-24T04:11:15.930Z","dependency_job_id":null,"html_url":"https://github.com/presttec/codeigniter-restserver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/presttec/codeigniter-restserver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/presttec%2Fcodeigniter-restserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/presttec%2Fcodeigniter-restserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/presttec%2Fcodeigniter-restserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/presttec%2Fcodeigniter-restserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/presttec","download_url":"https://codeload.github.com/presttec/codeigniter-restserver/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/presttec%2Fcodeigniter-restserver/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259352699,"owners_count":22844739,"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-10-02T02:05:14.193Z","updated_at":"2025-06-11T22:08:11.498Z","avatar_url":"https://github.com/presttec.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodeIgniter RestServer\n\n[![StyleCI](https://github.styleci.io/repos/230589/shield?branch=master)](https://github.styleci.io/repos/230589)\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 presttec/codeigniter-restserver\n```\n\n## Usage\n\nCodeIgniter Rest Server is available on [Packagist](https://packagist.org/packages/presttec/codeigniter-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\"presttec/codeigniter-restserver\": \"^3.1\"\n```\n\nor run\n\n```sh\ncomposer require presttec/codeigniter-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 RestServer\\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 RestServer\\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%2Fpresttec%2Fcodeigniter-restserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpresttec%2Fcodeigniter-restserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpresttec%2Fcodeigniter-restserver/lists"}