|
| 1 | +Vue 2 and Laravel Best Practices and Guidelines |
| 2 | + |
| 3 | +Vue 2 Rules |
| 4 | + |
| 5 | +You are an expert in TypeScript, Node.js, NuxtJS, Vue 2, Shadcn Vue, Radix Vue, VueUse, and Tailwind CSS. |
| 6 | + |
| 7 | +Code Style and Structure |
| 8 | + • Write concise, technical TypeScript code with accurate examples. |
| 9 | + • Use Vue 2’s Options API for component definitions; prioritize composition patterns using plugins like vue-composition-api where necessary. |
| 10 | + • Prefer iteration and modularization over duplication. |
| 11 | + • Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError). |
| 12 | + • Structure files: exported component, helpers, static content, and types. |
| 13 | + |
| 14 | +Naming Conventions |
| 15 | + • Use lowercase with dashes for directories (e.g., components/auth-wizard). |
| 16 | + • Use PascalCase for component names (e.g., AuthWizard.vue). |
| 17 | + • Use camelCase for composables and helpers (e.g., useAuthState.ts). |
| 18 | + |
| 19 | +TypeScript Usage |
| 20 | + • Use TypeScript for all code; prefer types over interfaces. |
| 21 | + • Avoid enums; use const objects instead. |
| 22 | + • Use Vue 2 with TypeScript leveraging class-style components or vue-property-decorator. |
| 23 | + |
| 24 | +Syntax and Formatting |
| 25 | + • Use arrow functions for methods and computed properties. |
| 26 | + • Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements. |
| 27 | + • Use template syntax for declarative rendering. |
| 28 | + |
| 29 | +UI and Styling |
| 30 | + • Use Shadcn Vue, Radix Vue, and Tailwind for components and styling. |
| 31 | + • Implement responsive design with Tailwind CSS using a mobile-first approach. |
| 32 | + |
| 33 | +Performance Optimization |
| 34 | + • Leverage Nuxt 2’s built-in performance optimizations. |
| 35 | + • Use dynamic imports and lazy loading for routes and components. |
| 36 | + • Optimize images: use WebP format, include size data, and implement lazy loading. |
| 37 | + |
| 38 | +Key Conventions |
| 39 | + • Use VueUse for common composables and utilities. |
| 40 | + • Use Vuex for state management in Vue 2. |
| 41 | + • Optimize Web Vitals (LCP, CLS, FID). |
| 42 | + • Utilize Nuxt’s auto-imports feature for components and utilities. |
| 43 | + |
| 44 | +Nuxt-Specific Guidelines |
| 45 | + • Follow Nuxt 2 directory structure (e.g., pages/, components/, plugins/). |
| 46 | + • Use Nuxt’s built-in features: |
| 47 | + • File-based routing in the pages/ directory. |
| 48 | + • Plugins for global functionality. |
| 49 | + • Modules for third-party integration. |
| 50 | + • Use asyncData and fetch hooks for data fetching. |
| 51 | + • Implement SEO best practices using Nuxt’s head() method or vue-meta. |
| 52 | + |
| 53 | +Laravel Rules |
| 54 | + |
| 55 | +You are an expert in Laravel, PHP, and related web development technologies. |
| 56 | + |
| 57 | +Key Principles |
| 58 | + • Write concise, technical responses with accurate PHP examples. |
| 59 | + • Follow Laravel best practices and conventions. |
| 60 | + • Use object-oriented programming with a focus on SOLID principles. |
| 61 | + • Prefer iteration and modularization over duplication. |
| 62 | + • Use descriptive variable and method names. |
| 63 | + • Use lowercase with dashes for directories (e.g., app/Http/Controllers). |
| 64 | + • Favor dependency injection and service containers. |
| 65 | + |
| 66 | +PHP/Laravel Practices |
| 67 | + • Use PHP 8.1+ features when appropriate (e.g., typed properties, match expressions). |
| 68 | + • Follow PSR-12 coding standards. |
| 69 | + • Use strict typing: declare(strict_types=1); |
| 70 | + • Utilize Laravel’s built-in features and helpers. |
| 71 | + • Implement error handling with: |
| 72 | + • Laravel’s exception handling and logging. |
| 73 | + • Custom exceptions where necessary. |
| 74 | + • try-catch blocks for expected exceptions. |
| 75 | + • Use Laravel’s validation for form and request inputs. |
| 76 | + • Implement middleware for request filtering and modification. |
| 77 | + • Utilize Laravel’s Eloquent ORM for database operations. |
| 78 | + • Use Laravel’s query builder for complex queries. |
| 79 | + • Implement proper database migrations and seeders. |
| 80 | + |
| 81 | +Dependencies |
| 82 | + • Laravel (latest stable version). |
| 83 | + • Composer for dependency management. |
| 84 | + |
| 85 | +Best Practices |
| 86 | + 1. Use Eloquent ORM instead of raw SQL queries where feasible. |
| 87 | + 2. Implement Repository pattern for the data access layer. |
| 88 | + 3. Use Laravel’s authentication and authorization features. |
| 89 | + 4. Utilize caching for improved performance. |
| 90 | + 5. Implement job queues for long-running tasks. |
| 91 | + 6. Use Laravel’s testing tools (PHPUnit, Dusk) for unit and feature tests. |
| 92 | + 7. Implement API versioning for public APIs. |
| 93 | + 8. Use localization for multi-language support. |
| 94 | + 9. Ensure proper CSRF protection and security measures. |
| 95 | + 10. Use Laravel Mix for asset compilation. |
| 96 | + 11. Index databases for improved query performance. |
| 97 | + 12. Use pagination for data-heavy pages. |
| 98 | + |
| 99 | +Key Laravel Conventions |
| 100 | + • Follow MVC architecture. |
| 101 | + • Use Laravel’s routing for endpoints. |
| 102 | + • Implement request validation using FormRequest. |
| 103 | + • Use Blade templating for views. |
| 104 | + • Implement relationships using Eloquent. |
| 105 | + • Use built-in authentication scaffolding. |
| 106 | + • Apply API resource transformations. |
| 107 | + • Use event and listener systems for decoupled logic. |
| 108 | + • Implement database transactions for data integrity. |
| 109 | + • Use Laravel’s scheduling features for recurring tasks. |
| 110 | + |
| 111 | +PHP tests |
| 112 | + • Use PHPUnit for unit testing. |
| 113 | + • Use Laravel's testing tools (PHPUnit, Dusk) for unit and feature tests. |
| 114 | + • If the test requires a user, create a user using the factory ProcessMaker\Models\User and authenticate as them. |
| 115 | + • Use `Tests\Feature\Shared\RequestHelper` for common request setup, and use `apiCall($method, $url, $data)` for API requests. |
0 commit comments