Yii 2 For Beginners
Yii 2 For Beginners
A step by step guide to learning Yii 2 for beginners
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!
Bundles that include this book
Table of Contents
-
Chapter One: Introduction
- Introduction
- Features
- What Makes The Yii 2 Framework Special?
- Upsides
- Downsides
- Why I chose Yii 2
- Other Options
- Yii 2 Arrives
- Gii
- DB-First Approach
- MySql
- Improved Workflow
- Minimum PHP Skills
- Tools You Will Need
- Errata
- Contact Bill Keck
- Summary
-
Chapter Two: Yii 2 Advanced Template Installation
- Quick Setup of Yii2 Advanced Template
- Step 1 - Create Folder
- Step 2 - Apache Conf
- Step 3 - Local Host
- Step 4 - Restart Apache
- Step 5 - Create Project in IDE
- Step 6 - Find Command Line Path
- Step 7 - Composer Self-Update
- Step 8 - Install Yii 2
- Step 9 - Check For Yii 2 Folder
- Step 10 - Run Php Init
- Step 11 - Create The Database
- Step 12 - Set DB Connection
- Step 13 - Run Migration
- Step 14 - Create Git Repository
- Step 15 - Confirm App Is Working
- Trouble-Shooting
- Summary
-
Chapter Three: Welcome to the MVC
- MVC Pattern
- Index.php
- The Application Instance
- Routing
- Using Gii
- Bootstrap
- Debugger
- Summary
-
Chapter Four: Modifying the User Model
- Role and Status
- The User Model
- Properties of the Model
- Constants
- Identity Interface
- Behaviors
- Rules
- Identity Methods
- Boilerplate Methods
- Other Models Accessing User
- SignupForm Model
- Summary
-
Chapter Five: Creating New Models with Gii
- Creating Tables
- Role Table
- Status Table
- User Type Table
- Gender Table
- Profile Table
- Synchronize
- Configuring Gii
- Making Models with Gii
- Create Role Model
- Add Records To Role Table
- Add Relationship To Role
- Update User Model with Role
- Create Status Model
- Update User Model with getStatus
- Add Records to Status Table
- Create UserType Model
- Update User Model with UserType
- Add Records to user_type Table
- Create Gender Model
- Add Records to gender Table
- Create Profile Model
- The Complete Profile Model
- Update User Model with Profile
- Finish Up User Model
- The Complete User Model
- Summary
-
Chapter Six: Helpers
- Value Helpers
- Permission Helpers
- Record Helpers
- Summary
-
Chapter Seven: Site Controller
- Behaviors
- Actions
- Index Action
- Login Action
- Login Form Model
- Logout Action
- Contact Action
- Contact Form Model
- Captcha
- Contact View Form
- About Action
- Signup Action
- Signup Form Model
- ResetPasswordForm Model
- Backend Site Controller
- Beginning Access Control
- loginAdmin Method
- Summary
-
Chapter Eight: Profile Crud
- CRUD
- Profile Controller
- Profile Search
- _search
- _form
- Index
- View
- Create
- Update
- Modifying Profile Controller & Views
- Modifying the Profile Controller
- Index Action
- View Action
- Create Action
- Update Action
- Delete Action
- FindModel Action
- Modifying the Profile Views
- View.php
- Gender
- Form Partial
- Create
- Update
- Site Layout
- Profile Link
- DatePicker
- Summary
-
Chapter Nine: Upgrade and Access Control
- Upgrade Controller
- Upgrade View
- Require Upgrade To
- Access Control
- Passing A Variable From the Controller
- Summary
-
Chapter Ten: Homepage Social Widgets
- Implementing Homepage Social Widgets
- Index
- Facebook Widget
- Facebook App Setup
- Facebook Configuration
- Extensions
- HTML Helper
- Collapse Widget
- Modal Widget
- Alert Widget
- Font-Awesome
- Asset Bundle
- Add Font-Awesome to Layout
- Summary
-
Chapter Eleven: Backend Creation
- Main.php
- Updating Backend Views
- backend/views/profile/_form.php
- backend/views/profile/view.php
- backend/views/user/view.php
- backend/views/user/_form
- Deeper Changes to Backend
- backend/views/user/index.php
- backend/views/profile/index.php
- backend/views/profile/_search.php
- backend/views/user/_search.php
- User Search
- Admin UI
- Controller Behaviors
- Match Callback
- Summary
- About The Author
-
Chapter 12: Bonus Material
- AutoResponder
- Dropdown Navigation
- FAQ
- Test Controller
- Components
- Creating a Custom Widget
- CDN
- Summary
-
Chapter 13: Bonus Material Pretty Urls & Slugs
- Pretty URLs
- Apache Vhost
- Restart Apache
- Slugs
- Sluggable Behavior
- Slug Column
- Drop old Faqs and Create New Ones
- Add Url Manager Rules
- Modify View Action on FaqController
- Modify Create and Update Actions on Backend Controller
- Change Gridview Action Column URL
- Summary
-
Chapter 14: Bonus Material Social Login and Register
- Yii2 - AuthClient
- Install yii2authclient via Composer
- Configuration
- Twitter Issue
- Provider Applications
- Facebook App
- Github App
- Google App
- LinkedIn App
- Index View Change
- Login View Change
- Signup View Change
- Social Sync Dropdown
- Auth Data Structure
- Auth Model
- Site Controller Actions Method
- OnAuth Success
- Updated OnAuth Success
- Login and Registration Scenarios
- Refactor For Maintainability and Extensibility
- New Class Properties
- New Helper Methods
- OnAuthSuccess Method
- Action Login
- Action Signup
- Pages Controller
- Summary
-
Chapter 15: Template Migration guide.
- User
- Role
- UserType:
- Status
- ValueHelpers
- PermissionHelpers
- RecordHelpers
- Database Changes
- Extra ValueHelpers
- LoginForm Model
- PasswordResetRequestForm
- UserSearch
- ProfileSearch
- Main.php
- Index.php
- Troubleshooting
- Summary
-
Chapter 16: Images and File Uploads
- The Uploads Folder
- Marketing Image Table
- Marketing Image SQL
- Marketing Image Model
- Modify MarketingImage Model
- PHP FileInfo
- Modify MarketingImage Search Model
- Modify Index View
- Modify View
- Modify Update View
- Modify _search Partial
- Modify _form Partial
- Modifying the Controller
- The Create Action
- The Update Action
- The Delete Action
- Image Thumbnails with Imagine
- Install Yii 2 Imagine Extension
- Create Thumbnail Folder
- Alter Marketing Image Table
- Modify MarketingImage Model
- Scenarios
- Modify MarketingImageSearch
- Modifying Marketing Image Controller
- Modify Create Action
- Modify Update Action
- Modify Delete Action
- Modify Views
- Modify View
- Modify Update
- Modify _form
- Modify _search
- Modify Index
- URL Manager
- Carousel Widget
- CarouselWidget.php
- carousel.php
- Pages Index
- Carousel Settings
- carousel_settings table
- CarouselSettings Model
- CarouselSettingsSearch Model
- CarouselSettingsController
- CarouselSettings _form View
- CarouselSettings view.php View
- CarouselSettings index.php View
- CarouselSettings _search View
- PagesController
- Pages Index View
- CarouselWidget
- carousel.php
- Main
- Summary
-
Chapter 17: Bonus Material Ratings Widget
- FaqRatings Model
- $model->getErrors()
- Overwrite Save Method on Model
- Faq Controller
- Frontend Faq view.php
- _rating-form.php
- FaqRatings Controller
- Faq Model
- Faq Index View
- Faq View
- Signup Form Model
- signup.php
- terms.php
- termsoverflow.css
- Frontend AppAsset.php
- Improving The Carousel
- Modify marketing_imageTable
- Modify MarketingImage Model
- MarketingImage Views
- Marketing Image view.php
- Update View
- MarketingImage Controller
- Create Action
- Update Action
- Delete Action
- Entire File
- CarouselSettings Model Rules
- CarouselWidget
- validateSize Method
- Entire CarouselWidget File
- carousel.php
- Summary
-
Chapter 18: Bonus Material Returning Calculated Values in Gridview
- Sorting A Calculated Value In Gridview
- Donate To Kartik
- Average Rating For Gridview
- Times Rated
- Summary
Authors have earned$10,095,386writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
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), EPUB (for phones and tablets) and MOBI (for 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
Top Books
C++20
Rainer GrimmC++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
The book is almost daily updated. These incremental updates ease my interaction with the proofreaders.
A Guide to Artificial Intelligence in Healthcare
Dr. Bertalan MeskoCan we stay human in the age of A.I.? To go even further, can we grow in humanity, can we shape a more humane, more equitable and sustainable healthcare? This e-book aims to prepare healthcare and medical professionals for the era of human-machine collaboration. Read our guide to understanding, anticipating and controlling artificial intelligence.
Atomic Kotlin
Bruce Eckel and Svetlana IsakovaFor both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
C++ Best Practices
Jason TurnerLevel up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
Introducing EventStorming
Alberto BrandoliniThe deepest tutorial and explanation about EventStorming, straight from the inventor.
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Everyday Rails - RSpecによるRailsテスト入門
Junichi Ito (伊藤淳一), AKIMOTO Toshiharu, 魚振江, and Aaron SumnerRSpecを使ってRailsアプリケーションに信頼性の高いテストを書く実践的なアドバイスを提供します。詳細で丁寧な説明は本書のオリジナルコンテンツです。また、説明には実際に動かせるサンプルアプリケーションも使用します。本書は2017年版にアップデートされ、RSpec 3.6やRails 5.1といった新しい環境に対応しています!さあ、自信をもってテストできるようになりましょう!
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
The Hundred-Page Machine Learning Book
Andriy BurkovEverything you really need to know in Machine Learning in a hundred pages.
Continuous Delivery Pipelines
Dave FarleyThis practical handbook provides a step-by-step guide for you to get the best continuous delivery pipeline for your software.
Top Bundles
- #1
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
All the Books of The Medical Futurist
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy, digital health investments and how technology giants such as Amazon... - #3
PowerShell
3 Books
Buy every PowerShell book from Adam Bertram at a 20% discount! - #4
Cisco CCNA 200-301 Complet
4 Books
Ce lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301. - #5
Software Architecture and Beautiful APIs
2 Books
There is no better way to learn how to design good APIs than to look at many existing examples, complementing the Software Architecture theory on API design. - #6
Linux Administration Complet
4 Books
Ce lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité... - #7
Learn Git, Bash, and Terraform the Hard Way
3 Books
Learn Git, Bash and Terraform using the Hard Way method.These technologies are essential tools in the DevOps armoury. These books walk you through their features and subtleties in a simple, gradual way that reinforces learning rather than baffling you with theory. - #8
9 Books-Bundle: Shut Up and Code!
9 Books
"Shut up and code." Laughter in the audience. The hacker had just plugged in his notebook and started sharing his screen to present his super-smart Python script. "Shut up and code" The letters written in a white literal coding font on black background was the hackers' home screen background mantra. At the time, I was a first-year computer... - #9
Mastering Containers
2 Books
Docker and Kubernetes are taking the world by storm! These books will get you up-to-speed fast! Docker Deep Dive is over 400 pages long, and covers all objectives on the Docker Certified Associate exam.The Kubernetes Book includes everything you need to get up and running with Kubernetes! - #10
CCDE Practical Studies (All labs)
3 Books
CCDE lab