Take this

Software Development / Web Development

Learning Yii 2

Take your first steps into web application development with Yii 2 and get rapidly acquainted with the new and improved PHP framework


Yii is the premium PHP framework for developing web applications. It provides components to simplify every aspect of web development, including authentication, authorization, and automated testing, offering a comprehensive ORM called ActiveRecord, and the option to perform performance tuning. We can use all of these features out-of-the-box, or even customize them based on our project requirements.

The more applications we develop for the web, the more aware we become that we’re spending time on the same repetitive tasks. Learning Yii 2 demonstrates how it is entirely possible to write quality applications fast. This course will show you how to create a basic but fully functional dating site for monsters. All this with minimal effort on your part, because the Yii framework simplifies the overhead work.

We’ll start by installing Yii's basic application template via Vagrant. Before you know it, you’ll have a fully-functional web application that is ready to be customized. You’ll learn to generate Models, Views, and Controllers, and debug and test them with the Debug Toolbar and Codeception. As we continue, you’ll learn to modify that generated code to create a registration page, a profile page, and a listing page, as well as a search interface using ActiveQuery and TypeAhead. We’ll also use ACF and RBAC to boost the security of our website.

By the end, you’ll be comfortable using Yii 2 to develop your own personal and professional web applications.

Full details


  • Introducing Yii 2.0
    The Course Overview
    This video will offer the overview of the course.
    Creating a Development Environment Using Vagrant and PuPHPet
    It takes a lot of time to set up a development environment for an application. Learn how to quickly create and configure a development environment on our local PC, so we can begin programming our application. • Download and install VirtualBox • Download and install Vagrant • Download a PuPHPet configuration and start our server
    Installing the Basic Application Template
    Learn how to easily install the Yii 2 basic application template, which is the starting point for any Yii-based project. • Connect to our development server and install the application template • Configure our web server and development machine • Verify application template installation
    An Overview of the Yii 2 Directory Structure
    Understand where Yii stores various files within the basic application template. • Walk through each folder and describe its contents • Explain basic namespace conventions and how they map to project folders
    Configuring and Extending Yii 2 Components
    Introduce application components, describe how to change their default configuration, and then explain how to extend a core component to add functionality. • Explain the database connection and application parameters files • Modify urlManager components to allow application to use pretty URLs • Demonstrate how to override the core View component to filter out an unwanted word
  • Introducing Yii's Development Tools
    Configuring and Using Gii
    Learn how to configure Gii, which is a tool that quickly generates code templates in order to cut development time dramatically. • Explain what Gii does • Configure Gii’s security settings • Load Gii and click through a few screens
    Generating and Working with Models
    Learn to generate models with Yii, and then describe Yii’s model features. • Generate a model based on a sample database table • Introduce the Yii ORM: ActiveRecord • Describe the basics of creating, reading, updating, and deleting models
    Generating the Controllers
    Learn to generate controllers with Gii, and then describe Yii’s controller features. • Generate CRUD pages for our Monstertest database table • Explain how URLs determine which controller is loaded • Examine several controller action methods to learn typical controller responsibilities
    Generating the Views
    The presentation logic in an application should be isolated, and contain a minimal amount of PHP. We’ll learn how to generate views using Gii as well as how to use them. • Look at the Monstertest list page and explore various features of the view component • Learn to register meta tags • Learn to register JavaScript
    Configuring and Using the Debug Module
    Learn how to configure and use Yii's built-in debugging module. • Configure the Debug module to allow access from your development computer • Describe some of the Debug module's features • Explain how to create a custom panel
  • Testing with Yii and Codeception
    Introducing the Codeception Testing Framework
    Automated testing can be difficult to configure and implement. Yii ships with an integrated version of the Codeception testing framework in order to simplify the process of writing automated tests. • Explain what Codeception is, and how it helps to run unit, functional, and acceptance tests • Learn how to configure Codeception • Learn how to create and populate a test database
    Unit Testing
    Learn how to use Codeception to write and execute unit tests for our application. • Understand what unit tests are, what they should test, and what Codeception offers. • Learn how to load fixtures to provide a known state for tests • Learn how to write and run the first unit test
    Functional Testing
    Learn how to use Codeception to write and execute functional tests for our application. • Understand what functional tests are, what they should test, and what Codeception offers. • Learn how to load fixtures to provide a known state for tests • Learn how to write and run the first functional test
    Installing Selenium and Acceptance Testing
    Learn how to use Codeception to write and execute acceptance tests for our application. • Learn how to download and install Selenium • Learn how to configure the local PC and Vagrant box to run acceptance tests • Learn how to write and run the first acceptance test
  • Creating and Managing Users
    It’s Alive – Creating Our First Monster
    Every application needs a means to authenticate users. We’ll explore the auto-generated User model that comes with the Yii 2 basic application template. • Take a look at the basic application template User model • Learn about the IdentityInterface • Explore the LoginForm model
    Warding Off Evil
    The default user is very limited and requires changes to the code to add users or edit their data. We’ll create a better user using the database and then learn how to easily hash their password. • Load data into a database table and generate a new model using Gii • Log in and log out one of our new users • Hash passwords with the Yii security component
    Registering Our Ghouls, Goblins, and Vampires
    The application doesn’t have a way to easily create new users. We will create a registration page to allow new users to create accounts. • Learn how to create a URL rule to direct "register" to "create" • Learn more advanced validation rules • Learn how to work with ActiveForm
    Access Control Filter – The Silver Bullet
    Guests (users who have not logged in) should not be able to update and delete profiles. Use Access Control Filter to restrict access to these pages. • Learn how to configure ACF • Create a rule to allow access to authenticated users • Create a custom deny callback to change behavior when blocking access
    Implementing Role Based Access Control
    ACF only allows the ability to block access to controller actions. For finer-grained over access to application features, use the AuthManager component to implement Role Based Access Control (RBAC). • Enable the AuthManager component and generate permissions and roles • Disable deletion for non-admin users • Only allow users to update their own page
  • Adding Some Style
    All about Yii 2 Layouts
    Some visual aspects of a web application are common to multiple pages, and having to update those aspects in each page would be very tedious. We’ll learn how to use Yii layouts to manage our common UI elements. • Explore the default layout and learn how it works • Edit the menu to reflect the needs of our application • Learn how to create and apply multiple layouts to a single application
    Managing JavaScript and CSS
    Applications often have many frontend assets that have dependencies as well as potential conflicts. The Yii 2 AssetBundle class helps keep Javascript and CSS organized. • Look at the provided AppAsset to learn how Asset Bundles work • Install the jQuery Lightbox plugin using Composer • Create a new Asset Bundle for Lightbox
    Introducing the Yii 2 HTMLHelper
    Dynamic web applications often mix too much HTML and PHP in order to generate HTML content. The HtmlHelper attempts to solve this by providing PHP methods to generate clean HTML. • Use the "encode" method and HTML Purifier to safely escape application output • Generate a Bootstrap link with the HtmlHelper class • Learn how to generate forms using HtmlHelper
    Monster Profiling – The Scary Details
    The current profile (view) page is not very appealing, so we'll use some of the skills we've learned in the previous videos to spice it up. • Create a custom URL with a parameter • Add a profile photo and Lightbox • Customize the details section and hide the edit buttons for other users
  • Finding Love
    Finding the Right Ghoul-mate Using ActiveQuery
    A dating site needs a method for users to search for their match. Yii’s ActiveQuery component makes generating complex SQL queries very easy. • Demonstrate how to do partial versus strict matches • Create a search feature by age range • Search by skin tone
    Enhancing the Search UI
    Sometimes, simply presenting a user with a text field in a search UI leaves them feeling overwhelmed. We can use the TypeAhead widget to provide meaningful suggestions for search terms. • Install the TypeAhead widget using Composer • Output the basic widget • Add a little style using options and pluginOptions
    Displaying and Sorting Results
    We've been using the GridView widget to display results, but it is really more suitable in an admin panel than a customer-facing page. We’ll learn how to use the ListView widget to improve the appearance of our listing page. • Replace the GridView widget with ListView • Create a partial view to display each item • Learn to sort and paginate results
    Adding New Themes
    Sometimes, an application needs multiple themes in order to display data in different ways to different users or under different circumstances. We’ll learn how to use themes to address this issue. • Create some new theme files • Apply the new theme globally • Apply the new theme only to logged-in, female users
  • Beyond the Basics
    Sending E-mails Using Swiftmailer
    Applications frequently need to send e-mails. We’ll learn how to use the built-in Swiftmailer component in order to easily send HTML e-mails. • Configure the component • Learn how to format our message • Learn how to send the message
    Working with Images
    Our application requires users to manually copy images to the photo directory, which they wouldn’t have access to in production. We’ll learn how to upload files through a form with Yii, and then learn how to manipulate them using the Imagine extension. • Set up our form to handle file uploads • Learn how to validate and save files • Install the Imagine extension and create a thumbnail
    Tracking Database Changes Using Migrations
    Managing database changes with multiple .sql files is slow and prone to error. Yii’s migration class helps manage database changes. • Create a migration template using the migrate command • Create and apply our migration • Revert our migration
    Love, the International Language (i18N)
    Not everyone speaks the same language. So, we’ll learn how to use the i18n component of Yii in order to translate our application into other languages. • Configure the application to use a different language • Use the "t" method to translate individual blocks of text and then generate message files • Use the message command line tool to generate our translation files • Translate an entire view


  • Bootstrap
  • MVC
  • Yii

Similar Courses

More Courses by this Instructor