Welcome Guest.   Make a donation to an author on the site September 01, 2014, 02:47:58 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Read the full one-year retrospective report on DonationCoder.com.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: The Yii PHP Framework  (Read 9911 times)
mouser
First Author
Administrator
*****
Posts: 33,292



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« on: April 20, 2011, 04:53:28 AM »

Just wanted to post some quick thoughts after spending a few days with the yii PHP Framework.

I have been looking for the "perfect" web development framework for a number of years.  I've had quite a bit of experience with a relatively lightweight PHP framework called CodeIgniter, which i quite like, and I have spent quite a bit of time trying to use the Drupal CMS system as a framework for custom web application coding, which i have vocally warned people to avoid.

You could sum up my current thinking about frameworks as highly dubious of anything fancy.  My experience is that the more minimalist the better -- less to go wrong, and less exotic code that does some stuff in super-clever ways but makes other stuff insanely convoluted.  The more a framework tries to do stuff in some clever automatic way, or enforces some elaborate structure, the more painful it is to use when you inevitably need to do real-world stuff.

I spent quite a bit of time this year looking at Python frameworks -- hoping to switch from php web development to python web development -- but concluded that at the current time, deploying python web applications is a total joke and a catastrophe for anything other than a scenario where you are running a single python web application on a server.  I also didn't fall in love with Django, Pylons, or the other major python web frameworks.

So anyway, I decided to experiment a bit with yii.  It's much newer than CodeIgniter but shares much of the same focus on being minimalist and fast.

However, it is substantially "heavier" than CodeIgniter in many areas -- providing some very cool form and data handling classes.  I'm still unsure about how much of a cost these features will inflict when it comes time to do some non-standard stuff, and i would prefer that it didn't do quite so much "magic" stuff behind the scenes.  In this respect I think i still prefer CodeIgniter.

However there is one area in which yii would seem to me to be a really clear win -- and that's what inspired me to post -- the quick construction of scaffolding code (controllers, models, views) automatically from existing database tables.

That is, if you have a legacy database that you want to build a web application around, yii has some absolutely fantastic tools for automatically creating controllers/models/views that will let users browse, view, create, edit entries in the database.  Normally I would avoid such features, but there is no denying that for some projects this might represent a huge time savings.
Logged
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: April 20, 2011, 05:30:41 AM »

Did you ever take a look at CakePHP?
Logged

- carpe noctem
mouser
First Author
Administrator
*****
Posts: 33,292



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: April 20, 2011, 05:35:05 AM »

I took a very long look at CakePHP a couple of years ago.. It was a toss up between that and CodeIgniter for a big project.  I went with CodeIgniter because I wanted something leaner and more lightweight.
Logged
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: April 20, 2011, 05:47:55 AM »

OK, just popped into mind because you mentioned Yii does model/view/controller.
Logged

- carpe noctem
bscott
Supporting Member
**
Posts: 21

View Profile Give some DonationCredits to this forum member
« Reply #4 on: April 20, 2011, 06:06:13 AM »

We have been down the same road. I looked at CakePHP but went with CodeIgniter because I preferred less magic. I have spent some time with Drupal and am not quite as averse to it as you - but then I haven't tried to use the Forum module.

Recently I have looked at Python frameworks starting with Django which I initially quite liked but then felt it was too heavyweight for me but it does have a good admin feature for rapid CRUD. I then took a brief look at Pylons and Turbogears neither of which were to my taste: Pylons has gone into maintenance mode and Turbogears makes too many decisions for me.

I am currently looking at Pyramid which I am quite taken with - it strikes me as the Codeigniter of the Python world.

I will now add Yii to my list (which never gets any shorter).
« Last Edit: April 20, 2011, 06:10:51 AM by bscott » Logged
justice
Supporting Member
**
Posts: 1,888



Solve issues simply.

View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: April 22, 2011, 11:53:33 AM »

Btw if you want something minimal Lemonade looks interesting:
[copy or print]
require_once 'vendors/limonade.php';
dispatch('/', 'hello');
  function hello()
  {
      return 'Hello world!';
  }
run();
But its a micro framework, CodeIgniter looks like Zend Framework in comparison.
Logged

mouser
First Author
Administrator
*****
Posts: 33,292



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #6 on: July 04, 2011, 06:39:13 AM »

I've been using Yii more lately and I have to say that there are some areas where it is absolutely a joy to use.  It's Active Record and Form classes make it very clean and easy to present forms, do error checking/reporting, and save/modify model data.  This is the bread and butter work of these frameworks and Yii just excels at this this kind of stuff.  It also seems to be very flexibly in terms of how you organize your code and how you handle flow of program execution.

To be sure it's not perfect, but I continue to be impressed with how smooth it is to code for, in a way that i've not been with any of the other frameworks i've looked at. 
Logged
Rover
Master of Smilies
Charter Member
***
Posts: 628



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #7 on: July 04, 2011, 11:31:10 PM »

Hey Mouser --  I don't want to alter the thread direction, BUT have you looked at Drupal?   embarassed

I have faithfully ignored it for many years.  Someone at work asked me to consider it and much to my surprise, I can drop only slightly modified php directly into a new page. (node, or whatever they call them.)  Given the steep learning curve of most php frameworks, I'm considering that I might be just as far ahead to learn the Drupal  way and simply use the CMS as a framework.

I  think you and I struggle with similar goals for perfection in tools.  It'd be really cool to not have to re-invent the wheel for normal requests like, Authentication, Intrusion prevention, DB connectivity, forms creation, processing and reporting, etc. all of that WITHOUT having to conform to the design constraints of the rabid Framework designers.  Or at least without having to spend 6 months of in-depth study, plus 3-4 projects with false starts and failures to learn the entirety of the framework design and functions.

Why can't I just have it all, right now?!!

Look at me getting all "developer-y" and serious in a post, without smileys even... can't have that.  tongue

 read two cents
Logged

Insert Brilliant Sig line here
mouser
First Author
Administrator
*****
Posts: 33,292



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #8 on: July 04, 2011, 11:34:56 PM »

Have i looked at drupal?  

http://www.donationcoder....um/index.php?topic=8030.0

I've used drupal on several projects now, and found it consistently unintuitive, confusing, and unpleasant.

It is powerful and extremely flexible, and has a nice modular design, and has a library of books about it (which i love), but it is big and alien.

If you are a coder who needs to develop a custom project that is first and foremost a CMS, Drupal may still be the right choice.  It does a good job of supporting modular non-invasive extensions.

But I was very unhappy with trying to use Drupal as the base of a project which was not really a CMS.  It *looks* like it might be a good foundation for generic projects that have user accounts, etc -- but i found it deeply frustrating.

And especially after having gone back to basics with a lightweight framework like yii, I can say it is immeasurably more enjoyable to build code on top of a more lean and minimalist foundation, rather than trying to find your way through the convolutions of something like Drupal.

It's really an age-old problem for programmers, whether it's better to rewrite your own version of some code or use an existing codebase.  Drupal has a ton of code that can be appealing in terms of letting you start off with most of the code you need already in place.  But as someone who has often leaned in that direction, I'm remembering now nice it is to write it yourself and really understand the code well, and not have so much stuff in there that has nothing to do with your needs.
« Last Edit: July 05, 2011, 01:11:53 AM by mouser » Logged
justice
Supporting Member
**
Posts: 1,888



Solve issues simply.

View Profile WWW Give some DonationCredits to this forum member
« Reply #9 on: July 05, 2011, 04:24:10 AM »

Sometimes what you need is a framework that makes it quicker to get to that point where you have a custom solution. I couldn't imagine starting a new PHP project from scratch without frameworks (CodeIgniter in my case)
Logged

mouser
First Author
Administrator
*****
Posts: 33,292



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #10 on: July 05, 2011, 04:27:14 AM »

CodeIgniter and Yii are similar PHP frameworks, and they are both excellent starting points for custom projects.
Logged
justice
Supporting Member
**
Posts: 1,888



Solve issues simply.

View Profile WWW Give some DonationCredits to this forum member
« Reply #11 on: July 05, 2011, 08:03:20 AM »

Hey mouser if you define the database in Yii, that makes it possible to version control your database schema right? Can you define database migrations with it like rake on RoR? Is it right you need commandline access to start a project?
« Last Edit: July 05, 2011, 08:22:47 AM by justice » Logged

mouser
First Author
Administrator
*****
Posts: 33,292



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #12 on: July 05, 2011, 09:25:55 AM »

Quote
Is it right you need commandline access to start a project?
you would only need commandline access to use the feature that builds a new project directory for you, but this is 100% optional and not very important. you can easily make your own new application directory structure manually.

as far as version controlling database schema.. yii wont create database tables for you automatically, so in as much as their is a database schema it is all in your class code.  though take my comments on this with a grain of salt because this is an area i don't know much about.
Logged
mouser
First Author
Administrator
*****
Posts: 33,292



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #13 on: July 15, 2011, 02:31:50 PM »

Quick update:
I've spent the last couple of weeks now coding a large project in Yii, and have had a real opportunity to put it through its paces doing some slightly unusual stuff.  My initial positive reactions have only intensified, which is rare for me.  Yii epitomizes the notion of making it everywhere easy to do the common things, and possible to do the uncommon things.  Definitely two big thumbs up from me.
Logged
mouser
First Author
Administrator
*****
Posts: 33,292



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #14 on: July 17, 2011, 08:10:15 AM »

One important caution to add about yii:

It has a very powerful and elegant ActiveRecord class that makes it convenient to grab database records in an object oriented way, and work with them in a very convenient high-level fashion.

However it's very hard to know how badly this will impact performance (memory and cpu) when dealing with large amounts of data.

Now there is nothing to stop you from doing low level efficient manual database querying, so you can always drop down to that when you need it.. Yii does use some fancy lazy-loading functionality which an be helpful -- but again it makes it hard to know how many queries are happening behind the scenes, etc.

In short -- if you are not working with large datasets, you are really going to benefit from these features.. But if you are, you may have to be careful about relying upon them.
Logged
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #15 on: July 17, 2011, 05:36:17 PM »

Now there is nothing to stop you from doing low level efficient manual database querying, so you can always drop down to that when you need it.. Yii does use some fancy lazy-loading functionality which an be helpful -- but again it makes it hard to know how many queries are happening behind the scenes, etc.
Does it have any diagnostics (like RoR) that shows generated SQL sentences and time spent executing queries?

And what's it's ActiveRecord querying like? Fluent OOP PHP calls, limited functions, or something string-based?
Logged

- carpe noctem
mouser
First Author
Administrator
*****
Posts: 33,292



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #16 on: July 17, 2011, 05:40:46 PM »

You can read more about Yii's active record stuff here:

Some of this stuff is definitely inspired by Ruby-on-rails stuff, but i don't know enough to speak intelligently about that.  Php and mysql do have their own tools for checking expensive queries etc., i don't think yii has anything extra for that.  But it does have function to help you see exactly what it IS doing behind the scenes.
Logged
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #17 on: July 17, 2011, 07:51:47 PM »

Thanks for those two URLs - it looks mostly sane, but...
Quote
'joinType'=>'INNER JOIN',
...
'order'=>'posts.create_time DESC'
(which looks a lot like RoR AR) hints that it's probably a very thin layer above SQL... There's two reasons this makes me go 'meh':

1) magic constants are bad, especially strings. And it {w,sh}ouldn't have been hard incorporating ascending/descending in the fluent API (LINQ does it).
2) a thin layer above SQL is likely to not add optimizations that a proper expression tree API can do... which leads to fine performance for toy applications, but having to resort to hand-written (and vendor-specific) SQL when you hit medium-sized sites, rather than being able to use a fluent API well into the medium-size sites.

Note that the performance comment is just an educated guesstimate - Yii's AR implementation could easily be better, haven't looked at it smiley
Logged

- carpe noctem
mouser
First Author
Administrator
*****
Posts: 33,292



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #18 on: July 17, 2011, 08:10:27 PM »

Well like i said it has some interesting stuff about lazy loading/saving -- especially for relations.  Which is quite appealing but i tend to view stuff like that with some suspicion in terms of performance.

My assumptions generally work like this: Don't trust such high-level abstractions when performance is really an issue (large databases, etc.), and so make sure you are using something that will let you go to low-level database access when you need it.  I think yii strikes a pretty good balance there.
Logged
jpprater
Supporting Member
**
Posts: 88



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #19 on: July 18, 2011, 11:48:52 AM »

I spent quite a bit of time this year looking at Python frameworks -- hoping to switch from php web development to python web development -- but concluded that at the current time, deploying python web applications is a total joke and a catastrophe for anything other than a scenario where you are running a single python web application on a server.  I also didn't fall in love with Django, Pylons, or the other major python web frameworks.
I personally would recommend the web2py framework for the Python side.  It's simple and easy to set up, and I've deployed both the framework and actual apps written for web2py in real-life situations.  It's painless, if you use the framework's packaging features.
Logged
CodeTRUCKER
Supporting Member
**
Posts: 1,028



Bush Flying... where I'd rather be.

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #20 on: July 22, 2011, 07:52:38 PM »

Aside from this thread, everything I have come across is dated (but I'll keep looking), so I'll ask if given the 3, Yii, CodeIgnighter, CakePHP are all equally good for someone brand new if this galaxy?

My target project is not real complicated, but since it is my first, I don't mind a framework which will enforce good habits.  Any comments?
« Last Edit: July 22, 2011, 07:56:26 PM by CodeTRUCKER » Logged

I applaud those that refuse to commit "intellectual suicide."

Truth, unlike opinion, tradition, etc. will always be able to stand on its own.  Truth is not a static, but a living entity and will perpetually impart life; therefore, any "truth" that does not or can not impart life can not be Truth.

I am persuaded the only reason bad men have succeeded is not because good men have done nothing, but that good men did not do enough.

An Open Letter to My Friends


Notice: - Unless stated otherwise, I receive no compensation for anything I post here.
mouser
First Author
Administrator
*****
Posts: 33,292



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #21 on: July 22, 2011, 10:43:54 PM »

Quote
Given the 3, Yii, CodeIgnighter, CakePHP are all equally good for someone brand new if this galaxy?

Well i'm hot on yii these days, so that's what I would recommend.  CakePHP is a bit bigger and heavier and more featurefull if that's what you need.  CodeIgniter has a bigger community if that's what you need.

Note that none of these are suitable unless you are quite comfortable doing substantial coding in PHP.
Logged
CodeTRUCKER
Supporting Member
**
Posts: 1,028



Bush Flying... where I'd rather be.

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #22 on: July 23, 2011, 01:30:45 AM »

If there was a push-button WYSIWYG turnkey solution for my aviation business project, I'd use it. anyone know if there is such a thing?  Unless there is such a thing and I can find it, I guess I'll take my best shot.
Logged

I applaud those that refuse to commit "intellectual suicide."

Truth, unlike opinion, tradition, etc. will always be able to stand on its own.  Truth is not a static, but a living entity and will perpetually impart life; therefore, any "truth" that does not or can not impart life can not be Truth.

I am persuaded the only reason bad men have succeeded is not because good men have done nothing, but that good men did not do enough.

An Open Letter to My Friends


Notice: - Unless stated otherwise, I receive no compensation for anything I post here.
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.06s | Server load: 0.06 ]