Basic template vs new Yii 3.0 template

I missed the composer require yiisoft/yii-base-api which does nicely what I wanted for rest API

what is funny in the poll is most of people voted for yii3 don’t even know about the actual problem

I’m sure at least @Insolita understands it completely so I’d not be that sure others do not.

So we have to emphasize that the new yii 3 template “yii-project-template” is a kind of place holder for the actual templates: “yii-base-web”, “yii-base-cli” and “yii-base-api”. Ideally we should easily be able to select only the required functionalities through those 3 templates and other libraries.

1 Like

I would like to keep 2.0 approach and only let composer be used for additional code not main app. Also index.php should be simpler.

My proposal basically would be to have a template, which would allow you to install as in Yii2 in a practical and simple way, usually the majority seeks to install the Application Web Template, which for me, the best proposal is @hiqsol with the base web skeleton and skeleton master, since it allows updating the base web skeleton without reinstalling it simply by updating and its installation was simple and intuitive with the basic configurations of any web application.

Hopefully we will have the DB layer working, since this will allow more people to relate and we can make corrections of other important packages, and so we can move faster.

On the other hand you can create another template, which of a clear example of how to use yii-base-api, yii-base-cli, so that we can all clearly understand what is the best way to work.

Sorry my bad english.

i agree with you @vanhelvzla

I think the purpose of a template should be to bootstrap a new app with minimal effort.

This is what I got after running the command
composer create-project --prefer-dist --stability=dev yiisoft/yii-project-template myapp
03

With this, I’ve to create everything from scratch. For that we have Laravel.

We need a basic template same as like yii2.

2 Likes

I really like the idea of a “yii-base” template with “yii-base-web”, “yii-base-cli”, “yii-base-api” templates for each purpose. We currently tend to always use the yii2-advanced template because we usually need cli, a frontend and backend webapp - or even more than 2 web parts. So the ability to only add api/cli/web as needed for a product, but as many of each as you need within the product, seems powerful. It’s also very much in line with current application design views and will make Yii 3 future-proof for the next decade!

However I also wholeheartedly agree with everyone concerned about accessibility for new and novice users and the learning curve required. It was quite a struggle for us to get started with yii2 about 3 years ago and it was not for the faint-hearted. It’s also Yii’s greatest disadvantage to Laravel and others. So overcoming this should be part of the Yii 3 agenda, but not at the expense design quality based architecturally sound decisions when we have other ways of lowering the barrier to entry and making Yii3 easy to get started with.

So why not do something like this?

  1. Create the new Yii 3 template structure as proposed because it makes sense.
  2. Make sure adding each api/cli/web component can be done with a one-liner. So for example do not require a composer require foxy/foxy:^1.0.0 to get yii-base-web to work, just make foxy a dependency of yii-base-web
  3. Create a quick-start wizard on https://www.yiiframework.com/start. Ask the user what he/she needs for a new product and interactively generate the list of composer commands to copy/paste to the CLI (or even a downloadable bash/powershell script) depending on the checkboxes the user marked. For example:

The product I’ll be building:

  • Will have a website (= adds composer require yiisoft/yii-base-web)
  • Will have an API (= adds composer require yiisoft/yii-base-api)
  • Will have batch jobs (= adds composer require yiisoft/yii-base-cli)
  • Will be used from a command line interface (= adds composer require yiisoft/yii-base-cli)
  • Will have users that register and/or login (= adds a user module)
  • Will need role-based access control (= adds composer require yiisoft/yii-rbac)

etc.

[Start button]

18 Likes

Good ideas. Thanks!

2 Likes

It would be cool, if new Yii3 web template will have some basic CMS features to start, like Admin panel, menu editor, RBAC manager, logging module, modular structure etc, like Yii2 Starter Kit, which is really popular (but too complicated for beginners). Such “yii-base-cms” will gain new developers to use Yii for common tasks, like website rapid development.

2 Likes

I don’t think it’s a good idea:

  1. Flexible CMS isn’t easy to implement and maintain.
  2. Not everything requires CMS.
  3. Not everything requires that kind of CMS.
  4. Template will be more complicated with it.
3 Likes

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 .