Yii is an optimal, high-performance PHP framework for developing Web 2.0 applications. It provides fast, secure, and professional features to create robust projects; however, this rapid development requires the ability to organize common tasks collectively to build a complete application. Being extremely performance-optimized, Yii is the perfect choice for projects of any size. It comes packaged with tools to help test and debug your application and has clear and comprehensive documentation.
This video course is a collection of Yii2 videos. Each video is represented as a full and independent item, showcasing solutions from real web applications. So you can easily reproduce them in your environment and learn Yii2 rapidly and painlessly…
In this video, you will get started by configuring your Yii2 application. After that, we will focus on how to make our extension as efficient as possible. Then we will cover some best practices for developing an application that will run smoothly until you have very high loads. Moving ahead, we will provide various tips, which are especially useful in application deployment and when developing an application in a team. Later, we will introduce the best technologies for testing and we will see how to write simple tests and avoid regression errors in our application.
Finally, we conclude this course by discussing review logging, analyzing the exception stack trace, and implementing our own error handler.
About the Authors
Andrew Bogdanovis a seasoned web developer from Yekaterinburg, Russia with more than six years of experience in industrial development. Since 2010, he has been interested in the Yii and MVC frameworks. He has taken part in projects written in Yii, such as a work aggregator for a UK company, high-load projects, real-estate projects, and the development of private projects for the government.
He has worked on various CMS and frameworks using PHP and MySQL, including Yii, Kohana, Symphony, Joomla, WordPress, CakePHP, and so on. Also, he is adroit at integrating third-party APIs such as Payment gateways (PayPal, Facebook, Twitter, and LinkedIn). He is very good in slicing and frontend, so he can provide full information about the Yii framework.
He is also well-versed in PHP/MYSQL, Yii 1.x.x, Yii 2.x.x, Ajax, Jquery, MVC frameworks, Python, LAMP, HTML/CSS, Mercurial, Git, AngularJS, and adaptive markup.
In his free time, he likes to visit and talk with new people and discuss web development problems. He is currently working with professionals.
Dmitry Eliseev has been a web developer since 2008 and specializes in server-side programming on the PHP and PHP frameworks.
Dmitry is interested in developmental best practices, software architectures, object-oriented programming, and other approaches.
He is an author and a presenter of practical courses about the principles and best practices of object-oriented programming and the use of version control systems. Also, he is an author of webinars, the Yii2 Framework, and common developmental subjects. He practices teaching and counseling by development on frameworks and using the principles of software design and improvements in common code quality. This is his first book.
Alexander Makarov is an experienced engineer from Russia and has been a Yii framework core team member since 2010. Before joining the Yii core team, he participated in the growth of the CodeIgniter community in Russia. In 2009, he finished the Russian translation of the framework documentation and created the Russian community website. In 2012, he released the Russian version of the book along with Russian community members. In the same year, he was a technical reviewer for three more books:
In his free time, Alexander speaks at conferences, and enjoys movies, music, traveling, photography, and languages. He currently resides in Voronezh, Russia with his beloved wife and daughter.
The aim of this video is to explore ElasticSearch engine adapter, which is an ActiveRecord-like wrapper for ElasticSearch full text search engine integration into the Yii2 framework.
The aim of this video is to learn about Gii code generator that provides a web-based code generator called Gii for Yii 2 applications.
Pax is a widget that integrates the PJax jQuery plugin. All content that is wrapped by this widget will be reloaded by AJAX without refreshing the current page.
The aim of this video is to learn about Redis database driver, which allows you to use Redis key-value storage in any project on the Yii2 framework.
There are a lot of built-in framework helpers such as StringHelper in the yii\helpers namespace. These contain sets of helpful static methods for manipulating strings, files, arrays, and other subjects.
There are many similar leading products such as Google's Gmail that define nice UI patterns. One of these is soft delete. Instead of a permanent deletion with tons of confirmations, Gmail allows us to immediately mark messages as deleted and then easily undo it. The same behavior can be applied to any object such as blog posts, comments, and so on.
You may have some code that looks like it can be reused but you don't know if it's a behavior, widget, or something else, most probably it's a component.
Common actions such as deleting the AR model by the primary key or getting data for AJAX autocomplete could be moved into reusable controller actions and later attached to controllers as needed.
In Yii, you can create reusable controllers. If you are creating a lot of applications or controllers that are of the same type, moving all common code into a reusable controller will save you a lot of time.
A widget is a reusable part of a view that not only renders some data but also does it according to some logic. It can even get data from models and use its own views, so it is like a reduced reusable version of a module.
Yii has good command-line support and allows creating reusable console commands. Console commands are faster to create than web GUIs. If you need to create some kind of utility for your application that will be used by developers or administrators, console commands are the right tool.
A filter is a class that can run before/after an action is executed. It can be used to modify execution context or decorate output.
If you have created a complex application part and want to use it with some degree of customization in your next project, most probably you need to create a module.
Yii2 only offers native PHP templates. If you want to use one of the existing template engines or create your own one, you have to implement it—of course, if it's not yet implemented by the Yii community. Here we will re-implement the Smarty templates support.
Yii2 provides built-in i18n support for making multilanguage applications. In this video, we are translating the application interface to different languages.
The aim of this video is to talk about how to share your results with people and why it's important.
Native session handling in PHP is fine in most cases. The aim of this video is to speed up the session handling.
Yii supports many cache backends, but what really makes the Yii cache flexible is the dependency and dependency chaining support. There are situations when you cannot simply cache data for an hour because the information cached can be changed at any time.
If all of the best practices for deploying a Yii application are applied and you still do not have the performance you want, then most probably there are some bottlenecks with the application itself. The main principle while dealing with these bottlenecks is that you should never assume anything and always test and profile the code before trying to optimize it.
Instead of only server-side caching implementation, you can use client-side caching via specific HTTP-headers.
HHVM transforms PHP code into intermediate HipHop bytecode (HHBC) and dynamically translates PHP code into machine code, which will be optimized and natively executed.
By default, we have the Basic and Advanced Yii2 application skeletons with different directory structures. But these structures are not dogmatic, and we can customize them if required.
By default, Yii2 applications work from the web directory for your site's entry script. But shared hosting environments are often quite limited when it comes to the configuration and directory structure. You cannot change the working directory for your site.
By default, Yii2's Advanced template has console, frontend, and backend applications. However, in your specific case, you can rename the existing ones and create your own applications
In the basic application template we have separated web and console configuration files. And usually we set some application components in the both the configuration files. Moreover, when we develop a big application, we may face some inconvenience.
What problem does this video deal with and what is the solution the viewer is looking for?
Sometimes, an application requires some background tasks, such as regenerating a site map or refreshing statistics. A common way to implement this is by using cron jobs. When using Yii, there is a way to use a command to run as a job.
Sometimes, there is a need to fine tune some application settings or restore a database from a backup. When working on tasks such as these, it is not desirable to allow everyone to use the application because it can lead to losing the recent user messages or showing the application implementation details.
There are many tools available for automating the deployment process. The aim of this video is to consider the tool named Deployer.
By default, the basic and advanced Yii2 application skeletons use Codeception as a testing framework. Codeception supports writing of unit, functional, and acceptance tests out of the box.
PHPUnit is the most popular PHP testing framework. It is simple for configuration and usage. Also, the framework supports code coverage reports and has a lot of additional plugins.
Besides PHPUnit and Codeception, Atoum is a simple unit testing framework. You can use this framework for testing your extensions or for testing a code of your application.
Behat is a BDD framework for testing your code with human-readable sentences that describes code behavior in various use cases.
Logging is the key to understanding what your application actually does when you have no chance to debug it. If we are expecting unusual behavior in our application, we need to know about it as soon as possible and have enough details to reproduce it. This is where logging comes in handy.
When an error occurs, Yii can display the error stack trace along with the error. A stack trace is especially helpful when we need to know what really caused an error rather than just the fact that an error occurred.
If you are following the best practices and developing and testing an application with all possible errors reported, you can get an error message. However, without the execution context, it is only telling you that there was an error and it is not clear what actually caused it.
In Yii, the error handling is very flexible, so you can create your own error handler for errors of a specifi type.
The Yii2-debug extension is a powerful tool for debugging own code, analyzing request information or database queries, and so on.
Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.
With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.
From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.
Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.