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
That's true. I'm craving for 2.0.

Quote: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.

I saw their going to have an API. This shouldn't be a problem if that's true. If that's correct, then it should be easy for a dev to hook into MyBB after reading some docs. Smile
As soon as I think about Yii, I see myself like an idiot who would know nothing in it. PHP was very easy, in fact, still learning it in deep. But Yii (or any other framework, its all about dependency) , I just have a strange feeling of what I am gonna do about it.
(2012-05-03, 01:41 PM)crazy4cs Wrote: [ -> ]As soon as I think about Yii, I see myself like an idiot who would know nothing in it. PHP was very easy, in fact, still learning it in deep. But Yii (or any other framework, its all about dependency) , I just have a strange feeling of what I am gonna do about it.

Get started with an "easy to learn" framework like CI, and then get into Yii.

Trust me, once you try using a framework, you will no longer wish to develop something from scratch. Frameworks saves a lot of time.
Now we are getting done to the issue. A framework is really just php but it's also like learning new functions.

I'm wondering how many here are using 5.3 name spaces or closures without a framework?

In a sense, myBB and basically any other large script is a framework. Basically, most people don't think of it that way though.


CI is an excellent jump point to get your feet wet in OO, mvc, url routing, a module/extension registry and the hocus pocus of the framework doing things for you.
(2012-05-03, 01:41 PM)crazy4cs Wrote: [ -> ]As soon as I think about Yii, I see myself like an idiot who would know nothing in it. PHP was very easy, in fact, still learning it in deep.

All frameworks are just an interpretation of MVC and OOP in PHP. Some do it well and some do it like an episode of CSI.

Consider the following query builders:

// MyBB 1.6
// Requires escape_string
$query = $db->simple_select('users', 'uid, username, email', "username LIKE '%Tomm%' OR username LIKE '%labrocca%'");

// Code Igniter
$this->db->select('uid', 'username', 'email');
$this->db->like('username', 'Tomm');
$this->db->or_like('username', 'labrocca');

$query = $this->db->get('users');

// Laravel
// Not sure if wildcards require escaping
$query = DB::table('users')
	->where('username', 'LIKE', array('%Tomm%', '%labrocca%'))
	->get('uid', 'username', 'email');

// Yii
// Requires wildcard characters to be escaped before use
$query = Yii::app()->db->createCommand()
	->select('uid', 'username', 'email')
	->from('users')
	->where(array('like', 'username', array('%Tomm%', '%labrocca%')))
	->queryAll();

// Doctrine/Symfony
// $qb; createQueryBuilder instance
$query = $qb->select(new Expr\Select(array('u.uid', 'u.username', 'u.email')))
	->add('from', new Expr\From('Users', 'u'))
	->add('where', $qb->expr()->orX(
		$qb->expr()->like('u.username', '?1'),
		$qb->expr()->like('u.username', '?2')
	))
	->setParameters(array(1 => 'Tomm', 2 => 'labrocca'))
	->getQuery();

// ... all produce
$query = "SELECT uid, username, email FROM mybb_users WHERE username LIKE '%Tomm%' OR username LIKE '%labrocca%'";

Apologies if any of the above is incorrect. All of it is PHP but is particular to the specific framework. It's worth noting that both Laravel and Yii require wildcards to be escaped before use and MyBB 1.6 will require escape_string.

As you can see, all 4 examples use a different method of querying the database with their own query builders. It's not that any of it is hard, alien or complex - it's just 100% different to what you're used to doing (perhaps, because this is the first framework experience?).

The more and more you delve into PHP's OOP and MVC methods the easier it is to understand what's going on within frameworks. It's easy to see the complexity grow between CI, Laravel, Yii then the impossible Doctrine but it's all about finding the happy medium for MyBB 2.0.
Tomm, I think that example was pretty simple to understand - even I liked the Yii way, to be honest.

However, I believe it was one of the settings files that sent me into confusion - though - that was before using CI.

If you guys can make 2.0 easy to understand with development, then Yii is perfect. But the challenge, for me, is when it looks just like Yii's syntax. It looks like you are calling methods within methods, when you are really just calling up more classes.
I almost went with Laravel but it's really tied to the lead dev who is employed by one of the sponsors. What the sponsor doesn't want doesn't get in ... Meh!

Yii framework doesn't get touched basically. Only the app (myBB) that is built on top. Now that is the key here since you can build "extensions" to go beyond both. If the foundation is laid right things turn into "plugins" sort of like Drupal/WP and you are good to go. Need to build a "who's on" then you can just build a "widget" which ends up being not so different from what you expect in php3/4 code.

Sure other frameworks basically do the same Smile

@ Tomm / waiting on Yii 2.0
Was wondering why the wait?
Manpower?

Just wondering, you guys have a alpha floating around? Myself and a few Yii'ers have been discussing Yii+myBB for a bit now Smile hence the real reason I started this thread Smile
I don't believe there's much built of 2.0 at all and what there is certainly isn't publicly available right now.
I've mentioned a few reasons why we're waiting for Yii 2. Mainly, because Yii 1.x now has a short life span - and 2.x has been built with 5.3 in mind (unlike other major frameworks).

We don't have an alpha publicly available - but we're really eager to get started!Smile
Kind of off topic, but in another thread you said there will be an API. Will this API be built in the software? (hopefully) and also, if you have planned it already, how will it hook with the templates? Functions or a template style system like it is now? (like get_header(); or {header})
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23