Skip to content
1. Introduction to Yii2
- What is Yii2?
- Why Use Yii2?
2. Setting Up Yii2
- System Requirements
- Installing Yii2
- Setting Up the Database
- Connecting Yii2 to MySQL, PostgreSQL, or SQLite
- Configuring database connection in
config/db.php
3. Basic Application Structure in Yii2
- Understanding Yii2 Directory Structure
basic/
vs advanced/
application template
- Key directories (e.g.,
controllers/
, models/
, views/
, config/
)
- Configuration Files
- Configuring Yii2 in
web/index.php
- Environment configuration (dev, prod, etc.)
- Using
config/web.php
for application settings
4. Building a Simple Yii2 Application
- Creating Models
- Defining models with ActiveRecord
- Connecting models to database tables
- Model validation and rules
- Creating Controllers
- Setting up basic controllers
- Using actions to handle requests
- Passing data from controller to view
- Creating Views
- Basics of Yii2 view files (
.php
)
- Using Yii2’s
Html
and ActiveForm
helpers
- Rendering views and layouts
- Routing and URL Management
- Configuring routes in
urlManager
- URL rules and pretty URLs
5. Advanced Yii2 Concepts
- Working with Databases
- Advanced queries with
QueryBuilder
and ActiveQuery
- Database migrations in Yii2
- Handling relations (one-to-one, one-to-many, many-to-many)
- Form Handling and Validation
- Creating forms using
ActiveForm
- Server-side validation and custom validation rules
- Authentication and Authorization
- Implementing user authentication (using
User
and IdentityInterface
)
- Role-based access control (RBAC)
- Using Gii for Code Generation
- Introduction to Yii2 Gii (code generator)
- Creating CRUD operations with Gii
- Customizing generated code
6. Yii2 RESTful API Development
- Setting Up RESTful API in Yii2
- Configuring the application for REST API development
- Creating API controllers
- Handling JSON Data
- Working with JSON requests and responses
- Configuring
behaviors
for CORS and content negotiation
- CRUD Operations via API
- Implementing CRUD operations in RESTful API
- Handling input validation in API controllers
- Securing the API
- Using JWT (JSON Web Tokens) for API authentication
- Securing API routes and endpoints
7. Testing in Yii2
- Unit Testing in Yii2
- Introduction to PHPUnit and Yii2’s testing framework
- Writing tests for controllers, models, and database operations
- Functional Testing
- Simulating browser requests and testing user flows
- Mocking and Data Fixtures
- Using Yii2’s
Codeception
for end-to-end testing
- Setting up mock data and fixtures for testing
8. Deploying Yii2 Applications
- Preparing for Production
- Optimizing Yii2 application for production (e.g., caching, asset compression)
- Handling migrations in production
- Setting up error logging and monitoring
- Deploying to a Server
- Deploying Yii2 on Apache or Nginx
- Configuring PHP-FPM and optimizing server performance
- Handling Database Backups and Maintenance
- Setting up cron jobs for backups
- Using
yii migrate
for database migrations in production
9. Yii2 Extensions and Modules
- Using Yii2 Extensions
- Introduction to the Yii2 extension library
- Installing and configuring Yii2 extensions via Composer
- Creating Custom Modules
- Overview of Yii2 modules and how to create them
- Organizing code within modules for larger applications
10. Conclusion
- Recap of Key Learnings
- Summary of topics covered (basic structure, advanced concepts, API, etc.)
- Next Steps
- Recommended next tutorials or books for further learning
- Best practices for Yii2 development and community resources