mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 05:31:10 -05:00
- Added rides index view with search and filter options. - Created rides show view to display ride details. - Implemented API routes for rides. - Developed authentication routes for user registration, login, and email verification. - Created tests for authentication, email verification, password reset, and user profile management. - Added feature tests for rides and operators, including creation, updating, deletion, and searching. - Implemented soft deletes and caching for rides and operators. - Enhanced manufacturer and operator model tests for various functionalities.
7.7 KiB
7.7 KiB
ThrillWiki Custom Artisan Commands
Created: June 13, 2025
Purpose: Documentation for custom Laravel artisan commands that accelerate ThrillWiki development
🚀 Overview
Custom artisan commands implement the development acceleration strategy by providing automated code generation with built-in ThrillWiki patterns, optimization, and best practices.
📋 Available Commands
1. make:thrillwiki-livewire
Purpose: Generate optimized Livewire components with ThrillWiki patterns and performance optimizations.
Location: app/Console/Commands/MakeThrillWikiLivewire.php
Command Signature
php artisan make:thrillwiki-livewire {name} [options]
Options
--reusable: Generate a reusable component with optimization traits--with-tests: Generate test files for the component--cached: Add caching optimization to the component--paginated: Add pagination support to the component--force: Overwrite existing files
Examples
# Basic component
php artisan make:thrillwiki-livewire RideCard
# Reusable component with caching and tests
php artisan make:thrillwiki-livewire SearchableList --reusable --cached --with-tests
# Paginated component with tests
php artisan make:thrillwiki-livewire RideResults --paginated --with-tests
# Force overwrite existing component
php artisan make:thrillwiki-livewire UserProfile --reusable --force
Generated Files
- Component Class:
app/Livewire/{ComponentName}.php - View Template:
resources/views/livewire/{component-name}.blade.php - Test File (if
--with-tests):tests/Feature/Livewire/{ComponentName}Test.php
🎯 Features & Optimizations
Built-in ThrillWiki Patterns
1. Component Structure
- Consistent namespace and class structure
- ThrillWiki-specific naming conventions
- Optimized import statements
- Performance-focused lifecycle hooks
2. View Templates
- Basic Template: Simple, clean structure for standard components
- Reusable Template: Advanced template with:
- Loading states with Alpine.js
- Responsive design with Tailwind
- Dark mode support
- Interactive elements with proper wire: directives
3. Test Generation
- Complete test suite with ThrillWiki patterns
- Component rendering tests
- Mount success tests
- Pattern compliance verification tests
- Ready-to-extend test structure
Performance Optimizations
1. Caching Integration
// Auto-generated caching methods
protected function getCacheKey(string $suffix = ''): string
protected function remember(string $key, $callback, int $ttl = 3600)
protected function invalidateCache(string $key = null): void
2. Pagination Support
- Automatic WithPagination trait inclusion
- Tailwind CSS theme configuration
- Query string parameter handling
3. Reusable Component Features
- Optimization traits for performance
- Modular design principles
- Component state management
- Event handling patterns
🛠 Implementation Details
Command Architecture
1. File Generation Strategy
- Stub-based Templates: Flexible template system with placeholder replacement
- Dynamic Content: Options-based content generation
- Directory Management: Automatic directory creation and validation
- Conflict Resolution: Force overwrite option with user confirmation
2. Template System
// Component stub with dynamic sections
{IMPORTS} // Dynamic import statements
{CLASS_NAME} // Component class name
{TRAITS} // Optional trait inclusions
{PROPERTIES} // Component properties
{METHODS} // Optional methods (caching, etc.)
{VIEW_NAME} // Kebab-case view name
3. Option Processing
- Boolean Options: Enable/disable features (
--cached,--reusable) - Conditional Logic: Generate different code based on options
- Validation: Ensure valid component names and file paths
- User Feedback: Comprehensive success messages and next steps
Integration with Development Workflow
1. Acceleration Benefits
- 50% Faster Component Creation: Pre-built templates with optimization
- Consistent Patterns: All components follow ThrillWiki standards
- Built-in Testing: Automatic test generation reduces QA time
- Performance by Default: Optimization patterns built-in
2. Developer Experience
- Rich CLI Output: Colored, formatted command output
- Helpful Guidance: Next steps and usage instructions
- Error Handling: Clear error messages and suggestions
- File Overview: Summary of generated files and features
📊 Usage Patterns
Recommended Workflows
1. Standard Component Development
# Step 1: Generate component with tests
php artisan make:thrillwiki-livewire MyComponent --with-tests
# Step 2: Customize component logic
# Edit app/Livewire/MyComponent.php
# Step 3: Update view template
# Edit resources/views/livewire/my-component.blade.php
# Step 4: Run tests
php artisan test --filter MyComponentTest
2. Reusable Component Development
# Generate optimized reusable component
php artisan make:thrillwiki-livewire SharedComponent --reusable --cached --with-tests
# Result: Component with caching, optimization traits, and comprehensive tests
3. List/Table Components
# Generate paginated list component
php artisan make:thrillwiki-livewire ItemList --paginated --cached --with-tests
# Result: Component with pagination, caching, and optimized queries
Integration with Existing Codebase
- Namespace Compliance: Generated components follow app namespace structure
- View Integration: Templates ready for inclusion in existing layouts
- Test Integration: Tests integrate with existing test suite
- Pattern Consistency: Matches existing ThrillWiki component patterns
🔄 Future Enhancements
Implemented Commands
- ✅ make:thrillwiki-livewire - Livewire component generation with optimization patterns
- ✅ make:thrillwiki-crud - Complete CRUD generation with controller, views, and routes
- ✅ make:thrillwiki-model - Model generation with ThrillWiki traits and relationships
Planned Command Extensions
- make:thrillwiki-api - API resource generation with optimization
- make:thrillwiki-service - Service layer generation with caching patterns
- make:thrillwiki-seeder - Data seeder generation with realistic test data
Advanced Features
- Interactive Mode: Guided component generation with prompts
- Template Customization: User-defined template overrides
- Batch Generation: Generate multiple related components
- Integration Hooks: Pre/post generation hooks for custom logic
📝 Best Practices
Component Generation Guidelines
- Use Descriptive Names: Clear, purpose-driven component names
- Choose Appropriate Options: Select options that match component purpose
- Review Generated Code: Customize templates to fit specific needs
- Test Early: Run generated tests to ensure proper setup
- Document Usage: Document component purpose and reuse patterns
Performance Considerations
- Use Caching Wisely: Enable caching for data-heavy components
- Pagination for Lists: Always use pagination for large datasets
- Optimize Queries: Leverage eager loading in generated components
- Monitor Performance: Track component rendering times
Development Workflow Integration
- Version Control: Commit generated files with descriptive messages
- Code Review: Review generated code for project-specific customization needs
- Testing: Extend generated tests with component-specific scenarios
- Documentation: Update component documentation in memory bank