MyBB Community Forums

Full Version: Yii framework
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
I would rather have that faster load time than extremely easy to read code. But, there can be a balance as well Toungue.
(2012-05-03, 04:37 AM)Alex Smith Wrote: [ -> ]I would rather have that faster load time than extremely easy to read code. But, there can be a balance as well Toungue.

Well I don't mean like you're reading a book. Just something you can pick up on without needing to invest a ton of learning time into it.
(2012-05-01, 05:01 PM)Tomm M Wrote: [ -> ]...Bear in mind Yii only loads what you need, so out of that 20mb it may only load 3...
I'll vote for Yii, already starting to learn it since MyBB is (was) going to use it.


Performance?
It blows away Drupal* (both DB and CPU usage) ~Source
[Image: drupal-performance.png]

*Is blowing away Drupal a valid reason to use something? Toungue



Edit:
Did some research:

Quote:What I need is:

performance,performance, peformance
SQL engine support based on PDO (NOT only mysql, but also mssql, oracle and pgsql)
API friendliness
integrated JQuery
documentation

Here is my TOP 5 on all frameworks:

Yii - genial architecture, PDO based SQL management, security, JQuery, documentation etc
Kohana - is advanced Codeigniter rewritten into PHP5, however bottleneck is SQL storage management
Code Igniter for beginners
CakePHP for advanced developers with good opcache on hosting production server
Symfony with Doctrine 2 model for heavy industrial projects and good opcache

And i dropped developing of my own framework, since the wheel named Yii is rolling far ahead of me:-)))

...and another 'expert' opinion:
  • I would say put in the effort to understand Yii as it will be well worth your while!
~source
@ CI
I'm rather leery about CI. Almost all the reviews that I've read mention that it is beginner's MVC. Which I'd not really fair since I'm sure you could build great things with it ... The other being is that it went through a fork and yet nothing really drastic seemed to change (if I'm wrong please correct me). There is also the Ellis Lab connection that makes me worried ... Think mambo ...

@ small stack framework
There is also the Silo option! You can pull in symfony components and because it's symfony derivative you probably use zend components ...
However developers might not like this solution.

@ Yii
I find the syntax just as gibbly glop like the rest Smile

@ modems
Would love to sit down for a beer with you! Egads! wwwThreads! Surprised that you didn't mention UBB too! My first hands on pc was a TRS80! I loathed the reliability of cassette tapes! My first pc was an Apple IIc the portable one Smile I used pine in unviersity. I was too busy with girls so I didn't spend much time on BBS. Beer and girls meant now extra money for dialup and BBS fees Wink Matrix made dial seem sexy Big Grin
class LoginForm extends CFormModel
{
    public $username;
    public $password;
    public $rememberMe=false;
 
    private $_identity;
 
    public function rules()
    {
        return array(
            array('username, password', 'required'),
            array('rememberMe', 'boolean'),
            array('password', 'authenticate'),
        );
    }
 
    public function authenticate($attribute,$params)
    {
        $this->_identity=new UserIdentity($this->username,$this->password);
        if(!$this->_identity->authenticate())
            $this->addError('password','Incorrect username or password.');
    }
}
http://www.yiiframework.com/doc/guide/1.1/en/form.model


$user = Yii::app()->db->createCommand()
    ->select('id, username, profile')
    ->from('tbl_user u')
    ->join('tbl_profile p', 'u.id=p.user_id')
    ->where('id=:id', array(':id'=>$id))
    ->queryRow();

The Query Builder is best used when you need to assemble a SQL statement procedurally, or based on some conditional logic in your application. The main benefits of using the Query Builder include:

It allows building complex SQL statements programmatically.

It automatically quotes table names and column names to prevent conflict with SQL reserved words and special characters.

It also quotes parameter values and uses parameter binding when possible, which helps reduce risk of SQL injection attacks.

It offers certain degree of DB abstraction, which simplifies migration to different DB platforms.

It is not mandatory to use the Query Builder. In fact, if your queries are simple, it is easier and faster to directly write SQL statements.

http://www.yiiframework.com/doc/guide/1....ry-builder


// keep the value in cache for at most 30 seconds
Yii::app()->cache->set($id, $value, 30);
http://www.yiiframework.com/doc/guide/1.1/en/caching.data


#
  • Anyone want to (please) post some Yii code which they find confusing?
  • I'm starting to really like it.
(2012-05-03, 07:14 AM)seeker Wrote: [ -> ]
class LoginForm extends CFormModel
{
    public $username;
    public $password;
    public $rememberMe=false;
 
    private $_identity;
 
    public function rules()
    {
        return array(
            array('username, password', 'required'),
            array('rememberMe', 'boolean'),
            array('password', 'authenticate'),
        );
    }
 
    public function authenticate($attribute,$params)
    {
        $this->_identity=new UserIdentity($this->username,$this->password);
        if(!$this->_identity->authenticate())
            $this->addError('password','Incorrect username or password.');
    }
}
http://www.yiiframework.com/doc/guide/1.1/en/form.model


$user = Yii::app()->db->createCommand()
    ->select('id, username, profile')
    ->from('tbl_user u')
    ->join('tbl_profile p', 'u.id=p.user_id')
    ->where('id=:id', array(':id'=>$id))
    ->queryRow();

The Query Builder is best used when you need to assemble a SQL statement procedurally, or based on some conditional logic in your application. The main benefits of using the Query Builder include:

It allows building complex SQL statements programmatically.

It automatically quotes table names and column names to prevent conflict with SQL reserved words and special characters.

It also quotes parameter values and uses parameter binding when possible, which helps reduce risk of SQL injection attacks.

It offers certain degree of DB abstraction, which simplifies migration to different DB platforms.

It is not mandatory to use the Query Builder. In fact, if your queries are simple, it is easier and faster to directly write SQL statements.

http://www.yiiframework.com/doc/guide/1....ry-builder


// keep the value in cache for at most 30 seconds
Yii::app()->cache->set($id, $value, 30);
http://www.yiiframework.com/doc/guide/1.1/en/caching.data


#
  • Anyone want to (please) post some Yii code which they find confusing?
  • I'm starting to really like it.

Its much easier to do that in CI. Toungue

I'm not going to start another CI vs Yii war though.
It's not a war, and it started quite a while ago.

(2012-05-03, 07:32 AM)kavin Wrote: [ -> ]...
Its much easier to do that in CI. Toungue

I'm not going to start another CI vs Yii war though.

Eventually someone will post some Yii vs. CI examples, or Yii wins by default. Wink
Quote:It's not a war. We're just discussing like civilized people do.

Toungue

To be honest I last used CI about a year ago but I still use PyroCMS which is built on top of CI. So, I'm not an expert at it but have at least tried it out.

Consider a query transaction between Yii and CI. The CI I have quickly written so apologies for mistakes:

$this->db->trans_start();
foreach($tables as $name => $table)
{
	if($this->db->table_exists($name))
	{
		// Drop table if it exists
		$this->db->query("DROP TABLE {$name}");
	}

	// Execute the table SQL
	$this->db->query($table);
}

$this->db->trans_complete();

if($this->db->trans_status() === false)
{
	// Problem? Then undo everything we've done
	$this->db->trans_rollback();
	show_error($this->lang->line('error'));
}
else
{
	// Commit tables to database
	$this->db->trans_commit();
}

OK, now Yii - this is actual MyBB 2.0 code (from our development test):

$table_transaction = Yii::app()->db->beginTransaction();

try
{
	foreach($tables as $name => $table)
	{
		if(Yii::app()->db->tableExists($name))
		{
			// Drop table if it exists
			Yii::app()->db->dropTable($name);
		}

		// Execute the table SQL
		Yii::app()->db->writeQuery($table);
	}

	// Commit tables to database
	$table_transaction->commit();
}
catch(Exception $e)
{
	// Problem? Then undo everything we've done
	$table_transaction->rollback();
	throw new CDbException(Yii::t('global', 'error', array('error' => $e)));
}

We can argue all day into which method is correct or which framework handles ActiveRecord better. Neither is going to win because we like our own frameworks but once you get the hang of Yii it really isn't as complicated as you might think.

If you haven't already, I would suggest reading Larry Ullman's Yii Series. Personally, I found it hard to get in to at first but after reading that the Yii class references and tutorials were fairly easy to follow it's just getting over that first hurdle that matters. While the grass isn't necessarily greener on the Yii side it does make things slightly more easier.
Tomm your example is an example of why I find Yii confusing. Their syntax is alien to what I know about php. I know it's written with OOP in mind but I feel like Yii uses a ton of odd named functions and classes I will be forced to learn.

catch(Exception $e) What's that?

The CI code I perfectly understood. The Yii code might as well been written in Python.

I already have the Larry Ullman's Yii Series bookmarked. I'll find an afternoon to go through it more.

But I wonder if I shouldn't sink my teeth into CI for a small project just to get my feet wet with OOP and a beginner framework.

Edit: Hmm... http://php.net/manual/en/language.exceptions.php


So much to learn.
(2012-05-02, 10:04 PM)kdevs Wrote: [ -> ]
I worry that all frameworks suffer a flaw at some level and wonder why MyBB doesn't go forward with code from scratch. Certainly enough libs exist within the open source community that not all elements have to be written from scratch. Borrow a piece here and there and you can build a sweet ass framework specific for forum software. 

That's what I'm thinking. Why not just build a framework from scratch?

Then you're looking at MyBB 2.0 being released in 4-5 years time. We can't really afford to wait that long for a major release. We'd just be reinventing the wheel. Having used many frameworks in the past, from CI to ZF, I can say this is firm decision for us to make at this current time.


(2012-05-02, 11:26 PM)Josh H. Wrote: [ -> ]The way I see it, MyBB will be using that crazy syntax, and therefore everyone else will need to read a dozen books to comprehend it. Okay, not a dozen... But the code should be where someone just understands syntax and MVC, and then instantly understands the code. Yii has confused the... Uh... Heck... Out of me.

We can still follow our own coding standards. I always do that with ZF. Not once have I followed those in their documentation. Of course, with 100% OOP on the table there will be a few changes made but that's understandable. If we want to we can follow the same standards as we do with with the 1.x series. No harm done there. Yes, you will need to understand the logic of MVC and OOP if you're going to be diving in to the code and possibly if you're going to be creating plugins but you'd have to do that no matter which framework we pick. Sometimes I think people forget we're using a framework, something to build upon, not something to develop itself.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23