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.
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.
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?
Create the new Yii 3 template structure as proposed because it makes sense.
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
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)
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.
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.
@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)
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.
So you can installyii-base-web alone.
You should not requireyii-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.
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.
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.
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 .
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.