Open Collective
Open Collective
Loading
Yii3 Overview 1. Intro
Published on December 17, 2022 by Alexander Makarov

 
Good day, dear reader.

My name is Dmitry Derepko. During my career, I worked with a lot of tools both within the PHP stack and outside of it: databases, different queues, search engines, and more. For the last several years I've been one of the Yii3 framework maintainers. A lot of hard work was done during this time to rebuild the framework from monolith architecture into packages. Occasionally I look at other open source projects, but most of all I help to develop Yii3.

I want to start an article series, and afterward video reviews of released libraries from Yiisoft.

About Framework


Yii3 is a package-based framework. This means you can use libraries from the framework out of the Yii ecosystem. Such packages can be connected to Yii2, Symfony, Laravel, projects without a framework, and any other PHP project.

You can visit a special page to see a list of existing Yii3 packages. A link to it can also be found on the Yii3 progress page. The footer has a link with an anchor “Detailed release statuses”.

In the survey of the Russian-language PHP community, Yii3 took third place in a framework of choice rating. The team and I will make every effort to up the framework to higher positions. Or, at least, to raise usage percent.

Framework choice in 2021 (source):
  • Laravel — 1231 (35.69%)
  • Symfony — 1109 (32.15%)
  • Yii — 608 (17.63%)
  • Bitrix — 254 (7.36%)
  • Laminas (Zend) — 95 (2.75%)
  • Drupal — 63 (1.83%)
  • Phalcon — 54 (1.57%)
  • Spiral — 35 (1.01%)

Why choose Yii3, if Laravel/Symfony exists?


  • Yii2 is famous for great documentation. Documentation can be found for any class property, not to mention modules. Laravel doesn't brag about it, and often it becomes a problem with this framework usage. In Yii3 we try to keep the documentation level standard.
  • Both Laravel and Symfony have many controversial implementations: naming difficulties, intricate algorithms, support for old PHP versions with non-effective language methods and functions usage, high coupling of framework components, etc. In Yii3 we adhere to inverse values.
  • Yii2 is a great tool for prototyping. Yii3 will have the same superpower. It doesn’t mean we will keep Yii::$app for convenient access to framework components. However, access to components will be fast and convenient with Dependency Injection and customizing a whole component in a configuration file. Everyone's favorite Gii will exist in the set of framework components.
  • Yii2 was often criticized for the bad solution with service locator Yii::$app, and it was a final point in a decision about framework choice for many people. There won’t be such an ability in Yii3, and it means Yii3 will promote good architecture with the correct domain layer and anything that today’s PHP developers love. Secretly, I would say that it didn’t cause problems before as well ;)

A framework is a tool only. There is no universal tool for solving all tasks. Choose tools wisely. Do tests, raise your expertise, and learn new things.

In this article questions about convenience/performance/features comparison of similar libraries from other frameworks will not be raised.

“Is Yii3 released?”


My answer: there is no single repository (e.g.yiisoft/yii3), by the tag of which one could determine the presence of a release.

Each component has its own release cycle. Components are not coupled to the entire framework. From time to time our community tells us that released components are used in their production projects with Yii2 and other frameworks. 

You can check out the progress here: https://www.yiiframework.com/yii3-progress. This link can be found on the main page of yiiframework.com. You will see a button with the label “Looking for Yii 3 progress?” at the top of the page.

What will we discuss?


The next articles will mention such definitions as “repository”, “package”, “library” or “tool”. Should initially be said that these definitions mean the same thing — a set of classes, methods, or functions for resolving one problem, packed into a separate repository.

In this article series, I will take a look at packages that already have a tag. A tag is the labeling of commits sequence for convenient versions perception. Yii3 versioning is made via SemVer.

This mean:

  • Major versions (X..) will change when a not backward compatible change occurs.
  • Minor versions (.X.) will change when current functionality is improved without a need to track “if anything is broken after the update or not”.
  • Finally, patch versions (..X) will change when some bugs are fixed in the code. These changes do not carry the need for backward compatibility checking, docs fixing, or other changes unrelated to package work logic.

New packages and new package versions will be created while the articles are in progress. We will look at them after the time or in the time of looking at this package.

Yii3 has some interesting documents. Some of them are internal (made for development), and others are external (made for framework users). A lot of such documents can be found on the link: https://github.com/yiisoft/docs.

Here I would like to address several key points to try to close some frequently repeated questions and not describe certain features later.

Packages


Yii3 is a package-based framework. That is, each package is located in a separate repository. The package will not depend on the whole framework, it depends on needed things only. However, it may be uncomfortable to use such packages in the Yii3 ecosystem. I’m sure the user wants to install a package to his project and start to use it immediately, not to create a new configuration file, to move configuration examples from documentation, and to try to optimize them, right?

The Yii3 ecosystem has both framework-independent packages and adapters, which link independent packages to the Yii3. Such packages have the yii- prefix. For example, https://github.com/yiisoft/yii-middleware. This package will be reviewed in the next articles, here it is for example only. 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 Yii3 package consists of:

  1. Name of organization Yiisoft.
  2. Name of the package. If there are some prefixes denoting something belonging or modularity, then the name is separated into several words with a backslash between them. For example, https://github.com/yiisoft/yii-sentry will turn to Yiisoft\Yii\Sentry, and  https://github.com/yiisoft/mailer-symfony will turn to Yiisoft\Mailer\Symfony.
  3. Names that logically consist of two or more words, don’t separate by a backslash. For example, the namespace for https://github.com/yiisoft/friendly-exception will be Yiisoft\FriendlyException.


PHP version support


Yii1 has supported PHP since 5.1. It’s very difficult for project development, it abandons new syntax usage, sets limits to new PHP features usage, forces code duplication to work with different versions of the language, etc.

Yii3 will only support PHP versions that are supported by the PHP development team. The support timeframe of a particular version can be found on PHP's official site: https://www.php.net/supported-versions.php.

Accordingly, at the time of article writing Yii3 packages support PHP versions 8.0 and up, because the minimal PHP version with active support is 8.0.

Some packages, because of their simplicity, may still support PHP 7.4. But it doesn't mean that in the next package release this version support will be kept.

The first article of the Yii3 Overview is coming to the end. You’re welcome to ask any questions both in the comments and in the PM. In the next articles, I’ll review tools that we use for Yii3 development, go over the released libraries, and review application templates and demo projects.


Useful links



  • https://t.me/yii3en - Telegram group to discuss Yii3. Ask questions, help others, and participate in framework development.


🚀  1

on

Good reading. I want more :-)

on

3 articles in a year! this is very sad, it mean the project is dead
not haveing a release date and such an answers are the worst:
" there is no single repository (e.g.yiisoft/yii3), by the tag of which one could determine the presence of a release. "

we had been using yii since version 1, but we cannot start new projects with yii2 (it is outdated), just maintaining old projects for now, 
also we cannot start new projects with yii3 because it is not ready for production, we have no clue when it will be ready,
thank you all, but we have switched to Laravel/Symfony, they have a roadmap and version system, we could rely on

and about package versions, there had been versioning hell in other frameworks before, you need to coordinate packages versions with framework versions, nobody need to have a complicated package upgrade, and check what versions of packages are compatible

not having a roadmap/deadline for yii3 is the worst thing happened to this framework
Yii2 was a great framework and I loved it

on

There are not that many articles because we're busy with the framework itself.

There's no release date because for some use-cases Yii3 is already stable. It depends on a package set you're using.

There's no need to check versions for compatibility since Composer does it for you.

There is a roadmap, btw.: https://github.com/yiisoft/docs/blob/master/003-roadmap.md. We need to finish docs, squash bugs and tag releases.

on

i am checking roadmap for a long time, and monitoring the progress, to be fare lots of work has been done, but it was a slow progress which force us to switch.

because of this slow progress, sadly some yii developers switched to Laravel and do not maintain yii packages anymore on github, and there is no replacement for some of them. 

stable?! a least a year required for yii3 to be stable and production ready, also many packages from other developers need to be ready for yii3, i'm saying from experience it is too soon too be production ready for yii3

also maintaining Yii1, Yii2 and make them compatible with latest php versions is a great job you are doing
Yii2 was great, but Yii3 takes very long time to reach this stage...

upgrading yii2 to yii3 not ready yet

👎  1