Leanpub Header

Skip to main content

Yii 2 For Beginners

A step by step guide to learning Yii 2 for beginners

Yii 2 for beginners will take you step by step through setup and installation, and then on to coding in the most exciting PHP framework available today. The book focuses on creating a reusable template that can serve as the basis for your projects.

Minimum price

$24.95

$39.95

You pay

$39.95

Author earns

$31.96
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
695
Pages
111,886Words
About

About

About the Book

Yii 2 for beginners will take you step by step through setup and installation, and then on to coding in the most  exciting PHP framework available today.  The book focuses on creating a reusable template that can serve as the basis for your projects, including the following features:

  • Setup and install
  • A Working user model
  • User registration and login
  • User Profile
  • Forgot password recovery
  • Frontend and backend separation
  • Helper classes
  • Access control
  • Free/Paid content control
  • RBAC with backend UI
  • JUI DatePicker
  • Facebook Social Widgets
  • Font-Awesome Implementation
  • Image Upload and Management
  • Multiple Social Auth Providers
  • Custom Data-driven Carousel Widget
  • Facebook Login & Registration with one click

This book is perfect for beginning PHP programmers who are ready to move onto framework development.  The Yii 2 PHP framework is highly scalable and extensible, and loaded with features.  We introduce you to this wonderful framework and explain in detail everything you need to know to get up and running.  See our great reviews at GoodReads.com.  You will love Yii 2!

Share this book

Categories

Author

About the Author

Bill Keck

Bill Keck is the author of 100 Patterns For Success, Laravel 5.4 For Beginners and other books on Laravel and PHP Frameworks.  He actively maintains the PHP Frameworks Blog and the Laravel Tips blog.

Translations

Translations

Languages

Contents

Table of Contents

Chapter One: Introduction

  1. Introduction
  2. Features
  3. What Makes The Yii 2 Framework Special?
  4. Upsides
  5. Downsides
  6. Why I chose Yii 2
  7. Other Options
  8. Yii 2 Arrives
  9. Gii
  10. DB-First Approach
  11. MySql
  12. Improved Workflow
  13. Minimum PHP Skills
  14. Tools You Will Need
  15. Tip
  16. Errata
  17. Formatting Tip
  18. Contact Bill Keck
  19. Summary

Chapter Two: Yii 2 Advanced Template Installation

  1. Quick Setup of Yii2 Advanced Template
  2. Step 1 - Create Folder
  3. Step 2 - Apache Conf
  4. Step 3 - Local Host
  5. Step 4 - Restart Apache
  6. Step 5 - Create Project in IDE
  7. Step 6 - Find Command Line Path
  8. Step 7 - Composer Self-Update
  9. Tip
  10. Step 8 - Install Yii 2
  11. Tip
  12. Step 9 - Check For Yii 2 Folder
  13. Step 10 - Run Php Init
  14. Step 11 - Create The Database
  15. Step 12 - Set DB Connection
  16. Step 13 - Run Migration
  17. Step 14 - Create Git Repository
  18. Step 15 - Confirm App Is Working
  19. Trouble-Shooting
  20. Summary

Chapter Three: Welcome to the MVC

  1. MVC Pattern
  2. Index.php
  3. The Application Instance
  4. Routing
  5. Using Gii
  6. Bootstrap
  7. Debugger
  8. Summary

Chapter Four: Modifying the User Model

  1. Role and Status
  2. Tip
  3. The User Model
  4. Tip
  5. Properties of the Model
  6. Constants
  7. Identity Interface
  8. Behaviors
  9. Rules
  10. Identity Methods
  11. Boilerplate Methods
  12. Other Models Accessing User
  13. SignupForm Model
  14. tip
  15. Summary

Chapter Five: Creating New Models with Gii

  1. Creating Tables
  2. Tip
  3. Role Table
  4. Status Table
  5. User Type Table
  6. Gender Table
  7. Profile Table
  8. Synchronize
  9. Configuring Gii
  10. Making Models with Gii
  11. Create Role Model
  12. Add Records To Role Table
  13. Add Relationship To Role
  14. Update User Model with Role
  15. Create Status Model
  16. Update User Model with getStatus
  17. Add Records to Status Table
  18. Create UserType Model
  19. Update User Model with UserType
  20. Add Records to user_type Table
  21. Create Gender Model
  22. Add Records to gender Table
  23. Create Profile Model
  24. Reminder
  25. The Complete Profile Model
  26. Update User Model with Profile
  27. Finish Up User Model
  28. The Complete User Model
  29. Summary

Chapter Six: Helpers

  1. Value Helpers
  2. Permission Helpers
  3. Record Helpers
  4. Summary

Chapter Seven: Site Controller

  1. Behaviors
  2. Actions
  3. Index Action
  4. Login Action
  5. Login Form Model
  6. Logout Action
  7. Contact Action
  8. Contact Form Model
  9. Captcha
  10. Contact View Form
  11. Tip
  12. Tip
  13. About Action
  14. Signup Action
  15. Signup Form Model
  16. ResetPasswordForm Model
  17. Backend Site Controller
  18. Beginning Access Control
  19. loginAdmin Method
  20. Summary

Chapter Eight: Profile Crud

  1. CRUD
  2. Profile Controller
  3. Profile Search
  4. _search
  5. _form
  6. Index
  7. View
  8. Create
  9. Update
  10. Modifying Profile Controller & Views
  11. Tip
  12. Modifying the Profile Controller
  13. Index Action
  14. View Action
  15. Create Action
  16. Update Action
  17. Delete Action
  18. FindModel Action
  19. Modifying the Profile Views
  20. View.php
  21. Gender
  22. Form Partial
  23. Create
  24. Update
  25. Site Layout
  26. Profile Link
  27. DatePicker
  28. Summary

Chapter Nine: Upgrade and Access Control

  1. Upgrade Controller
  2. Upgrade View
  3. Require Upgrade To
  4. Tip
  5. Access Control
  6. Passing A Variable From the Controller
  7. Summary

Chapter Ten: Homepage Social Widgets

  1. Implementing Homepage Social Widgets
  2. Index
  3. Tip
  4. Facebook Widget
  5. Facebook App Setup
  6. Facebook Configuration
  7. Extensions
  8. HTML Helper
  9. Collapse Widget
  10. Modal Widget
  11. Alert Widget
  12. Font-Awesome
  13. Asset Bundle
  14. Add Font-Awesome to Layout
  15. Summary

Chapter Eleven: Backend Creation

  1. Main.php
  2. Updating Backend Views
  3. backend/views/profile/_form.php
  4. backend/views/profile/view.php
  5. backend/views/user/view.php
  6. backend/views/user/_form
  7. Deeper Changes to Backend
  8. backend/views/user/index.php
  9. backend/views/profile/index.php
  10. backend/views/profile/_search.php
  11. backend/views/user/_search.php
  12. User Search
  13. Admin UI
  14. Controller Behaviors
  15. Match Callback
  16. Summary
  17. About The Author

Chapter 12: Bonus Material

  1. AutoResponder
  2. Dropdown Navigation
  3. FAQ
  4. Test Controller
  5. Components
  6. Creating a Custom Widget
  7. CDN
  8. Summary

Chapter 13: Bonus Material Pretty Urls & Slugs

  1. Pretty URLs
  2. Apache Vhost
  3. Restart Apache
  4. .htaccess
  5. Slugs
  6. Sluggable Behavior
  7. Slug Column
  8. Drop old Faqs and Create New Ones
  9. Add Url Manager Rules
  10. Modify View Action on FaqController
  11. Modify Create and Update Actions on Backend Controller
  12. Change Gridview Action Column URL
  13. Summary

Chapter 14: Bonus Material Social Login and Register

  1. Yii2 - AuthClient
  2. Install yii2authclient via Composer
  3. Configuration
  4. Twitter Issue
  5. Provider Applications
  6. Facebook App
  7. Github App
  8. Google App
  9. LinkedIn App
  10. Index View Change
  11. Login View Change
  12. Signup View Change
  13. Social Sync Dropdown
  14. Auth Data Structure
  15. Auth Model
  16. Site Controller Actions Method
  17. OnAuth Success
  18. Updated OnAuth Success
  19. Login and Registration Scenarios
  20. Refactor For Maintainability and Extensibility
  21. New Class Properties
  22. New Helper Methods
  23. OnAuthSuccess Method
  24. Action Login
  25. Action Signup
  26. Pages Controller
  27. Summary

Chapter 15: Template Migration guide.

  1. User
  2. Role
  3. UserType:
  4. Status
  5. ValueHelpers
  6. PermissionHelpers
  7. RecordHelpers
  8. Database Changes
  9. Extra ValueHelpers
  10. LoginForm Model
  11. PasswordResetRequestForm
  12. UserSearch
  13. ProfileSearch
  14. Main.php
  15. Index.php
  16. Troubleshooting
  17. Summary

Chapter 16: Images and File Uploads

  1. The Uploads Folder
  2. Marketing Image Table
  3. Marketing Image SQL
  4. Marketing Image Model
  5. Modify MarketingImage Model
  6. PHP FileInfo
  7. Modify MarketingImage Search Model
  8. Modify Index View
  9. Modify View
  10. Modify Update View
  11. Modify _search Partial
  12. Modify _form Partial
  13. Modifying the Controller
  14. The Create Action
  15. The Update Action
  16. The Delete Action
  17. Image Thumbnails with Imagine
  18. Install Yii 2 Imagine Extension
  19. Create Thumbnail Folder
  20. Alter Marketing Image Table
  21. Modify MarketingImage Model
  22. Scenarios
  23. Modify MarketingImageSearch
  24. Modifying Marketing Image Controller
  25. Modify Create Action
  26. Modify Update Action
  27. Modify Delete Action
  28. Modify Views
  29. Modify View
  30. Modify Update
  31. Modify _form
  32. Modify _search
  33. Modify Index
  34. URL Manager
  35. Carousel Widget
  36. CarouselWidget.php
  37. carousel.php
  38. Pages Index
  39. Carousel Settings
  40. carousel_settings table
  41. CarouselSettings Model
  42. CarouselSettingsSearch Model
  43. CarouselSettingsController
  44. CarouselSettings _form View
  45. CarouselSettings view.php View
  46. CarouselSettings index.php View
  47. CarouselSettings _search View
  48. PagesController
  49. Pages Index View
  50. CarouselWidget
  51. carousel.php
  52. Main
  53. Summary

Chapter 17: Bonus Material Ratings Widget

  1. FaqRatings Model
  2. $model->getErrors()
  3. Overwrite Save Method on Model
  4. Faq Controller
  5. Frontend Faq view.php
  6. _rating-form.php
  7. FaqRatings Controller
  8. Faq Model
  9. Faq Index View
  10. Faq View
  11. Signup Form Model
  12. signup.php
  13. terms.php
  14. termsoverflow.css
  15. Frontend AppAsset.php
  16. Improving The Carousel
  17. Modify marketing_imageTable
  18. Modify MarketingImage Model
  19. MarketingImage Views
  20. Marketing Image view.php
  21. Update View
  22. MarketingImage Controller
  23. Create Action
  24. Update Action
  25. Delete Action
  26. Entire File
  27. CarouselSettings Model Rules
  28. CarouselWidget
  29. validateSize Method
  30. Entire CarouselWidget File
  31. carousel.php
  32. Summary

Chapter 18: Bonus Material Returning Calculated Values in Gridview

  1. Sorting A Calculated Value In Gridview
  2. Donate To Kartik
  3. Average Rating For Gridview
  4. Times Rated
  5. Summary

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub