Is it really that easy?

Hi,

First of all m a n00b on this "yii territory" so pardon me if i get anything wrong, m hoping someone can respond me without an a RTFM.

So my simple question is…

-> What makes Yii "easy"?

Just finished the chapter two "fundamentals" of the "The definitive guide to Yii 1.1" and some basic coding with it and find the framework to be really complex rather than easy, i understand that maybe you want to really abstract lots of things from the developers which i guess you think is good but at least to me is awful since i feel that m loosing total control over my code m handing all the power over to yii.

Maybe is my previous experience with web-developing what is really getting between the real "yii experience" but at least as of this moment m see far more easier to work/learn with Code Igniter and Symfony than with yii.

The dependence of the yii and gii command line to make/start something useful scares me a little to be honest with all of you guys.

Hope this doesn’t start a flame war, m just asking why do you think this framework is easy as you say.

I understand that the Yii framework is very extensible and have a lots of optimizations mechanism integrated but i didn’t find it more easy, m kinda find it more difficult than any other framework available.

Regards

yeah… its pretty eaaaasy? :ph34r:

try to build your own freak blog to make you excited.

This comment is very abstract and has no context. Complex? Which part is complex? Abstract lot of thing? Please be specific?

Please give an example. All you are saying this is better than that, without any example or specific area.

Dependency? Dependency to what? To PHP version? to PEAR library? to what? gii command line? From what I understand gii is a web based tool.

Maybe you are not even familiar with the framework and start criticize the framework. That attitude is call ignorance.

I really want to use Yii but the guide doesn’t help

Please be more specific. Did you manage to run the requirement test and create a web application skeleton (with the command line tool yiic)? For more help see Installation and Setup section of the forum.

One thing that can be confusing in the new 1.1.2 release (and the updated guide) is that the web based code generators of Gii was introduced as the preferred way to generate models and crud code. Most of the posts on installation issues refers to the older yiic shell.

The yiic shell is still in the framework so that’s an alternate way to get started, see this section of the guide:

http://www.yiiframework.com/doc/guide/quickstart.first-app-yiic

(the page seems to be missing online but you can download the latest or previous documentation package for a pdf version of the guide.)

/Tommy

I would say Yii is not for the absolute beginner with PHP or web development in general. You should have some understanding of what’s going on and how to build a webapp with pure PHP. Also consider this note from the guide:

So a general advice would be: Learn more about PHP, MVC and OOP in general. If you have that IMO everything feels very natural. All objects are modelled to match real world scenarios pretty good.

My bad… the learning curve is complex rather than easy as the slogan says, this is what i ment.

Most of the power of Yii requires interaction with intermediary tools, i was expecting something more like “hey dude here are the libs, this is how we segment everything, this is were the modules go, so start to do your thing” and i found “go open the console type yii webapp newsite, configure this, configure that, move this, move that, call gii, put the password, configure this, configure that, wait for the magic and now you have a basic form with very limited CRUD functionality start do your thing but don’t touch anything or it will get screw just customize the theme, css and some put models and controllers”.

Did you get my point?

As i say in my first post, maybe m familiar/comfortable with just certain types of frameworks (like Code Igniter, Symfony or even Zend) and i just came here asking: why all you guys find easy with Yii?

What makes yii more easy to develop?

Cause to be honest as of this moment i can compare Yii somehow like a striped/just-libs version of Joomla with of course few improvements (especially in the performance area), as you say m not and expert in frameworks and maybe and a ignorant but i want to know from people with experience with yii: "why do you find easy Yii?" is it really worth to learn Yii? or maybe i should go looking for something better to use?

Regards

PS: Also why there is so short maintenance from different versions of Yii? one-year is really short time to offer.

I find Yii easy to use because it follows principles I’ve learned in school and form my won research. Our experiences with yii are quite different as I did not find the learning curve to be steep. In fact, I caught on rather quickly. Yii doc is coming along great but many times you will need to dive into the code or turn to the api doc. If you are afraid to do that, then at this moment, I don’t think Yii is the right tool for you. However, if you do not have a problem with that then I encourage you to use Yii, it is an exciting tool to build with.

"is it really worth to learn Yii?"

In my opinion, yes it is really worth it to use Yii. Getting a website up with Yii can be very quick if you have everything down as you really only need to write so much code for basic functionality. e.g. Creating a user management system can be done in minutes. What you don’t find in Yii, you can easily integrate eg. I needed email functionality for a recent app, Yii does not provide an interface for sending emails out of the box, this is how easy I implemented 1.

  1. I downloaded flourishlib http://flourishlib.com and extracted it alongside my copy of yii.

  2. I configured Yii to autoload flourish classes by doing this in protected/config/main.php




Yii::setPathOfAlias('flourishlib',dirname(dirname(YII_PATH)).DIRECTORY_SEPARATOR.'flourishlib');



then added the new alias ‘flourishlib’ to the import config




	'import'=>array(

                ...

		'flourishlib.classes.*',

                ...

	),



Then i wrapped the flourish fEmail class inside a custom ‘Application Component’




<?php

/**

 *

 */


class Mailer extends CApplicationComponent

{

	/**

	 *

	 */

	private $_mailerObj;

	

	/**

	 *

	 */

	private $_templatePath;

	 

	/**

	 *

	 */

	public function init()

	{

		parent::init();

		$this->_mailerObj = new fEmail();

	}

	

	/**

	 *

	 */

	public function setTemplatePath($path)

	{

		$this->_templatePath = $path;

	}

	

	/**

	 *

	 */

	public function getTemplatePath()

	{

		if($this->_templatePath === null)

		{

			$this->_templatePath = Yii::getPathOfAlias('application.components.mail.templates');

			

			if(($language = Yii::app()->language) !== Yii::app()->sourceLanguage)

				$this->_templatePath .= DIRECTORY_SEPARATOR.$language;

			$this->_templatePath .= DIRECTORY_SEPARATOR;

		}

		return $this->_templatePath;

	}		

	

	/**

	 * 

	 */

	public function __get($method)

	{

		return $this->_mailerObj->__get($method);

	}

	

	

	/**

	 * 

	 */

	public function addAttachment($filename, $mime_type, $contents)

	{

		$this->_mailerObj->addAttachment($filename, $mime_type, $contents);

	}

	

	

	/**

	 * 

	 */

	public function addBCCRecipient($email, $name = null)

	{

		$this->_mailerObj->addBCCRecipient($email, $name);

	}

	

	

	/**

	 * 

	 */

	public function addCCRecipient($email, $name = null)

	{

		$this->_mailerObj->addCCRecipient($email, $name);

	}

	

	

	/**

	 * 

	 */

	public function addRecipient($email, $name = null)

	{

		$this->_mailerObj->addRecipient($email, $name);

	}	

	

	/**

	 * 

	 */

	public function clearRecipients()

	{

		$this->_mailerObj->clearRecipients();

	}

	

	/**

	 * 

	 */

	public function encrypt($recipients_smime_cert_file)

	{

		$this->_mailerObj->encrypt($recipients_smime_cert_file);

	}

	

	

	/**

	 * 

	 */

	public function loadBody($file, $replacements = array())

	{

		$this->_mailerObj->loadBody($this->getTemplatePath().$file, $replacements);

	}

	

	

	/**

	 * 

	 */

	public function loadHTMLBody($file, $replacements = array())

	{

		$this->_mailerObj->loadHTMLBody($this->getTemplatePath().$file, $replacements);

	}	

	

	/**

	 * 

	 */

	public function send($connection = null)

	{

		$this->_mailerObj->send($connection);

	}

	

	

	/**

	 * 

	 */

	public function setBody($plaintext, $unindent_expand_constants = false)

	{

		$this->_mailerObj->setBody($plaintext, $unindent_expand_constants);

	}

	

	

	/**

	 * 

	 */

	public function setBounceToEmail($email)

	{

		$this->_mailerObj->setBounceToEmail($email);

	}

	

	

	/**

	 * 

	 */

	public function setFromEmail($email, $name = null)

	{

		$this->_mailerObj->setFromEmail($email, $name);

	}

	

	

	/**

	 * 

	 */

	public function setHTMLBody($html)

	{

		$this->_mailerObj->setHTMLBody($html);

	}

	

	

	/**

	 * 

	 */

	public function setReplyToEmail($email, $name = null)

	{

		$this->_mailerObj->setReplyToEmail($email, $name);

	}

	

	

	/**

	 * 

	 */

	public function setSenderEmail($email, $name = null)

	{

		$this->_mailerObj->setSenderEmail($email, $name);

	}

	

	

	/**

	 * 

	 */

	public function setSubject($subject)

	{

		$this->_mailerObj->setSubject($subject);

	}

	

	

	/**

	 * 

	 */

	public function sign($senders_smime_cert_file, $senders_smime_pk_file, $senders_smime_pk_password)

	{

		$this->_mailerObj->sign($senders_smime_cert_file, $senders_smime_pk_file, $senders_smime_pk_password);

	}

}



added it to the components config




		'mailer'=>array(

			'class'=>'application.components.mail.Mailer',

		),



Then sending an email is as easy as




$mailer = Yii::app()->mailer;

$mailer->addRecipient('person@domain.tld', 'Name');

$mailer->setFromEmail('me@mydomain.tld');

$mailer->setSubject('Subject');

$mailer->setBody('Body');

$mailer->send();



Because the devs are constantly making improvements in order to provide us with more secure code, and improve the performance of the framework.

PS: Why would you want to wait a whole year for security or performance updates?

I consider myself an experienced web developer and after years of using my own framework I decided to go with yii. Not a bad decision. But I also think that yii is not a framework to pick up easy…I didn’t have any problem bootstrapping my first app because I fully understand the MVC concept behind it (was previously using it in my framework) and when something wasn’t clear I dived in the lib’s code. But diving inside the code isn’t always an option for a newb. Hence the multitide of help questions in the forums - at least that’s how I perceive it.

I agree with NotSoEasy, while yii is a powerful framework it isn’t easy to pick up by a beginner developer.

Cheers,

-soso

Regarding the 1 year maitenance period. I didn’t know is that short! I also think it is a short period, especially regarding security. I don’t want to be forced every 1 year to upgrade to a new major version and learn the new API changes. As a company who’s developing large projects that span over years of development and maintenance I’d much rather look for stability and predictibility of libraries rather then change.

I agree with others who say Yii isn’t the ‘easiest’ framework to grasp, but don’t understand how you find it more difficult than Symfony which has one of the steeper learning curves!

After using CodeIgniter for about 12 months, Yii was a simple transition.

I find it much easier than Cake, Zend or Symfony myself so perhaps this is your first foray into frameworks?

Maybe you should learn the basics with CodeIgniter before progressing on to other frameworks?

The problem is not Yiiframework its the documentation. The Yii guide is imprecise and should be re-written…

Could you give some examples, please?

Yes, for example the installation isn’t very clear in Yii guide. Larry Ulman’s instructions are better but I can see that users are still having problems with installation. I feel that perhaps more screenshots are needed.

Perhaps the part on installing Gii needs to specify where to insert the code in the Config/Main file. I just pasted on the top of the Main file which works fine.

The chapter on active record is fine but needs more explanations and examples because the syntax only works with Yii. The syntax is not something that a new user could figure out on his own.

The second chapter on fundamentals of Yii. Why not give a small/short example on how MVC works when using Yii? The example will show a simple step by step workflow from how to install to how to deplay Yii. I know there are examples available but I don’t think the examples are very helpful for new users. I think more diagrams and screenshots will be helpful.

Dont get me wrong, i am not saying that the documenation is bad…I think it good and helpful but it can be better. I have worked with Yii for over 2 weeks now and my overall feeling of the guide is that its good but insufficient in some respects.

To answer your question, I believe the creators of YIi have done a great job in simplying alot of things. One of those things is accessing & retrieving data from the database. Unfortunately active record could be difficult for those who are not used to working with the object oriented db queries. But the pain of learning can be alleviated with more examples and explanations on the syntax.

The new feature called Gii is excellent, have you tried it?? It auto generates the code for you. Configuring and caching an Yii app is not difficult if you know where the correct files are and where to insert the code. I think this part may need more explanation & screenshots. Once you have grasped the basics, go to Special Topics to read the great features of YIi. Some of those features are not available in other php frameworks. HTH

When I started with Yii I was coming from PRADO and ASP.NET and did not know anything about how Yii worked. I read the fundamentals and got more questions. The cloud started to clear up when I studied the blog app.

Yii is extremely versatile and easy once you understand how it implements MVC and views.

Hello *,

I wasn’t saying that i will be waiting a hole year to enforce security or performance updates, just that anyone familiar here with freelance or well enterprise developing will understand that my point was about asking about the post-life-cycle of the framework policy will-be, will after that maintenance perioid (december 31/2011 as of the moment) will be a just security or major bugs life-cycle policy or it will just EOL and you must go up to the next version hoping that the next-version doesn’t break your app or a core functionality gets removed?.

Thank you both and as say from Gevik, i guess that the people coming from a ASP.NET and of course a PRADO background will really easy pickup Yii since Yii is an a idea/framework developed by the same author of PRADO and of course their goal was to implement some ideas from ASP.NET and other software houses to PHP.

M not blaming the author background of Yii m just saying that maybe Yii is the natural successor of Prado and of course another solution to bring people from the dark-side of the force (xD) to open-source solutions like PHP.

Yeah is serious problem to consider before adopting Yii for any project, since some clients and enterprises doesn’t invest time or resources in drastically making changes to their platforms in at least a 2 to 5 years period.

Agreed but even that is really a more complex and sometimes repetitive task framework it has a more familiar workflow than Yii and that is taking at least to me some time to understand.

I Came from a background of developing with Code Igniter and Symfony and yet still find some troubles with fully understanding it at is maximum expression, maybe need at least a couple of months of learning before actually seeing something really worth to begin in thinking in make that "simple" transition.

Maybe the performance is kinda worth it but since i don’t fully understand Yii, came here and ask to all developers of Yii, what makes Yii easy, what really makes yii a really worth to use?

That could be a time-saver while learning and agree that the documentation should at least provide some more complex examples besides the typical blog application which doesn’t actually shows the full-power behind it.

Thanks for the advice m actually right now reading the authentication section.

My intention is not to start a flamewar neither try to be a troll just came here hoping that someone really helps me understand why is it really taking me time to understand it and start questioning if it is really that easy or it just being a marketing-related slogan to attract more developers?

Regards

For me, Yii makes it easy to create custom web-apps. I have used Joomla!, Zend framework, a plethora of other small CMS systems and good ol’ straight PHP. Yii (especially the scaffolding) makes it extremely fast to get an application up and running in a basic form (hours instead of days in complex cases), and then gives me the tools to extend that application with ease.

Simply put, Yii frees me from the drudgery of writing the models, controllers and basic views, as well as the minutae of SQL queries, forms, etc. It follows a true MVC convention (unlike Joomla - ugh!), and is extremely flexible and extensible. Writing portlets/widgets (modules in Joomla-speak) is intuituve. Inclusion of jQuery and readily accessible AJAX syntax, as well as the built in validations make it simple to create very pretty, functional applications.

The directory structure is logical. The application flow makes sense. To me, Yii is the framework I yearned for - without knowing what I needed - as I became a more proficient PHP/SQL developer.

If you are not familiar with PHP and SQL, Yii will seem difficult to use, or non-intuitive. However, once you know what has to be done to interact with a database and user input with PHP, Yii makes all that stuff automatic (while still easily customisable) freeing you to think about the larger picture of the application you are creating.

In comparison, Joomla! (which is not a framework, I know) was often very difficult to write custom code for. I often found myself installing something like Jumi and then writing custom scripts in straight PHP.

A word on security: I’m not afraid of that, even with a short maintenance period of 1 year. We ain’t talking about rocket science here, but a well written framwork in pure PHP. If you use Yii in a larger project, you will (or should!) have some experienced PHP coders involved and not solely rely on a framework without understanding the internals.

Even PHP programmers with mediocre experience should be able to understand pretty much every piece of the framework, given enough time. So should there be a security issue after the maintenance - you should be able to fix it yourself. Otherwhise i’d tend to advise: change your development team ;)

Given enough time…I would write my own framework ;).

You’re missing the point, I want to be able to focus most of my time & money on development of my projects. Taking care of another application (yii) many times is not an option.