{"id":15025141,"url":"https://github.com/svnwa/laravel-strapi","last_synced_at":"2025-08-22T16:04:42.871Z","repository":{"id":39861229,"uuid":"495777275","full_name":"svnwa/laravel-strapi","owner":"svnwa","description":"This package provides an implementation to consume the Strapi REST API","archived":false,"fork":false,"pushed_at":"2023-03-08T12:31:19.000Z","size":20,"stargazers_count":3,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T07:51:10.142Z","etag":null,"topics":["cms","cms-backend","laravel","laravel-cms","laravel-framework","laravel-package","strapi","strapi-cms","strapi-v4","strapi4","strapicms"],"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/svnwa.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":"contributing.md","funding":null,"license":null,"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":"2022-05-24T10:36:58.000Z","updated_at":"2024-03-13T12:25:21.000Z","dependencies_parsed_at":"2024-09-30T10:40:38.657Z","dependency_job_id":null,"html_url":"https://github.com/svnwa/laravel-strapi","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.25,"last_synced_commit":"d1d66d3e454aa07f6a98f767b2197d2426abd00c"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svnwa%2Flaravel-strapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svnwa%2Flaravel-strapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svnwa%2Flaravel-strapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svnwa%2Flaravel-strapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/svnwa","download_url":"https://codeload.github.com/svnwa/laravel-strapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248571864,"owners_count":21126522,"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":["cms","cms-backend","laravel","laravel-cms","laravel-framework","laravel-package","strapi","strapi-cms","strapi-v4","strapi4","strapicms"],"created_at":"2024-09-24T20:01:34.096Z","updated_at":"2025-04-12T13:13:01.591Z","avatar_url":"https://github.com/svnwa.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel [Strapi](https://strapi.io/)\n\n[![Latest Version on Packagist][ico-version]][link-packagist] [![Total Downloads][ico-downloads]][link-downloads]\n\nThis package provides an implementation to consume the [Strapi REST API](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html). \n\nThe current implementation only supports fetching data from Strapi since I personally didn't have a use case to write data to it via API yet.\n\nCurrently supports Strapi v4 which is a bit different from the preceding v3 REST API.\n\n---\n\n## Installation\n\n##### 1. Installation via Composer\n\n``` bash\ncomposer require svnwa/laravel-strapi\n```\n\n##### 2. Publishing the the config file:\n``` bash\nphp artisan vendor:publish --provider=\"svnwa\\laravel-strapi\\LaravelStrapiServiceProvider\" --tag=\"laravel-strapi\"\n```\n\n##### 3. Editing the the **.env** file:\n\nThe ```STRAPI_CACHE_STORAGE_TIME``` is optional.[^1] \n###### The default value is defined in the config file at 3600 seconds (1 hour). \n[^1]: Time is in seconds.\n``` \nSTRAPI_API_TOKEN=some_strapi_api_token\nSTRAPI_BASE_URL=\"https://somestrapiurl.com\"\nSTRAPI_CACHE_STORAGE_TIME=3600\n```\n\n##### 4. Optional \"cache reset\" route\nThis package also provides an optional route to automatically reset the cache with a Webhook from within Strapi e.g. after update or creation of a resource.\nThe route can be activated in the config file. Just set the value to true:\n```\n'cacheResetRoute' =\u003e true\n``` \n\n---\n\n## Usage\nThis package attemps to make use of a fluent api similar to Laravels Eloquent:\n```php\nuse Svnwa\\LaravelStrapi\\Facades\\Strapi;\n\n$listOfRestaurants = Strapi::collection('restaurants')\n    -\u003epaginate(0,20,true)\n    -\u003efields(['name','adress','tel'])\n    -\u003esortBy([\n            ['name','asc'],\n        ]\n    -\u003efilterBy([\n            ['[name][$contains]','pizza'],\n        ])\n    -\u003epopulate()\n    -\u003elocale('de')\n    -\u003ewithFullUrls()\n    -\u003epublicationState('preview')\n    -\u003eget();\n```\n#### Examples\n\n1. [Get a list of entries](https://github.com/svnwa/laravel-strapi#get-a-list-of-entries)\n2. [Get an entry](https://github.com/svnwa/laravel-strapi#get-a-list-of-entries)\n3. [Parameters](https://github.com/svnwa/laravel-strapi#using-strapis-basic-api-parameters)\n\n    + [sort](https://github.com/svnwa/laravel-strapi#sort-sorting-the-response)\n    + [pagination](https://github.com/svnwa/laravel-strapi#pagination-page-through-entries)\n    + [filters](https://github.com/svnwa/laravel-strapi#filters)\n    + [fields](https://github.com/svnwa/laravel-strapi#fields)\n    + [populate](https://github.com/svnwa/laravel-strapi#populate)\n    + [publicationState](https://github.com/svnwa/laravel-strapi#publicationstate)\n    + [locale](https://github.com/svnwa/laravel-strapi#locale)\n\n\n* ###### Get a list of entries\n\n```GET``` ```api/restaurants```\n\n```php\nuse Svnwa\\LaravelStrapi\\Facades\\Strapi;\n\n$listOfRestaurants = Strapi::collection('restaurants')-\u003eget();\n```\n\n\n* ###### Get an entry\n\n```GET``` ```api/restaurants/999```\n```php\nuse Svnwa\\LaravelStrapi\\Facades\\Strapi;\n\n$listOfRestaurants = Strapi::entry('restaurants',999)-\u003eget();\n```\n\n#### Using Strapis basic [API Parameters](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#api-parameters):\n\n* ###### ```sort``` Sorting the response\nSupports Strapis sorting on one or multiple fields and/or their direction\n\n```GET``` ```api/restaurants?sort[0]=id:asc\u0026sort[1]=name:desc```\n```php\nuse Svnwa\\LaravelStrapi\\Facades\\Strapi;\n\n$listOfRestaurants = Strapi::collection('restaurants')\n    -\u003esortBy([\n        ['id','asc'],\n        ['name','desc'],\n    ]);\n```\n* ###### ```pagination``` Page through entries\nSupports Strapis pagination on results by offset\n\n```GET``` ```api/restaurants?pagination[start]=0\u0026pagination[limit]=20\u0026pagination[withCount]=true```\n```php\nuse Svnwa\\LaravelStrapi\\Facades\\Strapi;\n\n$listOfRestaurants = Strapi::collection('restaurants')\n    -\u003epaginate(0,20,true);\n```\n* ###### ```filters```\nSupports Strapis filter results found with its \"Get entries\" method\n\n```GET``` ```api/restaurants?filters[name][$contains]=pizza```\n```php\nuse Svnwa\\LaravelStrapi\\Facades\\Strapi;\n\n$listOfRestaurants = Strapi::collection('restaurants')\n    -\u003efilterBy([\n        ['[name][$contains]','pizza'],\n    ]);\n```\n* ###### ```fields```\nQueries can accept a fields parameter to select only some fields.\n\n```GET``` ```api/restaurants?fields[0]=name\u0026fields[1]=adress\u0026fields[2]=tel```\n```php\nuse Svnwa\\LaravelStrapi\\Facades\\Strapi;\n\n$listOfRestaurants = Strapi::collection('restaurants')\n    -\u003efields(['name','adress','tel']);\n```\n* ###### ```populate```\nQueries can accept a populate parameter to populate various field types\n\nPopulate with wildcard. If no parameter is given to the populate() method it defauls to using the wildcard operator:\n```GET``` ```api/restaurants?populate=*```\n```php\nuse Svnwa\\LaravelStrapi\\Facades\\Strapi;\n\n$listOfRestaurants = Strapi::collection('restaurants')\n    -\u003epopulate();\n```\nor:\n\n```GET``` ```api/restaurants?populate[0]=menu\u0026populate[1]=customers```\n```php\nuse Svnwa\\LaravelStrapi\\Facades\\Strapi;\n\n$listOfRestaurants = Strapi::collection('restaurants')\n    -\u003epopulate(['menu','customers']);\n```\nTip: Strapi offers deep population for e.g. nested components and does not populate them by default. Even not with the wildcard *\n```GET``` ```api/restaurants?populate[0]=menu.images```\n\n* ###### ```publicationState```\n```GET``` ```api/restaurants?publicationState=preview```\nQueries can accept a publicationState parameter to fetch entries based on their publication state:\n\n```php\nuse Svnwa\\LaravelStrapi\\Facades\\Strapi;\n\n$listOfRestaurants = Strapi::collection('restaurants')\n    -\u003epublicationState('preview');\n```\n\n* ###### ```locale```\nThe locale API parameter can be used to get entries from a specific locale\n\n```GET``` ```api/restaurants?locale=de```\n```php\nuse Svnwa\\LaravelStrapi\\Facades\\Strapi;\n\n$listOfRestaurants = Strapi::collection('restaurants')\n    -\u003elocale('de');\n```\n\n## License\n\nMIT. Please see the [license file](LICENCE) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/svnwa/laravel-strapi.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/svnwa/laravel-strapi.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/svnwa/laravel-strapi\n[link-downloads]: https://packagist.org/packages/svnwa/laravel-strapi\n[link-author]: https://github.com/svnwa\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvnwa%2Flaravel-strapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsvnwa%2Flaravel-strapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvnwa%2Flaravel-strapi/lists"}