Skip to main content
rule

laravel-tall-stack-best-practices-cursorrules-prom — Cursor rule

A Cursor rule for Laravel and the TALL Stack. It guides PHP, Livewire, Alpine.js, and Tailwind CSS work in application code.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/laravel-tall-stack-best-practices-cursorrules-prom.mdc
Open on GitHub

What laravel-tall-stack-best-practices-cursorrules-prom does

This rule steers Cursor toward Laravel and PHP conventions across the TALL Stack: Livewire, Alpine.js, and Tailwind CSS. It covers SOLID design, dependency injection, PSR-12, strict typing, MVC structure, Eloquent, migrations, request validation, and error handling.

For UI work, it asks for reusable Livewire components, lifecycle hooks, and built-in validation. Alpine.js handles small interactions close to the HTML, while Tailwind CSS supports responsive layouts and reusable styles. The guidance also addresses queues, caching, eager loading, pagination, CSRF protection, PHPUnit, Livewire tests, and Dusk.

The rule metadata targets **/* and sets alwaysApply: false. It is intended for projects using Laravel, Livewire, Alpine.js, Tailwind CSS, and Luvi UI; without that stack, its recommendations do not fit the project.

What it helps with

  • structure new Laravel code around MVC
  • check PHP against PSR-12 and SOLID
  • design a validated Livewire component
  • connect Alpine.js interactions with Livewire
  • prepare PHPUnit or Dusk tests

Example prompts for the agent

  • Review this controller against Laravel conventions and PSR-12.
  • Create a Livewire component with validation and lifecycle hooks.
  • Build a responsive Tailwind CSS interface with Alpine.js interactions.

How to install laravel-tall-stack-best-practices-cursorrules-prom

Manually: put the files in place

.cursor/rules/laravel-tall-stack-best-practices-cursorrules-prom.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about laravel-tall-stack-best-practices-cursorrules-prom

How do I install laravel-tall-stack-best-practices-cursorrules-prom in Cursor?

Copy the rule file to .cursor/rules/laravel-tall-stack-best-practices-cursorrules-prom.mdc.

What does laravel-tall-stack-best-practices-cursorrules-prom do?

It guides Cursor when building Laravel and TALL Stack applications. The guidance covers PHP, Livewire, Alpine.js, Tailwind CSS, databases, security, and testing.

What does this rule require?

It targets projects built with Laravel, Livewire, Alpine.js, Tailwind CSS, and Luvi UI. Composer is used for dependency management.

Source text

laravel-tall-stack-best-practices-cursorrules-prom.mdc · CC0-1.0
---
description: "Cursor rules for Laravel development with TALL Stack best practices."
globs: **/*
alwaysApply: false
---
You are an expert in the TALL stack: Laravel, Livewire, Alpine.js, and Tailwind CSS, with a strong emphasis on Laravel and PHP best practices.

Key Principles

- Write concise, technical responses with accurate PHP examples.
- Follow Laravel best practices and conventions.
- Use object-oriented programming with a focus on SOLID principles.
- Prefer iteration and modularization over duplication.
- Use descriptive variable and method names.
- Favor dependency injection and service containers.

PHP and Laravel Core

- Use PHP 8.1+ features when appropriate (e.g., typed properties, match expressions).
- Follow PSR-12 coding standards.
- Use strict typing: declare(strict_types=1);
- Utilize Laravel's built-in features and helpers when possible.
- Follow Laravel's directory structure and naming conventions.
- Use PascalCase for class-containing directories (e.g., app/Http/Controllers).
- Implement proper error handling and logging:
  - Use Laravel's exception handling and logging features.
  - Create custom exceptions when necessary.
  - Use try-catch blocks for expected exceptions.
- Use Laravel's validation features for form and request validation.
- Implement middleware for request filtering and modification.
- Utilize Laravel's Eloquent ORM for database interactions.
- Use Laravel's query builder for complex database queries.
- Implement proper database migrations and seeders.

Laravel Best Practices

- Use Eloquent ORM instead of raw SQL queries when possible.
- Implement Repository pattern for data access layer.
- Use Laravel's built-in authentication and authorization features.
- Utilize Laravel's caching mechanisms for improved performance.
- Implement job queues for long-running tasks.
- Use Laravel's built-in testing tools (PHPUnit, Dusk) for unit and feature tests.
- Implement API versioning for public APIs.
- Use Laravel's localization features for multi-language support.
- Implement proper CSRF protection and security measures.
- Use Laravel Mix for asset compilation.
- Implement proper database indexing for improved query performance.
- Use Laravel's built-in pagination features.
- Implement proper error logging and monitoring.

Livewire Implementation

- Create modular, reusable Livewire components.
- Use Livewire's lifecycle hooks effectively (e.g., mount, updated, etc.).
- Implement real-time validation using Livewire's built-in validation features.
- Optimize Livewire components for performance, avoiding unnecessary re-renders.
- Integrate Livewire components with Laravel's backend features seamlessly.

Alpine.js Usage

- Use Alpine.js directives (x-data, x-bind, x-on, etc.) for declarative JavaScript functionality.
- Implement small, focused Alpine.js components for specific UI interactions.
- Combine Alpine.js with Livewire for enhanced interactivity when necessary.
- Keep Alpine.js logic close to the HTML it manipulates, preferably inline.

Tailwind CSS Styling

- Utilize Tailwind's utility classes for responsive design.
- Implement a consistent color scheme and typography using Tailwind's configuration.
- Use Tailwind's @apply directive in CSS files for reusable component styles.
- Optimize for production by purging unused CSS classes.

Performance Optimization

- Implement lazy loading for Livewire components when appropriate.
- Use Laravel's caching mechanisms for frequently accessed data.
- Minimize database queries by eager loading relationships.
- Implement pagination for large data sets.
- Use Laravel's built-in scheduling features for recurring tasks.

Security Best Practices

- Always validate and sanitize user input.
- Use Laravel's CSRF protection for all forms.
- Implement proper authentication and authorization using Laravel's built-in features.
- Use Laravel's prepared statements to prevent SQL injection.
- Implement proper database transactions for data integrity.

Testing

- Write unit tests for Laravel controllers and models.
- Implement feature tests for Livewire components using Laravel's testing tools.
- Use Laravel Dusk for end-to-end testing when necessary.

Key Conventions

1. Follow Laravel's MVC architecture.
2. Use Laravel's routing system for defining application endpoints.
3. Implement proper request validation using Form Requests.
4. Use Laravel's Blade templating engine for views, integrating with Livewire and Alpine.js.
5. Implement proper database relationships using Eloquent.
6. Use Laravel's built-in authentication scaffolding.
7. Implement proper API resource transformations.
8. Use Laravel's event and listener system for decoupled code.

Dependencies

- Laravel (latest stable version)
- Livewire
- Alpine.js
- Tailwind CSS
- Luvi UI component library
- Composer for dependency management

When providing code examples or explanations, always consider the integration of all four technologies in the TALL stack. Emphasize the synergy between these technologies and how they work together to create efficient, reactive, and visually appealing web applications, while adhering to Laravel and PHP best practices.

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for Backend and APIs →

From the same set210

momen-cursurrules-prompt-file Instructs Cursor on building custom frontends on top of Momen.app headless BaaS. Guides GraphQL queries, Actionflow tasks, and WebSocket subscriptions. ★ 41,024repo stars medusa A Cursor rule that keeps Medusa code on one pattern: workflows, data models, services and admin customizations. ★ 41,024repo stars manifest-yaml-cursorrules-prompt-file A Cursor rule that tells the agent how to scaffold a small Manifest backend: project setup, the manifest/backend.yml file and limits on entities. ★ 41,024repo stars linux-nvidia-cuda-python-cursorrules-prompt-file Sets Cursor agent guidelines for the Hugging Face model quantization pipeline on Linux servers with Nvidia CUDA or AMD ROCm GPUs. ★ 41,024repo stars laravel-php-83-cursorrules-prompt-file A Cursor rule that walks the agent through building Laravel packages: plan, directory layout, naming standards, tests and docs. ★ 41,024repo stars landing-page-image-quality-cursorrules-prompt-file Stops Cursor from injecting placeholder image URLs into user-facing pages, requiring real project assets, fixed dimensions, and valid alt attributes. ★ 41,024repo stars kubestellar-console Rules for KubeStellar Console development across its React/TypeScript frontend and Go backend. Useful for dashboard cards and multi-cluster queries. ★ 41,024repo stars kubernetes-mkdocs-documentation-cursorrules-prompt A Cursor rule that turns the agent into a technical writer for Kubernetes and cloud native docs built with Markdown and MkDocs. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor