drupalninja/drupalx-decoupled 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

drupalninja/drupalx-decoupled

Composer 安装命令:

composer create-project drupalninja/drupalx-decoupled

包简介

Enterprise template for decoupled Drupal projects.

README 文档

README

CI License: GPL v2

A modern, enterprise-ready Drupal 11 decoupled project template featuring GraphQL API, Next.js frontend, and a comprehensive component library. Built with recipes, Storybook, and TypeScript for rapid development and deployment.

Features

Backend (Drupal 11)

  • GraphQL API - Fully configured GraphQL server with compose fragments
  • Recipe System - Modular configuration using Drupal recipes
  • Content Types - Pre-configured Article, Page, and Landing page types
  • Paragraph Components - 15+ reusable paragraph components (Hero, Cards, Carousel, etc.)
  • Media Management - Image, SVG, and video media types with responsive image styles
  • Preview System - Live preview with decoupled iframe integration
  • OAuth Authentication - Simple OAuth for secure API access

Frontend (Next.js 15)

  • TypeScript - Full TypeScript support with type safety
  • Tailwind CSS - Utility-first CSS framework with custom components
  • Radix UI - Accessible component primitives
  • Storybook - Component library documentation and testing
  • Cypress - End-to-end testing framework
  • GraphQL Client - Fully typed GraphQL queries and mutations
  • Component Library - 25+ pre-built React components
  • Responsive Design - Mobile-first responsive layouts

Development Environment

  • DDEV - Containerized development environment
  • Multiple Recipes - Demo, Government, University, and Nonprofit content
  • Hot Reload - Development server with live reload
  • Code Quality - ESLint, Prettier, and TypeScript checking

Requirements

  • PHP 8.3 or higher
  • Node.js 20+ (managed via nvm)
  • Composer 2.x
  • DDEV (recommended) or Docker
  • Git

Installation

1. Create your project

composer create-project drupalninja/drupalx-decoupled:11.x-dev drupalx-decoupled-starter --no-interaction
cd drupalx-decoupled-starter

2. Set up permissions

chmod -R 755 web/sites/default/files/

3. Configure DDEV

ddev config

4. Install Drupal with recipes

ddev install

This command will:

  • Start DDEV containers
  • Install Composer dependencies
  • Install Drupal with minimal profile
  • Apply DrupalX GraphQL and Core recipes
  • Configure OAuth consumer keys
  • Generate admin login link

5. Set up Next.js frontend

In a new terminal tab:

cd nextjs
nvm install  # Installs Node.js 20+
npm install
npm run dev  # Starts development server on port 8080

6. Access your sites

Development Workflow

Available Recipes

The project includes several content recipes you can apply:

# Demo content (default)
ddev drush recipe ../recipes/drupalx-demo

# Government site content
ddev drush recipe ../recipes/drupalx-gov

# University site content  
ddev drush recipe ../recipes/drupalx-university

# Nonprofit site content
ddev drush recipe ../recipes/drupalx-nonprofit

Common Commands

Backend (Drupal):

# Start/stop DDEV
ddev start
ddev stop

# Database operations
ddev drush sql:dump > backup.sql
ddev drush sql:drop -y && ddev drush sql:cli < backup.sql

# Clear cache
ddev drush cr

# Generate login link
ddev drush uli

# Export/import config
ddev drush config:export
ddev drush config:import

Frontend (Next.js):

cd nextjs

# Development server
npm run dev

# Build production
npm run build
npm run start

# Linting
npm run lint

# Component development
npm run storybook

# Testing
npm run cypress

Component Development

Storybook - Component library and documentation:

cd nextjs
npm run storybook
# Access at http://localhost:6006

Cypress Testing - End-to-end testing:

cd nextjs
npm run cypress

Frontend Architecture

Technology Stack

  • Next.js 15 - React framework with App Router
  • TypeScript - Type safety and better developer experience
  • Tailwind CSS - Utility-first CSS framework
  • Radix UI - Headless UI components
  • Shadcn/ui - Modern component library
  • URQL - GraphQL client with caching
  • Embla Carousel - Accessible carousel component
  • Lucide React - Beautiful icon library

Component Library

The project includes 25+ pre-built components:

  • Layout: Header, Footer, Container
  • Content: Hero, Text, RichText, Media
  • Navigation: MainMenu, Pager
  • Interactive: Accordion, Carousel, Modal, Tabs
  • Forms: Newsletter, Button, Input
  • Data Display: Card, Gallery, Stats, Pricing
  • Feedback: Alert, Badge, Tooltip

GraphQL Integration

  • Fully typed GraphQL queries
  • Fragment composition for reusable query parts
  • Automatic TypeScript generation
  • Optimized caching strategies

Troubleshooting

Common Issues

DDEV won't start:

ddev poweroff
ddev start

Port conflicts:

# Check what's using port 8080
lsof -i :8080
# Kill the process or change Next.js port
npm run dev -- --port 3000

GraphQL schema issues:

# Rebuild GraphQL schema
ddev drush cr
ddev drush graphql:rebuild

Next.js build errors:

cd nextjs
# Clear Next.js cache
rm -rf .next
npm run build

Permission issues:

# Fix file permissions
sudo chown -R $USER:$USER .
chmod -R 755 web/sites/default/files/

Node.js version issues:

# Ensure you're using Node 20+
nvm use 20
node --version

Support

For issues specific to this template:

For general support:

drupalninja/drupalx-decoupled 适用场景与选型建议

drupalninja/drupalx-decoupled 是一款 基于 TypeScript 开发的 Composer 扩展包,目前已累计 241 次下载、GitHub Stars 达 23, 最近一次更新时间为 2024 年 07 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 drupalninja/drupalx-decoupled 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 drupalninja/drupalx-decoupled 我们能提供哪些服务?
定制开发 / 二次开发

基于 drupalninja/drupalx-decoupled 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 23
  • Watchers: 4
  • Forks: 4
  • 开发语言: TypeScript

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2024-07-18