承接 aw-studio/laravel-strapi 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aw-studio/laravel-strapi

Composer 安装命令:

composer require aw-studio/laravel-strapi

包简介

README 文档

README

A Laravel package to integrate with Strapi CMS, providing an elegant way to interact with Strapi models and components.

Installation

You can install the package via Composer:

composer require aw-studio/laravel-strapi

Configuration

After installation, publish the configuration file:

php artisan vendor:publish --tag=laravel-strapi-config

Then, add the following environment variables to your .env file:

STRAPI_BASE_URL=https://your-strapi-url.com
STRAPI_CACHE_ACTIVE=true # Set to false to disable caching
STRAPI_CACHE_TTL=3600 # Cache duration in seconds

Strapi Models

You can create Strapi models using the following command:

php artisan make:strapi-model {name}

This will create a SingleType or CollectionType model in App\Strapi\Models.

Querying Strapi Models

You can query models fluently:

$post = Post::locale('de')
            ->where('Slug', $slug)
            ->populate([
                'Image' => [
                    'populate' => '*',
                ],
            ])
            ->first();

Strapi Components

You can create Strapi components with the following command:

php artisan make:strapi-component {name?}

Each component represents a Strapi component (e.g., from dynamic zones). It consists of:

  • A class file: App\Strapi\Components\<CollectionName>\ComponentName.php
  • A corresponding Blade view file

Registering Components

Components must be registered in the config/laravel-strapi.php configuration file.

Populating Components

You can populate all components of a Content dynamic zone like this:

$post = Post::locale('de')
            ->where('Slug', $slug)
            ->populateContent()
            ->first();

Rendering Components in Blade

You can render dynamic zone components in Blade templates using the x-dynamiczone component:

<x-dynamiczone :items="$page->Content" />

License

This package is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 100
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-11