Yii 3.0 and future versions: thoughts on structure: my humble opinion

I bow to all the good work being done on the next version of yii and I leave you with my opinion on how I think the structure would be improved:

All code in the Yii framework should be in a special external folder common to all vendors, not inside the vendor folder. I personally do not like the term vendor, I would call it library, and inside it should have a folder called modules and another called extensions. Each module or extention should only have a distinct name to it folder, not the name of the vendor just the module name or extension, and without version or other mentions. some rules or convention to this should be applied.
I imagine a cleaner code declaration like this:


    Use Core [
    Use Extentions [
    Use Module [
    Use Translation [
    Use Variables [

        $this->title = translate::text('backend', 'Title');
        $example1 = someThing;
    Use Parameters [
        'AppRoot'=> '@Web',
        'breadcrumbs' => $this->title;

  • All vendor extensions and modules should contain only their own code, when using yii or another vendor code, it should read the yii folder or the third-party vendor folder. We should not repeat, code from other vendors or code yii. I’ve seen some extensions and modules with vendor folders with yiisoft folders and code from other vendors, we have a confusion of one framework within another, wasted kb and structure code repetitions.

  • Messages should be at root and be a common folder to both framework and vendors to install their translations folders, if you build a very complex application with many modules and extensions, try to work on its translations… and if you want to control it with a database, you have to search and tweak code that can be changed with updates, Big work and Big mess.

I like Yii framework because it is easy to learn and very fast to develop with, but most of all because it is OOP MVC, that’s in my opinion what points my choice in using yii from other frameworks. So, we should go more this way to make the real difference.

Well, for now I just give some opinions for, at least, make you think.
I really dream with a bigger Yii.
Maybe later I will keep give you some more opinions, maybe they are good or not, but I thought I should share. Someday who knows, if I have time, I could help the core team.

I thank all the programmers, thinkers and doers and the patrons and all the community that support this beautiful framework.

Special Thanks to the Yii team, keep the good work and may the force be with you.

1 Like

So, in a nutshell, back to Yii 1 ? :wink:

Yiisoft is a vendor, a damn good one.

I like that Yii is tucked away in the ‘vendor’ folder and not shared between applications. Because that means that, unlike Yii 1, I can actually easily have different versions of Yii running at the same time.

It makes no sense to me to deviate from PSR-4.

1 Like

Not at all!
I may be wrong in this but, I think the idea is to separate framework folders from vendors folder structure, just to any project be more, in my humble opinion, organised and easily accessible and readable and,
I think it doesn’t conflict with PSR-4 as it is it’s designed for autoloading classes from files paths. So you could have all the frameworks or versions of frameworks you need.

What I was thinking is a bit like this:

| — Yii1/
| — Yii2/
| — Yii(whatever version you want)
| — Another Frameworks
| — …

| —Vendor1/
| —Vendor2/
| — …

| —Vendor1/
| —Vendor2/
| — …

| —Yii/
| —Vendor1/
| —Vendor2/
| — …

But It’s only a thought, I can be really wrong… what do you think?

1 Like

As yii3 is going now I kind of like it.

The whole vendor thing is at least partly driven by yii using Composer. Composer allows us to load yii and a template with one command and keep all the code that is not part of our project nicely tucked out of the way, yet easy to update.

The Yii3 template tucks your application code in the /src directory so you ONLY see your code in there.

Trying to rip the Yii framework and translations out of bender breaks a lot of this. Composer wants to keep all of a modules files in one nice easy to find and extend place.

-John Scott

Practically it will be very difficult to distinguish “framework” from “vendor”.

For instance, in which directory would you like to put yii-active-record, in 'vendor' or in 'framework'? The same can be said for yii-rbac. They can be used in other framework or with vanilla PHP projects.

And the widgets. There will be variations of UI widgets for yii framework depending on the various javascript/css libraries. The first release will probably be shipped with jQuery/bootstrap, but the one with plain javascript will be made later. Should we call them a part of the framework? Which directory should we put them in? I don’t know.

Anyway it’s not practically possible to get back to Yii 1.1 days.

1 Like

What about a more complex app with frontend, backend and api?

With Yii2 template we would have 3 folders, backend, frontend and api.

What is the suggested structure using Yii3 ?

Also looking for an answer to your question.