Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See @CLAUDE.md
114 changes: 114 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Development Commands

### Docker Environment (Recommended)
```bash
# Initialize Docker environment and install dependencies
make init

# Initialize database and run migrations
make database-init

# Load fixtures (optional)
make load-fixtures

# Start/stop containers
make up
make down

# Access containers
make php-shell
make node-shell
```

### Traditional Development
```bash
# Frontend setup
(cd vendor/sylius/test-application && yarn install)
(cd vendor/sylius/test-application && yarn build)
vendor/bin/console assets:install

# Database setup
vendor/bin/console doctrine:database:create
vendor/bin/console doctrine:migrations:migrate -n
vendor/bin/console sylius:fixtures:load -n

# Start server
symfony server:start -d
```

### Testing
```bash
# PHPUnit tests
vendor/bin/phpunit
make phpunit # Docker

# Behat tests (non-JS)
vendor/bin/behat --strict --tags="~@javascript&&~@mink:chromedriver"
make behat # Docker

# Behat tests (JS scenarios)
# Requires Chrome headless and symfony server
APP_ENV=test symfony server:start --port=8080 --daemon
vendor/bin/behat --strict --tags="@javascript,@mink:chromedriver"
```

### Code Quality
```bash
# PHPStan analysis
vendor/bin/phpstan analyse -c phpstan.neon -l max src/
make phpstan # Docker

# Coding standards
vendor/bin/ecs check
make ecs # Docker
```

### Composer Scripts
```bash
# Database reset with fixtures
composer run database-reset

# Frontend rebuild
composer run frontend-clear

# Complete test app initialization
composer run test-app-init
```

## Architecture

This is a **Sylius Plugin Skeleton** - a template for creating Sylius e-commerce plugins. It provides a complete development environment with both traditional and Docker setups.

### Core Structure
- **Main Plugin Class**: `src/AcmeSyliusExamplePlugin.php` - Entry point using `SyliusPluginTrait`
- **DI Extension**: `src/DependencyInjection/AcmeSyliusExampleExtension.php` - Handles service loading and Doctrine migrations
- **Services**: `config/services.xml` - Service definitions with XML configuration
- **Routes**: `config/routes/` - Separate admin and shop route definitions
- **Templates**: `templates/` - Twig templates for admin and shop with Twig hooks support

### Key Features
- **Test Application**: Uses `sylius/test-application` for plugin testing in isolation
- **Asset Management**: Webpack Encore for frontend asset compilation
- **Database**: Doctrine migrations with proper namespace handling
- **Testing**: Full Behat + PHPUnit setup with browser testing support
- **Code Quality**: PHPStan, ECS (Easy Coding Standard), and Rector integration

### Development Environment
- **Docker**: Complete containerized environment with PHP, Node.js, and database
- **Traditional**: Local Symfony server with manual dependency management
- **Frontend**: Yarn-based asset pipeline through test application

### Testing Strategy
- **Unit/Integration**: PHPUnit for isolated component testing
- **Functional**: Behat for feature testing with browser automation
- **Static Analysis**: PHPStan for type checking and code quality
- **Standards**: ECS for coding standard enforcement

### Database Configuration
Database credentials should be configured in:
- `tests/Application/.env` (for development)
- `tests/Application/.env.test` (for testing)
147 changes: 147 additions & 0 deletions CLEANUP_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Removing Customizations from Sylius Plugin Guide for AI

This guide helps AI assistants remove example customizations from a Sylius Plugin Skeleton.

## Step 1: Search for Example Code

First, identify all files related to the customization (e.g., "greeting", "example", "demo"):

```bash
# Search for class names, function names, and references
grep -r "greeting" . --include="*.php" --include="*.js" --include="*.yml" --include="*.yaml" --include="*.xml" --include="*.twig"
grep -r "example" . --include="*.php" --include="*.js" --include="*.yml" --include="*.yaml" --include="*.xml" --include="*.twig"
```

## Step 2: Identify Files to Delete

Common locations for example files in Sylius plugins:

### Controllers
- `src/Controller/*ExampleController.php`
- `src/Controller/*DemoController.php`

### Frontend Assets
- `assets/shop/js/*.js` (example scripts)
- `assets/admin/js/*.js` (example scripts)

### Templates
- `templates/shop/[feature_name]/` (entire directories)
- `templates/admin/[feature_name]/` (entire directories)

### Tests
- `features/*_example.feature`
- `features/*_demo.feature`
- `tests/Behat/Context/*/ExampleContext.php`
- `tests/Behat/Page/*/Example*Page.php`

## Step 3: Identify Configuration to Clean

### Service Definitions
**File:** `config/services.xml`
- Remove service definitions for example controllers
- Look for: `<service id="...Controller\ExampleController" />`

### Routing
**Files:** `config/routes/shop.yaml`, `config/routes/admin.yaml`
- Remove entire route definitions for example features
- Look for routes with "example", "demo", or feature-specific names

### Twig Hooks
**Files:** `config/twig_hooks/shop.yaml`, `config/twig_hooks/admin.yaml`
- Remove hook definitions for example features
- Remove entire `config/twig_hooks/` directory if it only contains empty placeholder files
- Look for: `'app_shop.example.*'` or similar patterns

### Asset Imports
**Files:** `assets/shop/entrypoint.js`, `assets/admin/entrypoint.js`
- Remove imports of deleted JavaScript files
- Look for: `import './js/example';`

### Main Configuration
**File:** `config/config.yaml`
- Remove imports that reference deleted directories
- Look for: `- { resource: "twig_hooks/**/*.yaml" }` or similar broken imports
- Clean up any example-specific configuration

### Behat Suites
**File:** `tests/Behat/Resources/suites.yml`
- Remove suite definitions for example features
- Look for suites with example/demo names

## Step 4: Cleanup Checklist

Use this checklist to ensure complete cleanup:

1. **Delete files:**
- [ ] Controllers (`src/Controller/`)
- [ ] JavaScript files (`assets/*/js/`)
- [ ] Template directories (`templates/*/`)
- [ ] Feature files (`features/`)
- [ ] Behat test files (`tests/Behat/`)

2. **Clean configurations:**
- [ ] Remove service definitions from `config/services.xml`
- [ ] Remove routes from `config/routes/*.yaml`
- [ ] Remove twig hooks from `config/twig_hooks/*.yaml` or remove entire directory if empty
- [ ] Remove broken imports from `config/config.yaml`
- [ ] Remove JavaScript imports from `assets/*/entrypoint.js`
- [ ] Remove test suites from `tests/Behat/Resources/suites.yml`

3. **Additional cleanup:**
- [ ] Remove empty directories (e.g., `config/twig_hooks/` if only contains placeholder files)
- [ ] Check for unused dependencies in `composer.json`
- [ ] Check for unused npm packages in `package.json`
- [ ] Clear cache after cleanup

## Step 5: Verification

After cleanup, verify the plugin still works:

```bash
# Clear cache
rm -rf var/cache/*

# Check for broken imports in config files
grep -r "twig_hooks\|greeting\|example" config/ --include="*.yaml" --include="*.yml" || echo "No broken imports found"

# Check for syntax errors
vendor/bin/phpstan analyse -c phpstan.neon -l max src/

# Run coding standards check
vendor/bin/ecs check

# If using Docker
make ecs
make phpstan
```

## Common Patterns to Remove

### Example 1: Greeting Feature
- Controller: `GreetingController.php`
- Routes: `acme_sylius_example_static_welcome`, `acme_sylius_example_dynamic_welcome`
- Templates: `templates/shop/greeting/`
- JavaScript: `assets/shop/js/greetings.js`
- Tests: `*greeting*.feature`, `*Welcome*.php`

### Example 2: Demo Feature
- Look for files/classes containing "Demo", "Example", "Sample"
- Check for placeholder routes like `/demo`, `/example`
- Remove test data generators if not needed

## Important Notes

1. **Always analyze before deleting** - Make sure the code is truly example/demo code
2. **Check dependencies** - Ensure no other code depends on what you're removing
3. **Keep plugin structure** - Don't delete essential plugin files like the main plugin class
4. **Preserve configuration structure** - Keep empty configuration files if they're required by Sylius

## Safe Files to Keep

Never delete these essential files:
- `src/[PluginName]Plugin.php` (main plugin class)
- `src/DependencyInjection/` (directory structure)
- `config/services.xml` (keep file, just clean content)
- `config/*_routing.yaml` (keep files, just clean content)
- `composer.json`, `package.json`
- Essential directories: `src/`, `config/`, `templates/`, `tests/`
86 changes: 86 additions & 0 deletions COMPATIBILITY_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Compatibility With Sylius Guide for AI

This guide explains how to configure the Plugin to work with different versions of Sylius (1.14, 2.0, and 2.1).

## Supported Sylius Versions

- Sylius 1.14.x
- Sylius 2.0.x
- Sylius 2.1.x

## Key Compatibility Changes

### 1. Composer Configuration

To support multiple Sylius versions, update your `composer.json`:

```json
{
"require": {
"php": "^8.1",
"sylius/sylius": "^1.14 || ^2.0 || ^2.1"
},
"require-dev": {
"sylius/sylius-rector": "^1.14 || ^2.0",
"sylius/test-application": "^1.14.0@alpha || ^2.0.0@alpha || ^2.1.0@alpha",
"symfony/webpack-encore-bundle": "^1.15 || ^2.2"
},
"prefer-stable": true
}
```

**Important notes:**
- PHP 8.1 is the minimum requirement for cross-version compatibility
- Use `prefer-stable: true` to prefer stable packages when available
- Use version constraints with `||` operator to support multiple versions

#### For Sylius 2.0 and 2.1:

In Sylius 2.0+, these properties are provided by the parent class, so you can use them directly without initialization.

### 2. Testing Across Versions

To test your plugin with different Sylius versions:

1. **Update composer.json for specific version:**
```bash
# For Sylius 1.14
composer require "sylius/sylius:~1.14.0"

# For Sylius 2.0
composer require "sylius/sylius:~2.0.0"

# For Sylius 2.1
composer require "sylius/sylius:~2.1.0"
```

2. **Run tests:**
```bash
vendor/bin/phpunit
vendor/bin/phpspec run
vendor/bin/behat
```

## Best Practices

1. **Use Conservative Constraints**: When supporting multiple versions, use the most conservative approach that works across all versions.

2. **Test Thoroughly**: Always test your plugin with each supported Sylius version before release.

3. **Document Version-Specific Features**: If certain features only work with specific Sylius versions, document this clearly.

4. **Use CI/CD**: Set up GitHub Actions or other CI tools to test against all supported versions automatically.

## Troubleshooting

### Common Issues

1. **Service not found errors**: Check that service IDs haven't changed between versions.

2. **Namespace conflicts**: Use fully qualified class names when there's ambiguity.

3. **Dependency conflicts**: Use `composer why-not` to debug version constraint issues.

## Conclusion

By following this guide, your plugin should work seamlessly across Sylius 1.14, 2.0, and 2.1. The key is understanding the differences between versions and implementing conditional logic where necessary while maintaining a clean, maintainable codebase.
Loading
Loading