I’ve been working with Yii for a while now, and my original, positive opinion of it, has only gotten stronger since then, to the point where I feel comfortable starting on one of my larger, paying projects in it. I’ve decided to write down my progress as I move along, hopefully resulting in a tutorial, to complement the Yii Blog tutorial. I’m not sure why it’s always a blog tutorial with these frameworks, maybe because so many would like their own blog, or maybe because they cover a lot of the basic elements, but personally I would like to see more advanced tutorials, that better showed off the depths of the framework, but that’s one of the reasons I really like Yii.. I feel like I can actually make a difference, and help out with it.
Anyway, before I get started on the larger project, I’ll share with you the experiences I’ve had so far, mainly comparing it to the experiences I had with CakePHP in some of the same situations.
The first task when developing a project with Yii is quite similar to that of CakePHP, namely to use the console to set up the basic application, then set up the database, followed by using the console to set up models and controllers. While the last step is really optional, I’d say it’s one I’m going to do every time, simply because it speeds up development time a bit, and prevents a lot of tedious typing. There are a few things I would have liked to have in the Yii console, that aren’t there, such as the ability to get help on setting up the DB connectivity with it, or at least having it make some educated guesses about the relationships between models, but they’re minor things, and due to the way relationships work in Yii, and the way they’re implemented, I’m not even sure if there would be a relatively simple way to do it.
So there’s less in the way of automation in the Yii console, but it comes with the added bonus of making the console more simple, and in addition to that, I find that it’s quite easy to extend the console, whereas this was an area I struggled a lot with in CakePHP, although I don’t know if that was because it really was complex, or because I found the rest of the framework complex, and thus automatically assumed that extending the console would be too, hence skewing my view of it.
When it comes to database connectivity, Yii uses PDO, which meant I had to read up on creating DSNs again, in particular doing so in relation to Yii, and while that wasn’t a huge issue, I would have appreciated having better help either in the console, or in the comment preceeding the database connection string configuration. It is nice, however, that you can quite easily get away with not having a database in Yii if you really don’t need one, like if you’re just doing quick prototyping. Just as you don’t -have- to have a model, and you’re free to make models that are or aren’t tied to a specific database table, so you could have a form that collected input from a form on the page, and either emailed it, or did something else entirely, without having to involve the database, which I find creates a feeling of -not- being locked inside the framework.
Once I had set up the connectivity, it was time to create the table structure. While I was using CakePHP, there was a rather rigid database structure you had to follow, and while that allowed for quite a bit of nifty automagic stuff from the framework, it was also contributing to my feeling of being locked inside the framework, as a sort of prison. But it means that there are things that, if you want them in your Yii project, you will have to make them yourself, which is surprisingly simple to do, actually. So after setting up the tables, including the needed foreign keys, I used the console to set up models for all the tables, and controllers for those areas that needed that, and after that, I was ready to start coding.
And let me tell you right now, that this was where I really started to like Yii, because everything just seemed so logical to me. The way everything was set up, while similar to CakePHP’s structure, never left me in doubt about where anything was. Some of this might be attributed to Yii’s rather thorough documentation, although sometimes I wish there were more documentation for the API reference, but be that as it may, it’s still quite brilliant. CakePHP’s documentation has also gotten a lot better over time, but when I first started out with it, it was incredibly messy, with whole chapters missing, and deprecated methods in which to do things.
So did I have absolutely no problems at all during this learning process? Well obviously I did, as it would be strange if I didn’t, but I again found that with Yii, I could get my answers far more easily than I ever could with CakePHP, because while CakePHP has a really large community, I found that coming into channel to ask questions could often result in not getting a response at all, either because no-one was awake to answer, or because people considered the question to be a newbie question, and thus couldn’t be arsed to answer it, and then there were times when people would want to help, but not know about that particular aspect of CakePHP, and all in all, it could be a rather frustrating experience. Yii, on the other hand, doesn’t have a big community yet, but it does have a very active developer, who responds to questions on the forum so quickly that I’ve sometimes wondered if he ever sleep or go out. Heh..
I could go on and on about Yii, but this post is already getting kinda cluttered, because there’s so much I want to say, yet I can’t think of a good way to structure it, so I’ll just end on the note of performance, which doesn’t cease to amaze me when it comes to Yii.. When I was running CakePHP it was running really sluggish on my development machine, and while I wouldn’t expect it to be high-performing, I did expect that it would be able to execute things in a timely manner, but it was incredibly slow. Yii runs a lot faster, making it a pleasure to work with, and to test things out in locally without having to upload to a fast production server.
As I work on my tutorial, I’ll be able to structure things a lot better, but before I end here, I would like to make it absolutely clear, that I am not saying that CakePHP is a bad framework, because it really isn’t. It’s just not the right framework for me, and it took trying out Yii for me to figure that out.
Thnak you for your notes.
I’m also switching to YIi right now and hopefully it’s a right choice.
I have the feeling that they are less things that are done for me by the framework and I’m a bit scared I’ll have to re-code a lot of the things I did for cakephp, but the cleanness and speed of Yii is really appealing.
Good luck with your projects.
I won’t lie to you.. Yes, you will have to recreate most of your work in Yii, or at least alter quite a bit of it, but on the other hand.. Not only will that be an excellent way to learn how to use Yii.. It will also give you a chance to compare Yii to CakePHP, and see if it works as well for you as it did for me.
Hi,
I am 3 years exp with PHP, used to Dreamweaver ro create the php project. Haven’t used any framework before, until my current project run bigger and bigger, I found problem when adding new module.
So I decide to use a framework. I have read through the recent Yii tutorial, and quiet understand what it is talking about. But I still have no idea where to start the project. Should I start from modify using the template project generated by Yiic ?
Any advice are really appreaciated…..
Well.. For my first, smaller project, that I used to learn Yii, I just went with the Yii Blog Tutorial, coupled with the Definitive Guide to Yii. They’re both really good, and together they explain most of the things I wanted to know. There were a few things I ran into, but I either found the answer to those in the Yii Cookbook, or on the forum.
So to answer your question.. You should start out by generating the template project, set up the database, then create models and controllers, and start modifying the code to suit your needs. Once you get started, you’ll likely found that it’s incredibly easy to do, but you need to get into the whole MVC mindset first, I think.
hi
every thing is good with yii but there is a big whole in yii
Tutorials! ye there is not enough tutorials for it and don’t know how to pass this problem!
@mahdi: Which problem? I didn’t have a problem with the amount of tutorials available for it. There’s quite a lot available, or rather, not a lot, but both the blog tutorial and the definitive guide are rather long and thorough.