Yii Framework Forum

Basic template vs new Yii 3.0 template

(Lubosdz) #21

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).

(John) #22

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

(Ricardo Pérez) #23

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.

(Mehdi Achour) #24

@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:

(Mehdi Achour) #25

@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)


(Softark) #26

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

You’ll get all the template code outside of vendor directory and all the dependencies in vendor directory.

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.


(Mehdi Achour) #27

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!

(Tecnologiaterabyte) #28

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 .

(John) #29

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

(Fabrizio Caldarelli) #30

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 ?

(Yurik) #31

At what point does the src folder appear?

(Tecnologiaterabyte) #32

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.