Basic template vs new Yii 3.0 template

Great idea - application template configurator!
Actually should not be that difficult to implement - just like jQuery UI builder.
The result might be generated composer file (Yii2/3 way) or even ZIP package (Yii1 way).

I have just been looking over the (draft) Understanding Yii 3. Specifically the section on the new basic templateā€¦

Looking over the sectionā€¦

So where do what we see in the browser comes from ?
Exploring yiisoft/yii-base-web structure:

If you explore the folder in vendor/yiisoft/yii-base-web , you will see that the template is in fact a project itself, with this structure:

It looks like my code is going to be placed under the vendor folder?!?!

And this is going to be the recommended way to write YII apps for version 3?

I think this is about as non-obvious a place to put the application as we could find!

I would much rather it be placed somewhere on the upper level. Perhaps in /app or /application.

As it stands now I have a problem with tree duplication. I have multiple /public, /config, /composer.php directories and files. This smells bad! It is ripe for typo errors and confusion while trying to learn a new framework.

It may be that I am missing something as I have not tried using v3, since the DB stuff is not working yet, and would like to get some feedback on these issues.

Thanks for all the work in keeping Yii such a great framework.

-John Scott

I think the same.

Will my code be under the vendor folder? To me, itā€™s a nonsense. .gitignore file puts vendor folder out of version control.

Am I missing something? I hope so!

It could be great if anyone clarified this.

@jscott @ricpelo no, you wonā€™t be hosting or modifying code under vendor.

I was planning to describe how to start doing your own modifications, but decided I need to understand things a bit better before writing that part. Hereā€™s what Iā€™ve originally wrote and kept back: https://gist.github.com/machour/84d52e8db3b63f0f53b63b12a294f1cb#modifying-the-text-on-the-homepage

Iā€™ll be updating the wiki post soon :slight_smile:

1 Like

@samdark Something Iā€™m not sure to understand with the new web template, but maybe thatā€™s because itā€™s in a really early state: Is it supposed to be a real template, that user require and build on top of it?

I see for example that it is requiring bootstrap & jQuery, as it uses ActiveForm, so using this template would force me to have those in my app.

I know that this is trying to solve the yii2 problem (install basic template, change it and never benefit from changes made after that in the template), but Iā€™m not sure this is the right direction either.

On the other hand, I love the idea proposed by @toMeloos that is having a project builder.

What if yii-base-xxx were labeled as ā€œsamplesā€, came into many different flavors community maintained (yii-web-sample-vue-webpack). Using the builder, if I tick one of those, their code would be copied in the resulting project (copied to the project root, not included as a composer dependency)

:thinking:

1 Like

What I understand is this:

  1. yii-base-web is a superset of yii-project-template. yii-base-web has all that yii-project-template has. And it also has web application specific dependencies.
  2. So you can install yii-base-web alone.
  3. You should not require yii-base-web in your project created by yii-project-template.

The documents of yii-project-template and yii-base-web are out of date and are not correct at the moment.

What we have to do is just simple:

composer create-project --prefer-dist --stability=dev yiisoft/yii-base-web myapp

But, oh, it fails because of dependency problem at the moment. You have to edit the composer.json to exclude yii-debug and yii-gii. And do the composer update:

composer update

Voila!
Youā€™ll get all the template code outside of vendor directory and all the dependencies in vendor directory.

[EDIT]
OK, I was totally wrong with my understanding. You canā€™t install yii-base-web alone. Or, you may say that you can install it alone but it wonā€™t work.
You need to install yii-project-template and require yii-base-web. And copy those template files in vendor directory to your own directory.

:smirk:

It seems to be implemented the other way around for now. yii-project-template is the base project you install using composer create-project, and then you can include yii-base-web, yii-base-api, yii-base-cli if you require them.

The idea behind this is that youā€™ll be able to keep yii-base-web up to date with its latest changes whenever you want.

Iā€™ve updated the README of yii-base-web accordingly yesterday: https://github.com/yiisoft/yii-base-web#installation

All in all, this is still a bit fuzzy and none of it seems definitive to me. Other solutions like the project builder mentioned earlier seems promising too!

The truth of everything while the DI PSR connection is not ready, nothing will work, I understand that this was already discussed at https://github.com/yiisoft/di/issues/23, but this is the main problem to advance in Yii3 .

OK, so if i can do a:

composer create-project --prefer-dist --stability=dev yiisoft/yii-base-web superapp.example.com

and get a yii v3 install with directories for controllers, models, views, etc then it sounds great to me.

The idea of being able to update the app as upgrades to the source template happen is tempting, but I expect most people, myself included, take the template and make enough changes as I build my app that updating the template is not a trivial task.

I canā€™t wait for the database stuff to be completed so I can do a test port of one of my small apps.

-John Scott

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 ?

At what point does the src folder appear?

Good evening, happy new year, this week has been excellent @machour, @fabriziocaldarelli and @hiqsol have done an extraordinary job still missing a lot, but it has taken a big step, for my part I have been accompanying and learning di is a breakthrough and foxi for handling the asset management proposed by @schmunk, and the adaptation to yii 3.0 from @hiqsol can take a big step towards the use of webpack, node, vue, etc.

Anyone who wants to try a basic web application, can send me a private message and I will gladly pass them the repository, so as not to place a link that is not from yiisoft.

I feel happy, Yii 3.0 I think it will be a great achievement for the community.

4 Likes

can be done with composer installer. ie. Yii2 has yii2-composer extension

The most helpful ā€œdocumentā€ I ever read when learning Yii 1 was the sample blog that you could download from the yiiframework site. It was a fully functioning blog - nice! Looking through that code while reading the tutorials and other online docs really helped me to learn Yii.

It had a lot more than the Yii2 basic template and in some ways more than the advanced template, though, of course the advanced template does have some complex app structure to it. But in general those templates have a home page, contact page and a login page. The blog had rbac, database models; it used grids and complex forms. So much to see and learn from. It was exciting! And it worked and did so much - nothing to get discouraged about.

I think we need to consider the learning curve. I would guess that the majority of the voters and those of us reading and making comments have gone past the learning curve part. Years ago. Letā€™s not forget our roots, :slight_smile:

Yiiframework.com has always had very impressive API docs and a very nice User Guide, but for me a sample application is like having a personal tutor. I learn from it a lot faster, at least to get that first website up and running. I believe a more full sample app template would be a boon to Yii framework adoption. It convinced me years ago.

I have invested in a lot of Yii1 and Yii2 books, and I have spent a lot of time reviewing the Yii source code, online API and guides. But I donā€™t think I would have ever gone that far if it wasnā€™t for the great start I got from the sample blog.

3 Likes

Iā€™m actually thinking about creating a blog tutorial for Yii 3 as well :slight_smile:

7 Likes

I got Uncaught ReflectionException: Class app does not exist error after I install the yii-base-web

@aszx0413 Yes, use https://github.com/yiisoft/yii-demo/ for now.

It sounds good! Especially, if i want to make complex application with api, cli, orm, and web - i should receive full skeleton with all parts and necessary config stubs (i think this can be resolved with postinstall hooks).

Only a question: for yii3 there will be one basic and one advanced install, or only a basic?
Iā€™m going to start a project with yii2 with frontend and backend and I want to be sure that I will be able to migrate to yii3 when it will be ready.

1 Like

Only one template structured more like basic one from Yii 2. Youā€™ll be technically able to create advanced-like structure with Yii 3 as well but it wonā€™t be proposed in a form of template.