Yii3 Overview 1. Introduction

Good day, dear reader.

During my professional career, I have worked with a lot of tools – both on the PHP stack and outside it: databases, various queues, search engines and more. For the last couple of years I have been one of the maintainers of the Yii3 framework. During this time, a lot of effort has been invested in the restructuring of the framework from monolithic to fully component. I look into other open source projects from time to time, but mostly I help the team develop Yii3.

I want to launch a series of articles, and in the future, video reviews of opportunities ready libraries from Yiisoft.

About the framework

Yii3 – package framework. And this means that you can use the libraries from the framework in decoupling from the Yii ecosystem. For example, such packages can be connected to Yii 2, Symfony, Laravel, to a project without a framework, or to any other PHP project.

To view existing packages in Yii3 there is a separate page: https://www.yiiframework.com/status/3.0. A link to it can be found on the progress page. There is a link in the footer with the text: “Detailed release statuses”.

AT survey Russian-speaking PHP community Yii3 took third place in the choice of framework. The team and I will make every possible effort to raise the framework to a higher position. Or at least increase the percentage of use.

Link to source: https://phpcommunity.ru/2021-php#!/tab/404346216-1
Link to source: https://phpcommunity.ru/2021-php#!/tab/404346216-1

Why choose Yii3 when Laravel/Symfony is available?

  • Yii2 was famous for its excellent documentation. Documentation can be found on any of the properties of the class, not that on the module. Laravel cannot boast of this, and quite often this becomes a problem when using this framework. In Yii3, we will try to keep the level of documentation high.

  • Both Laravel and Symfony have many controversial points in their implementation: naming difficulties, confusing algorithms, support for older PHP versions using inefficient language methods and functions, strong binding of framework components to each other. In Yii3, we will stick to reverse values.

  • Yii2 is a great prototyping tool. In Yii3, we will not drop support for this feature. Of course, this does not mean that we will leave Yii::$app for convenient access to the framework components. However, access to the components will be quick and convenient using Dependency Injection and configuring the entire component in the configuration file. Everyone’s favorite Gii will exist in the framework’s component set.

  • Often Yii2 was criticized for its poor decision with the Yii::$app service locator and this was the final point in the choice of framework. Now there will be no such possibility, which means that Yii3 will not yield in building a good application architecture with the right allocation of the domain layer and everything that today’s PHP developers love. I’ll tell you a secret that this has never caused problems before;)

As always, a framework is just a tool. There is no one universal tool for solving all problems. There are comfortable and suitable. And they are not always the same tool. Choose your tools wisely. Conduct the necessary tests, upgrade your expertise by learning new things.

In subsequent articles, the issues of comparing convenience / performance / capabilities of similar libraries from other frameworks will not be raised.

“Is Yii 3 released?” – you ask.

And I will answer that there is no single repository. For example, yiisoft/yii3, by the tag of which it would be possible to judge whether there was a release or not.

Each component has its own release cycle. Components are not related to the entire framework. From time to time, the community informs us that ready-made components are already being used in production. Both with Yii2 and with other frameworks.

You can follow the progress here: https://www.yiiframework.com/yii3-progress. You can find this page on the main page. At the top you will see a button with the text: “Looking for Yii 3 progress?”.

What will we consider?

The articles will mention concepts such as: “repository”, “package”, “library” or “tool”. It is worth initially unsubscribing that these concepts mean the same thing – a set of classes, methods or functions for solving one problem, packaged in a separate repository.

In this article series, I will be looking at packages that already have a tag of some kind. Tag – marking the sequence of commits for easy perception of versions. Versioning in Yii3 occurs according to Semver.

This means:

  • Major versions (X..) will change when a backwards incompatible change occurs.

  • Minor versions (.X.) will be changed when the current functionality is improved without the need to track “if anything broke after the update”

  • Finally, the patch version (..X) will change when fixing errors in the code that do not require checking for backward compatibility, fixing the documentation, or other changes not related to the logic of the package.

As the article is written, new packages or versions will appear. We will consider them after or at the time of consideration of the same package.

Yii3 has a number of interesting documents. Both internal, for development, and external, for users. Many of these documents can be found at: https://github.com/yiisoft/docs

Here, I would like to break down a few highlights to try to close some of the frequently recurring questions and not explain any features in the future.

Packages

Yii3, as you remember, is a package framework. That is, the final package is in a separate repository. The package will not depend on the whole framework, only on the necessary things. However, such packages can be inconvenient to use in the Yii3 ecosystem. I am sure that the user wants to include the package in the project and immediately start using it, rather than creating a new config file, dragging configuration examples from the documentation and trying to configure it in the best way. So right?

Within the Yii3 ecosystem, there are framework-independent packages and adapters that bind a package to the ecosystem. Such packages are prefixed yii-. For example, https://github.com/yiisoft/yii-middleware. The features of this package will be considered in future articles, now it is for an example.

In addition to linking framework packages with the framework itself, we make similar links with external libraries. For example, https://github.com/yiisoft/yii-sentry, https://github.com/yiisoft/yii-swagger and others.

Namespaces

The namespace of any package in Yii3 consists of:

  1. Yiisoft organization names.

  2. Package names. If there are prefix words in the package name that indicate some kind of belonging or modularity, then the name is split into several words with a backslash between the words. For example, https://github.com/yiisoft/yii-sentry will turn into Yiisoft\Yii\Sentry, and https://github.com/yiisoft/mailer-symfony will turn into Yiisoft\Mailer\Symfony.

  3. Names that logically consist of two or more words are not separated by a backslash. For example, namespace for https://github.com/yiisoft/friendly-exception will be: Yiisoft\FriendlyException

PHP version support

Yii1 has support since PHP 5.1. This greatly complicates the development of the project, limits the use of new syntax, limits the use of new PHP functionality, makes it necessary to duplicate pieces of code so that they work on different versions of the language, and so on.

Yii3 will only support versions of PHP supported by the PHP development team itself. You can find the time frame for supporting a particular version on the official PHP website: https://www.php.net/supported-versions.php.

Based on this, at the time of this writing, packages in Yii3 support PHP versions above 8.0, since the minimum PHP version that is in the active support phase is 8.0.

Some packages, due to their simplicity, may still support PHP 7.4. But this does not mean that support for this version will remain in the next update of the package.


The first Yii3 Overview article is coming to an end. I will be glad to answer your questions both in the comments and in a personal. In the following articles, I will analyze the tools that we use to develop Yii3, go through the released libraries, analyze templates and demo projects.

useful links

Chronicles Yii3. We post news almost every day.

Yii3 discussion channel. Ask questions, help others, take part in the development of the framework.

Instructions to help you become a contributor.

A page where you can express your gratitude financially and speed up the development of the framework.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *