A simple, full-featured CRUD (Create, Read, Update, Delete) application built with Laravel 11, Blade templating engine, and SQLite database. This project demonstrates fundamental web development patterns including MVC architecture, RESTful routing, form validation, and database operations.
This application provides a complete item management system where users can:
- Create new items with name, description, and optional price
- Read and browse all items in a paginated table view
- Update existing item information
- Delete items with a confirmation dialog
- View detailed information about individual items
The application follows Laravel's conventions and best practices, making it an excellent starting point for learning Laravel development or as a foundation for more complex applications.
- ✅ Full CRUD operations (Create, Read, Update, Delete)
- ✅ Form validation with error handling
- ✅ Pagination for large datasets
- ✅ Responsive Bootstrap 5 UI
- ✅ SQLite database (no external database server required)
- ✅ RESTful routing
- ✅ MVC architecture
- ✅ Success/error flash messages
- ✅ Confirmation dialogs for destructive actions
Before you begin, ensure you have the following installed on your system:
- PHP 8.2 or higher - Check with
php -v - Composer - PHP dependency manager (Download Composer)
- SQLite - Usually included with PHP installations
If you have the project files, navigate to the project directory:
cd laravelcrudappInstall all PHP dependencies using Composer:
composer installThis will install Laravel framework and all required packages.
The project comes pre-configured with SQLite. The database file (database/database.sqlite) should already exist. If it doesn't, create it:
touch database/database.sqliteOr on Windows:
type nul > database\database.sqliteThe database migrations have already been run, but if you need to reset or run them again:
php artisan migrateThis will create the items table in your SQLite database.
Start Laravel's built-in development server:
php artisan serveThe server will start on http://localhost:8000 by default.
Open your web browser and navigate to:
http://localhost:8000
You will be automatically redirected to /items which displays the items list.
If you encounter any issues, you may need to generate an application key:
php artisan key:generateWhy Laravel 11?
- Modern PHP Framework: Laravel is one of the most popular and well-documented PHP frameworks
- Built-in Features: Provides authentication, validation, routing, and ORM out of the box
- Developer Experience: Excellent tooling with Artisan CLI, clear error messages, and comprehensive documentation
- Community Support: Large community and extensive package ecosystem
- MVC Architecture: Enforces clean separation of concerns
Why Blade instead of a frontend framework?
- Server-Side Rendering: Simple and efficient for CRUD applications
- No Build Step: No need for npm, webpack, or build processes
- Laravel Integration: Native integration with Laravel's features (routes, models, etc.)
- Learning Curve: Easier for developers familiar with PHP/HTML
- Performance: Direct rendering without JavaScript overhead for simple applications
Why SQLite instead of MySQL/PostgreSQL?
- Zero Configuration: No need to set up a separate database server
- Portability: Database is a single file (
database.sqlite) - Perfect for Development: Ideal for small to medium applications
- Easy Deployment: No database server dependencies
- Learning: Simplifies the setup process for beginners
Trade-off: SQLite is not ideal for high-concurrency production applications, but perfect for this CRUD demonstration.
Why use Resource Controllers?
- Convention over Configuration: Laravel's standard approach
- Clean Code: All CRUD methods in one controller
- RESTful Routes: Follows REST principles (
GET /items,POST /items, etc.) - Maintainability: Easy to understand and modify
- Scalability: Easy to add more resources following the same pattern
Why Bootstrap instead of Tailwind CSS or custom CSS?
- Rapid Development: Pre-built components (tables, forms, buttons, alerts)
- Consistency: Ensures a professional look without custom CSS
- Responsive: Built-in responsive design
- CDN Delivery: Easy to include via CDN
- Familiar: Most developers are familiar with Bootstrap
Note: Laravel 11 ships with Tailwind CSS, but Bootstrap was chosen for faster development and simpler styling.
Why server-side validation?
- Security: Never trust user input - validate on the server
- Data Integrity: Ensures database constraints are met
- User Feedback: Clear error messages guide users
- Laravel's Validation: Powerful, expressive validation rules
Why paginate results?
- Performance: Prevents loading thousands of records at once
- User Experience: Easier to navigate large datasets
- Memory Efficiency: Reduces server memory usage
- Laravel Built-in: Simple pagination with
paginate()method
Why use session flash messages?
- User Feedback: Immediate confirmation of actions
- Non-intrusive: Doesn't require page reloads or JavaScript
- Laravel Sessions: Built-in session management
- UX Best Practice: Standard pattern for web applications
Why use Route Model Binding?
- Clean URLs:
/items/{item}instead of/items/{id} - Automatic Resolution: Laravel automatically finds the model
- 404 Handling: Automatic 404 if item doesn't exist
- Type Safety: Type-hinted models in controller methods
- Less Code: No need to manually query the database
Why follow MVC pattern?
- Separation of Concerns: Models (data), Views (presentation), Controllers (logic)
- Maintainability: Easy to locate and modify code
- Testability: Each component can be tested independently
- Scalability: Easy to add features without breaking existing code
- Team Collaboration: Multiple developers can work on different components
laravelcrudapp/
├── app/
│ ├── Http/
│ │ └── Controllers/
│ │ └── ItemController.php # Handles all CRUD operations
│ └── Models/
│ └── Item.php # Item model with fillable fields
├── database/
│ ├── migrations/
│ │ └── *_create_items_table.php # Database schema
│ └── database.sqlite # SQLite database file
├── resources/
│ └── views/
│ ├── layouts/
│ │ └── app.blade.php # Main layout template
│ └── items/
│ ├── index.blade.php # List all items
│ ├── create.blade.php # Create form
│ ├── edit.blade.php # Edit form
│ └── show.blade.php # View single item
├── routes/
│ └── web.php # Application routes
└── README.md # This file
The items table structure:
| Column | Type | Constraints |
|---|---|---|
| id | bigint | Primary Key, Auto Increment |
| name | varchar(255) | Required |
| description | text | Nullable |
| price | decimal(10,2) | Nullable |
| created_at | timestamp | Auto-managed |
| updated_at | timestamp | Auto-managed |
| Method | URI | Action | Description |
|---|---|---|---|
| GET | / |
redirect | Redirects to items index |
| GET | /items |
index | List all items (paginated) |
| GET | /items/create |
create | Show create form |
| POST | /items |
store | Save new item |
| GET | /items/{item} |
show | Display single item |
| GET | /items/{item}/edit |
edit | Show edit form |
| PUT | /items/{item} |
update | Update existing item |
| DELETE | /items/{item} |
destroy | Delete item |
- Laravel 11 - PHP web framework
- Blade - Laravel's templating engine
- SQLite - Lightweight database
- Bootstrap 5 - CSS framework for styling
- PHP 8.2+ - Programming language
Potential improvements for this application:
- User authentication and authorization
- Image uploads for items
- Search and filtering functionality
- Sorting by columns
- Export to CSV/Excel
- API endpoints for mobile apps
- Unit and feature tests
- Docker containerization
- Category/tag system
- Soft deletes (trash/recycle bin)
This project is open-source and available for educational purposes.
Feel free to fork this project and submit pull requests for any improvements!