I am 99% new to Yii2 so I need some basic understanding of best practice. The 1% is that I installed the basic template and got it up and running. I even tried the migration.
I am an experienced developer and so I am not new to frameworks, mvc, extensions and all that. I am a pro developer for i.e. TYPO3 and Drupal. Enough of my background. Just so you know I do not need to have it from the beginning.
I got a new job and after a short time, I finally convinced the other developers that the homemade framework was old and not fleksible, not maintainable etc. We are wasting increadible amount of time to maintain existing codebase. And it is getting harder and harder to maintain it.
SO - I am trying to find out how to proove that Yii2 is the way to go. And I need your help for that. I need to build an administration-system from the scratch up. And Yii2 fits perfectly in here, in my oppinion.
I have searched for best practice of how to make "something" and to have an installation-routine for the project. But up to now, it has been unclear for me. I do not want to invent something where others already been.
Does anyone know whats the best practices of installing a project, how to build an installation-program of some sort. I guess you guys do not install i.e. a yii2 based cms by running migrations?
I would probably develop an administration module and then create a Composer project.
Installation would then just be a simple call
composer create-project you/your_starter_project
The basic project template has some initialization code that runs in the post create hook - take a look at the composer.json for that.
As for the actual user-driven installation, one way of doing this is to have either an installation controller or an installation module combined with a check for the existence of a .lock file somewhere…
I haven’t actually looked into creating installers for Yii 2 yet…
I’d advice you to check out a wide range of Yii 2 extensions and browse their code because it will (hopefully) give you many ideas about what makes Yii 2 tick.
Thanks for the reply. I was thinking the same thing + one more thing. I was thinking of calling the migration-part directly from the controller to install the basic system. And so on.
I am already diving into the world of components, to see if I can develop something to help me here. And I am also looking at various projects of how they are doing it.
I still have some documentation to read because I do not understand fully how Yii2 handles namespaces in modules etc.
Thanks for the links and the info. You pointed me in the right direction.
So you are suggesting to develop the core system as a seperate new composer package, instead of keeping it "in the project"?
I can see the benefits here but what would you then suggest to handle the modules for the project?
Before you can answer that, I need to tell the aim of the project. It is mainly going to be an administration-system. Up to now the "client" has everything in one big system, special developed. And there is so many "coding standards" in it, so you go blind. I want to change all that so I can help me and the other developers to focus more on the functionality instead of the code.
One of the directions is to have a core system, and install it multiple times with special developed modules in each system. Some of the modules will be in installation no. 1 and others in installation no. 2
It is almost like a cms system like Joomla with enabling/disabling of things.
I am really grateful of your input. It is a big help. I am very keen about the architecture and wants the best.
So from a pro developers point of view, the right aproach (simplified a lot) will be to have the base almost untouched, with only the SiteController to start it all up and activate the first module. And then let all the magic happens in various modules?
Hi CoRex and Jacmoe. Am also very new, still a baby developer. Have a little above 1 year experience with PHP development. Have never used a framework before besides wordpress and joomla. All other projects are hand coded. I know frameworks are a way to go.
My questions are:
What is/are the dangers/demerits of installing Yii (or any other framework) via their archive files? Must I install via composer?
Must I use stuff like codeception for testing?
I have been studying a book I got from packt on web development using Yii2 and it’s getting too complex and errors are erupting here and there.
The errors erupting all over the place will eventually - if you stick it out - cease and you will learn the ropes
Yes, you definitely need to be using Composer. Because it not only installs Yii but the dependencies as well. And you will need Composer to install Yii extensions.
While you theoretically can install everything manually, you will miss out on version control and easy upgrade/downgrade.
Learn to love Composer - it is in my opinion one of the most important changes from Yii 1 that has made Yii 2 so much better!
No, you don’t need to be using Codeception, but since it is built-in it would be less wise to use something else. Especially when Codeception is easy compared to ‘the competition’.
The sooner you get to know the framework, the better.
Feel free to open up topics in the Yii 2 general discussion forum when the errors erupt.
A little word from me. I agree in all what jacmoe writes. Even the bigger CMS’es are going composer. TYPO3 is fully supporting composer. Dont know status of Drupal, Joomla is on its way. Dont know about WordPress. So you can see, if the big ones see’s the light, so can we
After my brief time to Yii2 I found that Yii2 is a very solid framework with a lot of supporters. It is of course important to use a solid framework, but even more important are the developers behind it and all the contributors. These are your buddies. I have developed my own framework from scratch up some years ago. I would not do that again. I would rather take a framework i.e. Yii2 and base my development on that.
That said, Yii2 cannot handle everything, but bear in mind that it is "only" a framework. I had to develop some widgets from my own because I found Yii2 was missing what I needed. But in doing that, I did not start from scratch, since the foundation (Yii2) was there.
Since you call yourself a baby developer, I will give some advice’s to you. If you do not agree, trash them, but I am pretty sure that these will help you grow as developer. There are a lot of developers, but if you want to be a top developer, read these advice’s. There have been written large books on these subjects, but here is a few basic ones.
Learn to recognize patterns and use them.
Always research best practices and try to stick with them.