{"id":37009702,"url":"https://github.com/trabdlkarim/lararestler","last_synced_at":"2026-01-14T00:55:59.591Z","repository":{"id":292933014,"uuid":"981682302","full_name":"trabdlkarim/lararestler","owner":"trabdlkarim","description":"A simple package for integrating seamlessly Restler API into your Laravel application.","archived":false,"fork":false,"pushed_at":"2025-12-20T12:53:35.000Z","size":198,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-11T16:45:00.184Z","etag":null,"topics":["api","api-rest","api-server","apis","laravel","laravel-package","rest-api","restful-api","restful-apis","restler"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/trabdlkarim.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,"zenodo":null}},"created_at":"2025-05-11T16:58:44.000Z","updated_at":"2025-12-20T12:53:38.000Z","dependencies_parsed_at":"2025-05-14T22:33:44.495Z","dependency_job_id":null,"html_url":"https://github.com/trabdlkarim/lararestler","commit_stats":null,"previous_names":["trabdlkarim/laravel-restler","trabdlkarim/lararestler"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/trabdlkarim/lararestler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trabdlkarim%2Flararestler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trabdlkarim%2Flararestler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trabdlkarim%2Flararestler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trabdlkarim%2Flararestler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trabdlkarim","download_url":"https://codeload.github.com/trabdlkarim/lararestler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trabdlkarim%2Flararestler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api","api-rest","api-server","apis","laravel","laravel-package","rest-api","restful-api","restful-apis","restler"],"created_at":"2026-01-14T00:54:58.970Z","updated_at":"2026-01-14T00:55:56.561Z","avatar_url":"https://github.com/trabdlkarim.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003ca href=\"https://laravel.com\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/trabdlkarim/assets/main/lararestler/preview.png\" alt=\"Lararestler\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/laravel/framework/actions\"\u003e\u003cimg src=\"https://github.com/laravel/framework/workflows/tests/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/trabdlkarim/lararestler\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/trabdlkarim/lararestler\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/trabdlkarim/lararestler\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/trabdlkarim/lararestler\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/trabdlkarim/lararestler\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/trabdlkarim/lararestler\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Restler for Laravel\n\nLararestler is a simple package that lets you to take advantage of all the features from both [Restler 5](https://restler5.luracast.com/) and Laravel as your API backend. With this package you can seamlessly integrate Restler into your existing laravel application without any hassle.\n\n## Installation\n\nYou can easily install this package with `conmposer`.\n\n```shell\ncomposer require trabdlkarim/lararestler\n```\n\n\u003e [!WARNING]\n\u003e You should note that this package works actually with Laravel framework `^12.x`.\n\nAfter the installation, you must publish the package assets for customization. Run the following command:\n\n```shell\nphp artisan vendor:publish --tag=lararestler-config --tag=lararestler-assets\n```\n\nThe following files should be generated if everything works fine:\n\n- `config/lararestler.php`\n- `resources/views/vendor/lararestler/explorer.blade.php`\n- `public/vendor/lararestler/*`\n\nNow, feel free to change or modifiy any of these files as needed, to adapt them to your project.\n\n## Usage\n\nBefore starting writting your API, make sure you've properly set the API resource `namespace` in `config/lararestler.php`.\nThe default namespace is `App\\Http\\Resources`.\n\n### Add Resources to API\n\nCreate a new class and extend `Mirak\\Lararestler\\Http\\Resources\\Resource` class.\nAdd all the needed private and public methods as you would do with Restler.\n\nLet's define a basic API class called `Users` as an example.\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Resources;\n\nuse App\\Models\\User;\nuse Mirak\\Lararestler\\Attributes\\QueryParam as QParam;\nuse Mirak\\Lararestler\\Exceptions\\RestException;\nuse Mirak\\Lararestler\\Http\\Resources\\Resource;\n\nclass Users extends Resource\n{\n    /**\n     * Retrieve users\n     * \n     * @param int $id User ID\n     * @param string $email Email Address\n     * @param string $name Name\n     * @return App\\Http\\Responses\\UserResponse\n     */\n    public function index(#[QParam('id')] ?int $id = 0, #[QParam('email')] ?string $email = '', #[QParam('name')] ?string $name = '')\n    {\n        $builder = User::select('*');\n        if ($id) {\n            $builder = $builder-\u003ewhere('id', $id);\n        }\n        if ($email) {\n            $builder =  $builder-\u003ewhere('email', $email);\n        }\n        if ($name) {\n            $builder = $builder-\u003ewhere('name', 'like', '%' . $name . '%');\n        }\n        return $builder-\u003eget();\n    }\n\n    /**\n     * Retrieve a user info\n     * \n     * Retrieve a given user details from storage\n     * \n     * @param int $id User ID\n     * @return array\n     * @url GET /{id}\n     * @throws RestException\n     */\n    public function get(int $id)\n    {\n        $user = User::find($id);\n        if (!$user) throw new RestException(404, \"User #{$id} does not exist.\");\n        return $user;\n    }\n}\n```\n\nNote that we make use of `Mirak\\Lararestler\\Attributes\\QueryParam` contextual attribute to caputure relevant query parameters from the current request.\n\nThere is also another attribute `Mirak\\Lararestler\\Attributes\\RequestBody`, useful when you want to capture all request body as an array.\n\nAfterwards, you need to add your newly created resource class to the API `resources` array in `config/lararestler.php` file as shown below.\n\n```php\n\u003c?php\n\nreturn [\n    \"name\" =\u003e \"REST API\",\n    \"version\" =\u003e 1,\n    \"path_prefix\" =\u003e \"api\",\n    \"middleware\" =\u003e [\"api\"],\n    \"allowed_envs\" =\u003e ['local'],\n    \"namespace\" =\u003e \"App\\\\Http\\\\Resources\",\n    \"resources\" =\u003e [\n        \"users\" =\u003e \"Users\",\n    ],\n];\n```\n\nThat's it, you're done! Visit the Explorer at `{APP_URL}/api/explorer` to play with the API.\n\n### Request Models\n\nYour request models should extend `Mirak\\Lararestler\\Http\\Requests\\Model` class as follows:\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Requests;\n\nuse Mirak\\Lararestler\\Http\\Requests\\Model;\n\nclass UserRequest extends Model\n{\n    /**\n     * @var string Name {@required true}\n     */\n    public $name;\n\n    /**\n     * @var string Email Address {@required true}\n     */\n    public $email;\n}\n```\n\nThen, you could inject them into your resource class methods and use them as an instance of Laravel `Illuminate\\Http\\Request` class.\nCheck the example below.\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Resources;\n\nuse App\\Http\\Requests\\UserRequest;\nuse App\\Models\\User;\nuse Mirak\\Lararestler\\Attributes\\QueryParam as QParam;\nuse Mirak\\Lararestler\\Exceptions\\RestException;\nuse Mirak\\Lararestler\\Http\\Resources\\Resource;\n\nclass Users extends Resource{\n    /**\n     * Create a new user\n     * \n     * @param UserRequest $postRequest\n     * @return App\\App\\Http\\Responses\\UserResponse\n     */\n    public function post(UserRequest $postRequest)\n    {\n        $v = $postRequest-\u003evalidate([\n            'name' =\u003e ['required', 'string', 'max:255'],\n            'email' =\u003e ['required', 'string', 'max:255'],\n            'phone' =\u003e ['nullable', 'string', 'max:255'],\n            'role' =\u003e ['nullable', 'string', 'max:255'],\n            'location' =\u003e ['nullable', 'string', 'max:255'],\n        ]);\n\n        $user = User::create([\n            'name' =\u003e $v['name'],\n            'email' =\u003e $v['email'],\n            'phone' =\u003e $v['phone'],\n            'role' =\u003e $v['role'],\n            'location' =\u003e $v['location'],\n            'password' =\u003e 'pass123456',\n        ]);\n\n        return $user;\n    }\n}\n```\n\n## Protected API Routes\n\nTo protect a route in your resource class, simply add the `@middleware` annotation, followed by the name of the middleware, to the method documentation.\n\n```php\n/**\n * @param Illuminate\\Http\\Request $request\n * @url POST /test\n * @middleware auth:web,admin\n */\npublic function postTest(Request $request){\n    //\n}\n```\n\n## Contributing\n\nThank you for considering contributing to this package! You should take a look at the contribution guide [here](https://laravel.com/docs/contributions).\n\n## Code of Conduct\n\nIn order to ensure that the Lararestler community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).\n\n## Security\n\nIf you discover a security vulnerability within this package, please send me an e-mail via [mail@trabdlkarim.me](mailto:mail@trabdlkarim.me). All security vulnerabilities will be promptly addressed.\n\n## License\n\nThis is an open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrabdlkarim%2Flararestler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrabdlkarim%2Flararestler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrabdlkarim%2Flararestler/lists"}