Lara Klean is a clean and modular Laravel 12 application that demonstrates best practices with authentication, blog posts, comments, policies, services, notifications, and localization support.
- Features
- Requirements
- Installation
- Environment Setup
- Database & Seeding
- Project Structure
- Routes & Controllers
- Events & Listeners
- Services Layer
- Policies & Authorization
- Localization
- Contributing
- License
- Authentication (register, login, logout, password reset)
- Blog posts CRUD
- Comments on posts with policy-based access
- Service layer for clean business logic separation
- Event-driven notifications on post creation
- Factory & Seeder support for easy demo data
- Localization (Uzbek and English by default)
- Policies & middleware for secure authorization
- PHP 8.1+
- Composer
- MySQL/MariaDB (or another supported database)
- Node.js & npm (or Yarn)
- Laravel 10.x
Clone the repository and install dependencies:
git clone https://github.com/xteam-uz/lara-klean.git
cd lara-klean
# Install PHP dependencies
composer install
# Install JS dependencies
npm install && npm run buildCopy the example environment file and generate the application key:
cp .env.example .env
php artisan key:generateUpdate .env with your database and mail credentials:
| Key | Description |
|---|---|
APP_URL |
Base URL of the application |
DB_CONNECTION / DB_HOST / DB_DATABASE / DB_USERNAME / DB_PASSWORD |
Database settings |
MAIL_* |
Mail settings for notifications/password reset |
Run migrations and seeders:
php artisan migrate --seedThis will create users, posts, comments and other initial data using the included factories and seeders.
app/
├── Events/ # PostCreated event
├── Http/
│ ├── Controllers/ # Auth, Post, Comment controllers
│ ├── Middleware/
│ └── Requests/ # Form requests for validation
├── Listeners/ # SendPostNotification listener
├── Models/ # User, Post, Comment models
├── Notifications/ # Laravel notifications
├── Policies/ # PostPolicy, CommentPolicy
└── Services/ # AuthService, PostService, CommentService
database/
├── factories/ # Model factories
├── migrations/ # Migrations
└── seeders/ # Database seeders
resources/
├── lang/ # Localization files (uz, en)
├── views/ # Blade templates
└── js & css # Frontend assets
routes/
├── web.php # Web routes
└── api.php # API routes (if any)The application provides web routes for:
-
Auth – login, registration, logout
-
Posts – index, create, store, edit, update, destroy
-
Comments – store, delete, update
Controllers handle these routes using dedicated service classes for the business logic.
The project uses Laravel’s event/listener system:
-
PostCreatedevent is fired after a new post is created. -
SendPostNotificationlistener sends notifications to users.
This approach keeps controllers thin and easier to test.
Policies under app/Policies manage access control:
-
PostPolicycontrols who can create/edit/delete posts. -
CommentPolicycontrols who can add/edit/delete comments.
Apply policies in controllers or via middleware for fine-grained permissions.
The app supports multiple languages. Localization files are located in:
resources/lang/en/
resources/lang/uz/
resources/lang/ru/Use the __() helper in Blade templates and controllers to render translated strings.
Contributions are welcome:
-
Fork the repository.
-
Create a feature branch:
git checkout -b feature/your-feature. -
Commit your changes and push:
git push origin feature/your-feature. -
Create a Pull Request.
This project is open-source and available under the MIT License