SRL Archive - Web Development

YII Framework


Smartzkid

2012-01-12 01:01:03

Project Homepage

So far, I have had a good experience with it. The learning curve has not been easy, but I am coming from windows application development - so I first had to familiarize myself with the MVC pattern.

Anyone ever use it?

Mannsderek

2012-01-12 11:04:23

The company I work for has a website built using Yii (I didn't make that decision). It's just like any other framework, I don't see any large drawbacks or advantages of it. It's not really a popular framework yet, but it's been rising a bit http://www.php-developer.org/screenshot/phpframeworktrend.jpg

Companies usually go for the most popular or more popular ones, since it's easier finding developers who are straight off the bat familiar with them. Any reason you chose or bumped into Yii?

Wizzup?

2012-01-12 11:05:35

I look forward to the day PHP will completely vanish from the world of programming languages…

Mannsderek

2012-01-12 11:21:51

From: Wizzup?
I look forward to the day PHP will completely vanish from the world of programming languages…


PHP is completely ok, no reason to hate on it.

With the advent of the latest few versions, there's improved support for object oriented programming.

An issue with PHP is that beginners often start off with it because it's so widely supported on most web hosts. The next step for beginner web designers is usually to use PHP. This means that they code a lot of scripts and applications in bad ways and establish bad habits.

Another reason is that you can easily write bad code in PHP to perform something. Thus developers write shitty code because they can get away with it, as opposed to a language like C++.

If you're a good developer I don't see why PHP is inferior to any other language that's used for the web.

Wizzup?

2012-01-12 12:05:44

From: Mannsderek
PHP is completely ok, no reason to hate on it.


This tells me you're not a serious or professional programmer.

From: Mannsderek

With the advent of the latest few versions, there's improved support for object oriented programming.

An issue with PHP is that beginners often start off with it because it's so widely supported on most web hosts. The next step for beginner web designers is usually to use PHP. This means that they code a lot of scripts and applications in bad ways and establish bad habits.


Moreover, they're driven to bad habits because PHP encourages and enforces bad habits.

From: Mannsderek

Another reason is that you can easily write bad code in PHP to perform something. Thus developers write shitty code because they can get away with it, as opposed to a language like C++.

If you're a good developer I don't see why PHP is inferior to any other language that's used for the web.


You can always get away with poor code if you don't take yourself seriously. PHP is not the way. PHP is inferior to pretty much all the other languages out there. Ruby, Perl, Java/JSP, Python, etc.

Mannsderek

2012-01-12 12:50:25

I'm afraid I have to contest you. You come in on a thread about Yii framework and start bashing on PHP, yet you provide no solid arguments at all on why you feel this way. I find this a bit impolite.

There's a reason why PHP is used and is popular. It's widely supported, that's why there are lots of frameworks, CMS etc. that are coded in PHP. Because a large userbase has access to it. PHP can't be as inferior as you make it out to be. These languages aren't set in stone and updates can improve upon them easily. Which is what PHP has seen over the years. Your judgement of PHP being bad is too subjective.

Internet Explorer received a lot of hate, and rightfully so (actually IE 6 was great at the time of release like 10 years ago). But they eventually did improve and the latest version is comparable to the consensus good browsers.

If there there are things you severely dislike about PHP, suggest that to the developers.

Wizzup?

2012-01-12 13:53:36

  • PHP has no conventions for their _own_ API's. They are very inconsistent and often PHP suddenly breaks compatibility on minor version updates. ( http://tnx.nl/php.html#names & http://tnx.nl/php.html#args ) Due to this inconsistency you have to constantly look up the API calls.
  • PHP still has no proper unicode support. What year do we live in now, 2012?
  • PHP arrays are overly complex, slow and use a LOT of memory. They even for some retarded reason keep track which hash you inserted first. ( http://nikic.github.com/2011/12/12/How-big-are-PHP-arrays-really-Hint-BIG.html )
  • PHP's error reporting feature aren't all that great.
  • PHP enforces terrible security practices. Obviously, this is also an issue related to the developers, but just to set up a secure PHP environment you need to turn off way too many features.
  • The syntax is pretty horrible. If you don't agree, then you really need to look at some other languages… I don't think I need to cite someone on this.

I'm not really sure how object oriented programming fits in this list, because it really doesn't matter.


As for off topicness - yeah I realised this and I'm sorry if you feel offended. (by the truth? ;) )

PHP being widely supported is not a reason to use PHP. It's a circular argument. Choosing PHP because it is widely supported will obviously make it even more widely supported. Python is installed on pretty much any linux distribution, and with virtualenv you can set up and install just about any framework even without root rights. Ruby is also pretty easy to set up. However, to set up PHP properly, you should at least count several hours.

Some other references: (Yes, some are relatively old and some of the annoyances have since been ``fixed'')

Just because PHP is simple to start out with doesn't mean it is the right solution. Typically hiding too much from the developer is a bad thing.

PHP was fun to play with when the web just started and other languages didn't really have any frameworks (neither did PHP back then though), but it is really inferior to languages such as JSP, Ruby and Python these days.

E: Also fun, http://svn.php.net/viewvc/php/php-src/trunk/ext/standard/php_crypt_r.c?r1=314438&r2=314437&pathrev=314438

Mark

2012-01-12 14:25:01

I couldn't agree with you more wizzup my first ever language was php and I personally thought it was over complicated to setup the simplest things

Mannsderek

2012-01-12 15:28:53

Good post there, that's what I wanted you to follow it up with when you posted that PHP was bad. To provide some reasons.

I just felt that it was discouraging for Smartzkid, since he's obviously spent some time learning about Yii and therefore PHP as well. I don't think he should stop, since at the bare minimum you get to familiarize yourself with the MVC approach.

You seem to be very against PHP so I won't argue the contrary. I personally prefer Python (though they did have a version update not too long ago that wasn't backwards compatible) but I'm stuck using PHP because a lot of the structure that people built before was in PHP. They don't want to spend money hiring people for converting the whole thing, so they keep on using PHP.

There are a lot of funny, older PHP guides out there that appear high on Google search rankings. They have database scripts that don't use prepared statements and loads of other XSS vulnerable stuff. Many beginners unfortunately copy paste those and shit happens.

Wizzup?

2012-01-12 17:26:40

From: Mannsderek
Good post there, that's what I wanted you to follow it up with when you posted that PHP was bad. To provide some reasons.

I just felt that it was discouraging for Smartzkid, since he's obviously spent some time learning about Yii and therefore PHP as well. I don't think he should stop, since at the bare minimum you get to familiarize yourself with the MVC approach.


Well I didn't want to discourage him, at least he knows there are better languages out there now. :p

From: Mannsderek

You seem to be very against PHP so I won't argue the contrary. I personally prefer Python (though they did have a version update not too long ago that wasn't backwards compatible) but I'm stuck using PHP because a lot of the structure that people built before was in PHP. They don't want to spend money hiring people for converting the whole thing, so they keep on using PHP.


I've been using Python for most (it's not that much) web development as well. Mainly for SRL-Stats and pyroTorrent.


@Smartzkid, I suppose the framework doesn't look too bad. If you're looking for fully fledged python frameworks, Django may be what you want… or Pyramids.

Dgby714

2012-01-12 20:49:36

From: Wizzup?
If you're looking for fully fledged python frameworks, Django may be what you want… or Pyramids.


+1 Django!!

Wizzup, Why didn't you make the stats website with Django? (Just checked it out)

Should prob say something ontopic…. ummmm… ummmm…. Hmmmm…. Cool? And nope never used it.

Smartzkid

2012-01-12 21:11:35

I picked Yii mostly because I wanted to learn MVC and YII appeared to have a good implementation of it.

I haven't used python extensively, though I'll definitely consider it at some point. I like RoR, but I've only briefly studied it. And I can't go for JSP because then I'll start mixing C# and Java (I write C# at work). ;)

PHP is shitty. I hate writing $ every time I want to reference a variable. However, it's got the userbase to stick around, and it really is slowly improving.

I imagine Python, RoR, and PHP are all on par performance wise?

Wizzup?

2012-01-13 12:24:52

From: Smartzkid
I picked Yii mostly because I wanted to learn MVC and YII appeared to have a good implementation of it.

I haven't used python extensively, though I'll definitely consider it at some point. I like RoR, but I've only briefly studied it. And I can't go for JSP because then I'll start mixing C# and Java (I write C# at work). ;)

PHP is shitty. I hate writing $ every time I want to reference a variable. However, it's got the userbase to stick around, and it really is slowly improving.

I imagine Python, RoR, and PHP are all on par performance wise?


Not really. You'll find that most performance gains are not in the interpreter anyway. I think speed wise it is Python > PHP > Ruby. But the difference between Python and PHP isn't that big, at least not when not considering Python modules. (Which are often written in C)

However, Python and Ruby are much more intuitive and are easy to manage / understand how they do garbage collection etc. So you won't end up wasting megabytes of ram just for small arrays like php does. But more than anything, Python and Ruby (apparently, I haven't used it a lot) improve your productivity several times. The language are much more expressive, each in their own way. I just prefer Python because it is (to me) so much more readable.

Dgby, Django is pretty big. SRL-Stats isn't really big. I played around with several frameworks but decided to write my own. If I had to choose one now, it would be Flask. (http://flask.pocoo.org)

nielsie95

2012-01-13 12:53:01



It really doesn't matter which language you pick. They all have good libraries and it's just how you use them. PHP has a huge userbase and there are lots of tutorials, frameworks and documentation available.

About yii; I've looked into it in the past, it's pretty nice. The main downside with such frameworks, for me, is that they are pretty huge and have lots of features you will never use. The MVC model is useful for large websites, but might be a hassle if you want something simple.

Also, here's another PHP implementation in which you might be interested. It doesn't have the dollar sign and should be a lot faster as it runs on the JVM.

Wizzup?

2012-01-13 14:42:41

From: nielsie95


It really doesn't matter which language you pick. They all have good libraries and it's just how you use them. PHP has a huge userbase and there is lots are tutorials, frameworks and documentation available.

About yii; I've looked into it in the past, it's pretty nice. The main downside with such frameworks, for me, is that they pretty huge and have lots of features you will never use. The MVC model is useful for large websites, but might be a hassle if you want something simple.

Also, here's another PHP implementation in which you might be interested. It doesn't have the dollar sign and should be a lot faster as it runs on the JVM.


I think it is very debatable if they all have good libraries. However, php.reboot surely looks better than PHP, Unicode support and all. I don't really see why they even used the name PHP in there.

Dankness

2012-02-15 13:00:51

Is Yii HMVC or just MVC patterned? I personally use CodeIgniter myself with HMVC structure and extension. Yii seems nice but i'd rather use FuelPHP the Yii honestly, it's just that FuelPHP is PHP 5.3+ since it uses Namespaces, Closures, etc, etc so in the real world application I find that I can't use it on as many host's so I stick with CI.

If you want to check out a really nice CI starting point, try out CI-Bonfire

it's a Open Source Starting point for CI Projects, that I have been dedicated a lot of my free time to and have built 15 web sites with since before v .2RC came out, I love all the extra features such as Activity's, Migrations, Permissions, etc that are already built into it plus the Module Builder is awesome, namely for converting legacy app's that already have a Database Table into a new HMVC structured project. Very good documentation on it and a lively forums.

Smartzkid

2012-02-24 22:12:25

As far as I know, Yii implements the MVC pattern.

I truly appreciate what Yii & PHP have taught me of the MVC pattern. Up until now, I have had trouble wrapping my head around it. Now that I understand the pattern, I am moving to ASP.NET MVC.

It will be a big change, but I feel it is an acceptable price to pay to get away from PHP. While it's a decent language, I am already familiar with C#. I like the idea of not having to learn another language, and it should get me up and running more quickly.