{"id":18970800,"url":"https://github.com/dilexus/octobase-plugin","last_synced_at":"2025-04-19T15:03:05.783Z","repository":{"id":182175761,"uuid":"668065324","full_name":"dilexus/octobase-plugin","owner":"dilexus","description":"October CMS Plugin for REST API Services","archived":false,"fork":false,"pushed_at":"2024-05-29T01:56:06.000Z","size":114,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T09:05:46.411Z","etag":null,"topics":["hacktoberfest","laravel","octobercms","octobercms-plugin","php"],"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/dilexus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-07-19T00:24:07.000Z","updated_at":"2024-07-28T16:37:31.000Z","dependencies_parsed_at":"2024-01-13T18:53:23.169Z","dependency_job_id":"bb8765d6-43b9-4403-b58a-d0afee3364a9","html_url":"https://github.com/dilexus/octobase-plugin","commit_stats":null,"previous_names":["chaturadilan/octobase","chaturadilan/octobase-plugin","dilexus/octobase-plugin"],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilexus%2Foctobase-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilexus%2Foctobase-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilexus%2Foctobase-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilexus%2Foctobase-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dilexus","download_url":"https://codeload.github.com/dilexus/octobase-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249213766,"owners_count":21231096,"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":["hacktoberfest","laravel","octobercms","octobercms-plugin","php"],"created_at":"2024-11-08T14:57:59.291Z","updated_at":"2025-04-16T07:35:07.992Z","avatar_url":"https://github.com/dilexus.png","language":"PHP","funding_links":["https://www.buymeacoffee.com/bcdperera"],"categories":[],"sub_categories":[],"readme":"\n # Octobase : REST API Services Plugin for OctoberCMS\n\n## Introduction\nAn awesome  plugin for OctoberCMS is available to expose REST API services for data access from anywhere. This plugin enables the creation of CRUD operations for REST services and allows the creation of custom REST services with middleware support for API authorization. Additionally, the plugin provides an API for OctoberCMS frontend users to perform actions such as login, registration, token refresh, and retrieval of user information. Bearer API tokens are utilized for API authorization within this plugin.\n\n## Requirements\nTested in PHP 8.2 and above. You need to enable sodium extension in the server inorder to work with this plugin\n\n## Flutter SDK\nYou can connect the APIs of your Octobase Easily with Flutter SDK here https://pub.dev/packages/octobase_flutter\n\n## Manual Installation\nphp artisan plugin:install Dilexus.Octobase --from=https://github.com/chaturadilan/octobase-plugin.git\n\n## Roadmap\nThis plugin requires additional features to be added in the future.\n\n1. Web SDK (Javascript) support for the plugin\n\nYou can assist in accelerating the development of the plugin by contributing to the following features that are on the roadmap.\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/bcdperera)\n\n\n##  How To\nIf you want to expose a REST webservice from your OctoberCMS plugin, please ensure that the following plugins have been installed.\n1. October CMS Frontend Users Plugin\n2. Octobase Plugin\n\n## Create your Routes and APIs\n1. Create routes.php in your plugin\n2. As an example if you want to enable CRUD services. Let's say your plugin is School and you have a Model for Student\n\n```\nuse Dilexus\\Octobase\\Classes\\Api\\Lib\\Octobase;\n\n...\n\n\n  Route::prefix('api/school/v1')-\u003egroup(function () {\n\n    (new Octobase)-\u003ecrud('Dilexus\\School\\Models\\Student',\n        ['obPublic'], // List All records\n        ['obPublic'], // List single record\n        ['obPublic'], // add single record\n        ['obPublic'], // update single record\n        ['obPublic']  // delete single record\n    );\n\n});\n\n ```\n\nHere obPublic is a middlewere that expose your CRUD APIs to public.\n\nMore Examples\n\n```\n (new Octobase)-\u003ecrud('Dilexus\\School\\Models\\Student',\n        createM: ['obPublic'], // Enable only the add (create) API\n    );\n```\n\n## Operations\n\nThe above will expose the following APIs to the public\n\n### Main APIs\n\nGET     /api/school/v1/students       - List all students (you can use page, limit query parametrs for pagination, with, where, order quary parameters to filter data)\n\nGET     /api/school/v1/students/1     - List single student by Id (form parameters are required)\n\nPOST    /api/school/v1/students      - Create a new student (form parameters are required)\n\nPOST    /api/school/v1/students/1    - updates a student by Id\n\nDELETE  /api/school/v1/students/1  - delete a student by Id\n\n### File APIs\n\nPOST    /api/school/v1/students/1/files    - upload file to the student (form file parameters are required)\n\nDELETE    /api/school/v1/students/1/files    - delete file of a student (file parameter name is required, use all to delete all files)\n\n### Language\nif you want to speicify a language to the api, either you can use Content-Language (Eg: Content-Language: en) header or locale (Eg: locale=en) query parameter. For this you need to have OctoberCMS Translation plugin\n\n## More Examples\n\nThis will only allow list API to public, by default other APIs are restricted to anyone\n\n```\n  Route::prefix('api/school/v1')-\u003egroup(function () {\n\n    (new Octobase)-\u003ecrud('Dilexus\\School\\Models\\Category',\n        ['obPublic'], // List All records\n    );\n\n});\n\n ```\n\n\n## Middleware\n\n#### obRestricted\nRestrict Anyone from acccessing the APIs\n\n#### obRegistered\nOnly registered users will be allowed to access the APIs. If you want to restrict registered users to only access their own data, add \":true\" after the middleware name. For example, [obRegistered:true]. However, please ensure that the table has a user_id column if you choose to do so.\n\n#### obAdmin\nOnly registered Admin will be allowed to access the APIs. Please make sure to create a Admin user group with the code 'admin' in the Groups section of the Users Plugin and user has been assigned to admin group. Admin has permission to do any operations on the APIs\n\n#### obPublic\nAnyone who calls the APIs has unrestricted access to them.\n\n#### obGroups\nOnly the defined groups can access the APIs. For example, if you want to restrict access to the groups \"admin\" and \"api\", you can add them as follows using a colon: [obGroups:admin:api].\n\n## Custom Functions\nIf you want to modify the output before it is sent to the client, you can use a custom function like below\n\n```\n (new Octobase)-\u003ecrud('Dilexus\\School\\Models\\Student',\n        ['obPublic'],\n        function :function ($request, $records, $method) {\n            return $records-\u003eselect('name');\n        }\n );\n\n```\n\n\n## Authentication and Authrorization\n\n### Authentication\nYou can authenticate the API using following API. You have to send login, password form parameters. login is the user's email\n\nPOST /octobase/login\n\n#### Registration\nYou can register the user using following API. You need to send first_name, last_name, email, password, confirm_password as form parameters. You can disable this feature from Octobase plugin settings. Also You can enable the auto activation of the user from the plugin settings.\n\nPOST /octobase/register\n\n#### Refresh\nYou can send the SHA256 token and get a new token from refresh API. You need to send the token in the Authtorization heder as a Bearer token\n\nPOST /octobase/refresh\n\n#### User\nYou get the user information from this API. You need to send the token in the Authtorization header as a Bearer token\n\nGET /octobase/user\n\n#### Check\nYou get the status of the token whether it is exist or not. You need to send the token in the Authtorization header as a Bearer token\n\nGET /octobase/check\n\n#### Firebase Authentication\nYou can authenticate it with Firebase by sending ID token to following API. It required a form parameter called token (eg: token=[Firebase User ID Token]). It will create a record in Users if the user is not there or return the existing user with Octobase token. You can use Octobease token after that to call APIs. Firebase can be configured in Octobase Settings\n\nPOST /octobase/login/firebase\n\n### Authrorization\nTo Authorize all your APIs you need to send the token in the Authtorization heder as a bearer token\n\n### Debug mode Settings\nIf you are using APIs solely for testing purposes, you can enable the debug mode to test them without authentication and authorization.\n\n\n## Create your own APIs with Middleware\nYou can attach Octobase middleware to your own APIs as well. As an example.\n\n```\nRoute::prefix('api/school/v1')-\u003egroup(function () {\n\n    Route::get('student/{id}/getInfo', function (Request $request, $id)  {\n       // Logic Here\n    })-\u003emiddleware(['obRegistered']);\n\n});\n\n```\n\n##  License (MIT)\n\nCopyright (c) 2023 Chatura Dilan Perera\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n## Developer\nThis plgin is developed by Chatura Dilan Perera\n\n## Bugs and Comments\nTo report bugs or comments on this app or if you are looking to create an Flutter app based on this app please contact me 'Chatura Dilan Perera'\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdilexus%2Foctobase-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdilexus%2Foctobase-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdilexus%2Foctobase-plugin/lists"}