SETUP.md 4.9 KB

🚀 Quick Setup Guide

Get started with SixShop Maker Bundle in minutes!

📦 Installation

Option 1: Composer Install (Recommended)

# Install as development dependency
composer require six-shop/maker-bundle --dev

# Or install globally
composer global require six-shop/maker-bundle

Option 2: Direct Clone

git clone https://github.com/sixshop/maker-bundle.git
cd maker-bundle
composer install

✅ Verify Installation

# Check if command is available
php vendor/bin/sixshop-maker --help

# List all available commands
php vendor/bin/sixshop-maker list

# Run basic tests
php tests/simple_test.php

🎯 Quick Start Examples

1. Create a New Extension

php vendor/bin/sixshop-maker create_extension

Follow the interactive prompts to:

  • Set extension path
  • Configure package name (e.g., sixshop/my-extension)
  • Set namespace (e.g., SixShop\MyExtension\)
  • Generate complete extension structure

Note: You can run php vendor/bin/sixshop-maker without arguments to see all available commands.

2. Generate Database Migration

php vendor/bin/sixshop-maker create_migration

Interactive workflow:

  • Choose extension path
  • Define table name (e.g., products)
  • Add fields step by step
  • Generate migration + model + entity + controllers

3. Quick User Table Example

# Start migration creation
php vendor/bin/sixshop-maker create_migration

# When prompted, enter:
# - Table: users
# - Fields:
#   - username (string, length: 100, not null, unique)
#   - email (string, length: 255, not null, unique)  
#   - password (string, length: 255, not null)
#   - status (integer, default: 1, not null)

📁 Generated Structure

After running the generators, you'll have:

my-extension/
├── composer.json                 # Package configuration
├── database/
│   └── migrations/              # Database migration files
├── src/
│   ├── Controller/
│   │   ├── Admin/              # Admin interface controllers
│   │   └── Api/                # REST API controllers
│   ├── Entity/                 # Business logic entities
│   └── Model/                  # ThinkPHP models
├── route/
│   ├── admin.php               # Admin routes
│   └── api.php                 # API routes
├── config.php                  # Extension configuration
└── info.php                   # Extension metadata

🔧 Common Commands

# Extension generation
php vendor/bin/sixshop-maker create_extension

# Migration generation
php vendor/bin/sixshop-maker create_migration

# Get help
php vendor/bin/sixshop-maker --help

# List commands
php vendor/bin/sixshop-maker list

# Run tests
php tests/simple_test.php

# Run comprehensive demo
php test/comprehensive_demo.php

💡 Pro Tips

1. Existing Extensions

If you have an existing composer.json, the tool will:

  • Auto-detect your configuration
  • Pre-fill forms with existing values
  • Offer to regenerate with current settings

2. Field Types

Supported database field types:

  • string (varchar with length)
  • text (long text)
  • integer / biginteger
  • decimal (with precision/scale)
  • boolean
  • json
  • timestamp / datetime / date / time

3. Generated Code Features

  • Controllers: Dependency injection with Request $request and entity parameters
  • Entities: RESTful methods (indexUser, saveUser, etc.) with proper signatures
  • Models: Modern getOptions() pattern for ThinkPHP 8.x
  • Routes: Clean Route::resource() syntax

4. Customization

Templates are located in /templates/ directory:

  • Modify templates to match your coding standards
  • Variables available: $namespace, $tableName, $entityName, etc.

🆘 Troubleshooting

Permission Issues

# Make binary executable
chmod +x vendor/bin/sixshop-maker

# Check directory permissions
ls -la vendor/bin/

Autoload Issues

# Regenerate autoload
composer dump-autoload

# Check installation
composer show six-shop/maker-bundle

Migration Path Issues

  • Ensure target directory is writable
  • Check that database/migrations directory exists
  • Verify composer.json exists in extension directory

📚 Next Steps

  1. Read the Full Documentation: See README.md for comprehensive guides
  2. Check Examples: Run php test/comprehensive_demo.php for examples
  3. Review Generated Code: Examine the templates and generated files
  4. Customize Templates: Modify templates in /templates/ to match your standards

🎉 You're Ready!

The SixShop Maker Bundle is now ready to accelerate your development workflow. Generate migrations, models, entities, and controllers in seconds instead of hours!


Need Help?

  • 📖 Full Documentation: README.md
  • 🐛 Issues: Report on GitHub
  • 💬 Support: Contact the SixShop team