PHPackages                             svnwa/laravel-strapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. svnwa/laravel-strapi

ActiveLibrary[HTTP &amp; Networking](/categories/http)

svnwa/laravel-strapi
====================

This package provides an implementation to consume the Strapi REST API.

v1.2(3y ago)34.2k↓50%3[2 issues](https://github.com/svnwa/laravel-strapi/issues)MITPHP

Since May 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/svnwa/laravel-strapi)[ Packagist](https://packagist.org/packages/svnwa/laravel-strapi)[ Docs](https://github.com/svnwa/laravel-strapi)[ RSS](/packages/svnwa-laravel-strapi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

Laravel [Strapi](https://strapi.io/)
====================================

[](#laravel-strapi)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7bc28ddaa88363bc325d1d0f8e0e3bc360580650165b95275d503f82ee160e28/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73766e77612f6c61726176656c2d7374726170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/svnwa/laravel-strapi) [![Total Downloads](https://camo.githubusercontent.com/476525e937eae93628cd90cc45a5b7a136d90791418cb33e32a1465d3b121e8d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73766e77612f6c61726176656c2d7374726170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/svnwa/laravel-strapi)

This 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).

The 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.

Currently supports Strapi v4 which is a bit different from the preceding v3 REST API.

---

Installation
------------

[](#installation)

##### 1. Installation via Composer

[](#1-installation-via-composer)

```
composer require svnwa/laravel-strapi
```

##### 2. Publishing the the config file:

[](#2-publishing-the-the-config-file)

```
php artisan vendor:publish --provider="svnwa\laravel-strapi\LaravelStrapiServiceProvider" --tag="laravel-strapi"
```

##### 3. Editing the the **.env** file:

[](#3-editing-the-the-env-file)

The `STRAPI_CACHE_STORAGE_TIME` is optional.[1](#user-content-fn-1-143bf8293815cec0c6166cecd9c2b2a1)

###### The default value is defined in the config file at 3600 seconds (1 hour).

[](#the-default-value-is-defined-in-the-config-file-at-3600-seconds-1-hour)

```
STRAPI_API_TOKEN=some_strapi_api_token
STRAPI_BASE_URL="https://somestrapiurl.com"
STRAPI_CACHE_STORAGE_TIME=3600

```

##### 4. Optional "cache reset" route

[](#4-optional-cache-reset-route)

This 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. The route can be activated in the config file. Just set the value to true:

```
'cacheResetRoute' => true

```

---

Usage
-----

[](#usage)

This package attemps to make use of a fluent api similar to Laravels Eloquent:

```
use Svnwa\LaravelStrapi\Facades\Strapi;

$listOfRestaurants = Strapi::collection('restaurants')
    ->paginate(0,20,true)
    ->fields(['name','adress','tel'])
    ->sortBy([
            ['name','asc'],
        ]
    ->filterBy([
            ['[name][$contains]','pizza'],
        ])
    ->populate()
    ->locale('de')
    ->withFullUrls()
    ->publicationState('preview')
    ->get();
```

#### Examples

[](#examples)

1. [Get a list of entries](https://github.com/svnwa/laravel-strapi#get-a-list-of-entries)
2. [Get an entry](https://github.com/svnwa/laravel-strapi#get-a-list-of-entries)
3. [Parameters](https://github.com/svnwa/laravel-strapi#using-strapis-basic-api-parameters)

    - [sort](https://github.com/svnwa/laravel-strapi#sort-sorting-the-response)
    - [pagination](https://github.com/svnwa/laravel-strapi#pagination-page-through-entries)
    - [filters](https://github.com/svnwa/laravel-strapi#filters)
    - [fields](https://github.com/svnwa/laravel-strapi#fields)
    - [populate](https://github.com/svnwa/laravel-strapi#populate)
    - [publicationState](https://github.com/svnwa/laravel-strapi#publicationstate)
    - [locale](https://github.com/svnwa/laravel-strapi#locale)

- ###### Get a list of entries

    [](#get-a-list-of-entries)

`GET` `api/restaurants`

```
use Svnwa\LaravelStrapi\Facades\Strapi;

$listOfRestaurants = Strapi::collection('restaurants')->get();
```

- ###### Get an entry

    [](#get-an-entry)

`GET` `api/restaurants/999`

```
use Svnwa\LaravelStrapi\Facades\Strapi;

$listOfRestaurants = Strapi::entry('restaurants',999)->get();
```

#### Using Strapis basic [API Parameters](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#api-parameters):

[](#using-strapis-basic-api-parameters)

- ###### `sort` Sorting the response

    [](#sort-sorting-the-response)

Supports Strapis sorting on one or multiple fields and/or their direction

`GET` `api/restaurants?sort[0]=id:asc&sort[1]=name:desc`

```
use Svnwa\LaravelStrapi\Facades\Strapi;

$listOfRestaurants = Strapi::collection('restaurants')
    ->sortBy([
        ['id','asc'],
        ['name','desc'],
    ]);
```

- ###### `pagination` Page through entries

    [](#pagination-page-through-entries)

Supports Strapis pagination on results by offset

`GET` `api/restaurants?pagination[start]=0&pagination[limit]=20&pagination[withCount]=true`

```
use Svnwa\LaravelStrapi\Facades\Strapi;

$listOfRestaurants = Strapi::collection('restaurants')
    ->paginate(0,20,true);
```

- ###### `filters`

    [](#filters)

Supports Strapis filter results found with its "Get entries" method

`GET` `api/restaurants?filters[name][$contains]=pizza`

```
use Svnwa\LaravelStrapi\Facades\Strapi;

$listOfRestaurants = Strapi::collection('restaurants')
    ->filterBy([
        ['[name][$contains]','pizza'],
    ]);
```

- ###### `fields`

    [](#fields)

Queries can accept a fields parameter to select only some fields.

`GET` `api/restaurants?fields[0]=name&fields[1]=adress&fields[2]=tel`

```
use Svnwa\LaravelStrapi\Facades\Strapi;

$listOfRestaurants = Strapi::collection('restaurants')
    ->fields(['name','adress','tel']);
```

- ###### `populate`

    [](#populate)

Queries can accept a populate parameter to populate various field types

Populate with wildcard. If no parameter is given to the populate() method it defauls to using the wildcard operator: `GET` `api/restaurants?populate=*`

```
use Svnwa\LaravelStrapi\Facades\Strapi;

$listOfRestaurants = Strapi::collection('restaurants')
    ->populate();
```

or:

`GET` `api/restaurants?populate[0]=menu&populate[1]=customers`

```
use Svnwa\LaravelStrapi\Facades\Strapi;

$listOfRestaurants = Strapi::collection('restaurants')
    ->populate(['menu','customers']);
```

Tip: Strapi offers deep population for e.g. nested components and does not populate them by default. Even not with the wildcard \* `GET` `api/restaurants?populate[0]=menu.images`

- ###### `publicationState`

    [](#publicationstate)

`GET` `api/restaurants?publicationState=preview`Queries can accept a publicationState parameter to fetch entries based on their publication state:

```
use Svnwa\LaravelStrapi\Facades\Strapi;

$listOfRestaurants = Strapi::collection('restaurants')
    ->publicationState('preview');
```

- ###### `locale`

    [](#locale)

The locale API parameter can be used to get entries from a specific locale

`GET` `api/restaurants?locale=de`

```
use Svnwa\LaravelStrapi\Facades\Strapi;

$listOfRestaurants = Strapi::collection('restaurants')
    ->locale('de');
```

License
-------

[](#license)

MIT. Please see the [license file](LICENCE) for more information.

Footnotes
---------

1. Time is in seconds. [↩](#user-content-fnref-1-143bf8293815cec0c6166cecd9c2b2a1)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~144 days

Total

3

Last Release

1167d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7819d4f65fa0ed8926124eb178c584302aec4e612aac7f8fdae83583c7b23f69?d=identicon)[svnwa](/maintainers/svnwa)

---

Top Contributors

[![svnwa](https://avatars.githubusercontent.com/u/62885174?v=4)](https://github.com/svnwa "svnwa (9 commits)")

---

Tags

cmscms-backendlaravellaravel-cmslaravel-frameworklaravel-packagestrapistrapi-cmsstrapi-v4strapi4strapicmslaravelrestheadless cmsstrapiLaravel CMSLaravelStrapiLaravel Headless CMS

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/svnwa-laravel-strapi/health.svg)

```
[![Health](https://phpackages.com/badges/svnwa-laravel-strapi/health.svg)](https://phpackages.com/packages/svnwa-laravel-strapi)
```

###  Alternatives

[pusher/pusher-http-laravel

\[DEPRECATED\] A Pusher bridge for Laravel

400509.0k3](/packages/pusher-pusher-http-laravel)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[illuminatech/data-provider

Allows easy build for DB queries from API requests

4413.3k](/packages/illuminatech-data-provider)[bjerke/laravel-bread

A boilerplate package for BREAD operations through REST API in Laravel

115.2k](/packages/bjerke-laravel-bread)[laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

161.8k](/packages/laragear-api-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
