background preloader

Yii - Tutorial

Facebook Twitter

Create facebook application using php - Yii Framework and Graph API. Recently we developed an facebook application and during the development of application, we encounter lots of issues due to vague Facebook documentation.

Create facebook application using php - Yii Framework and Graph API

We wanted to share our experience so that other developers can develop facebook application easily. We have used yii framework for this application as its pretty cool framework and application development on this framework takes less time without compromising the performance.In this article, we assume that the reader have experience in facebook application development. A little introduction about yii framework Yii is a high-performance PHP framework best for developing Web 2.0 applications. Yii comes with rich features: MVC, DAO/ActiveRecord, I18N/L10N, caching, authentication and role-based access control, scaffolding, testing, etc.

A little introduction about facebook Graph API Facebook introduced new components of Facebook Platform and one of them is Graph API. Yiimailer. Yii extension for sending HTML emails with layouts using PHPMailer What's new ¶ v1.5 ¶ Calling render() is not necessary when sending emailsNew methods : setFrom(), setTo(), setSubject(), setBody(), setAttachment()...testMode for saving emails as eml filesNew ways to send simple messages without layout or view, or with just layout without the viewUpdated PHPMailer to 5.2.6 Extension should be compatible with code used with previous versions Features ¶

yiimailer

Extension. Auth is a new module from the creator of the popular Rights module for managing user permissions in Yii applications.

Extension

It's a completely new, modern and responsive user interface for Yii's authorization manager (CAuthManager) built using the also popular Bootstrap extension. Auth is NOT a new version of Rights, even though those familiar with Rights might feel at home using it. Extension. Small Yii extension, that wraps a few PHP libraries (mPDF and HTML2PDF) to convert HTML to PDF Yii-PDF Extension Small Yii extension, that wraps a few PHP libraries (mPDF and HTML2PDF so far) to convert HTML to PDF.

Extension

Extension. Force a User to Change Their Password (ChangePasswordFilter) Sometimes you need to force a user to change their password after x number of days.

Force a User to Change Their Password (ChangePasswordFilter)

This article describes how to implement this using a filter, ChangePasswordFilter. Why can't I use afterLogin()? Sure, you could redirect a user to a change password form after they login, but there's no mechanism to keep the user on the change password form. I.e. they could easily browse to another page. The Password Filter Class. The Password Rule Class. Yii. New updates to yasSlide, a jQuery plugin that creates a slideshow in the background of a DIV.

Yii

Fully responsive and can change images on change of orientation [more...] A neat little JQuery slider to convert Kgs -> Stone -> Lbs The Code:- Kgs: Lbs: Stone: / <---------------- Slide It -----------------> [more...] If you're like me and like the bash interface on linux then here is a really quick and easy way to replace the windows shell with a linux based bash interface [more...] I just read a very interesting article on how to boost and maintain your Google Page Rank in which it discussed the merits of link building.

Sending email in yiiframework using yii-mail extensions. Sending email in a website is one of the main function to have interaction with the users and one of main features of the website.

Sending email in yiiframework using yii-mail extensions

For yii users maybe ever had error when sending the emails in the localhost with some kinds of warning. The error maybe like this : It has caused because in the localhost there is no mail server so you can even send email. To solve this issue you must install mail server in your local computer such as hMailServer. Or if you want to use the mail server from your provider you can use the SMTP configuration email from the provider.

CWebUser. Look up a class, method, property or event CWebUser represents the persistent state for a Web application user.

CWebUser

CWebUser is used as an application component whose ID is 'user'. Therefore, at any place one can access the user state via Yii::app()->user. CWebUser should be used together with an identity which implements the actual authentication algorithm. A typical authentication process using CWebUser is as follows: The user provides information needed for authentication.An identity instance is created with the user-provided information.Call IUserIdentity::authenticate to check if the identity is valid.If valid, call CWebUser::login to login the user, and Redirect the user browser to returnUrl.If not valid, retrieve the error code or message from the identity instance and display it. The property id and name are both identifiers for the user. Both id and name are persistent during the user session. Public Properties Hide inherited properties. Wiki. How to learn Yii?! Here is a step by step To-Do list for Yii beginners.

How to learn Yii?!

The list is an advice of what tutorials and documentation you can walk through to get a full understanding of the Yii Framework. These can be a help to learn Yii. Learn PHP You need to know how to program in PHP. You can find many tutorials on the web, or buy a book. If you'd like a book, I recommend Larry Ullman's books. Easy introduction Visual explanation is the best! Yii – PHP Coding Standards (draft) Best Practice to set constant in Yii. I don't know if it is 'Best Practice' but you can just set global variables in the controller component.

Best Practice to set constant in Yii

Since most of your controllers extend this class you have access to the variables. Example - (note that Yii uses this approach by default) Then you can access these globals like so // in controller or view$this->description = "some text here";// pull it from a database$this->description = SomeModel::model()->findByPk($id)->description;// do something with itecho $this->description; For things that won't ever change setting them in the main config file under 'params' allows you to access the value using. Custom Authentication using the Yii Framework. In a previous post, I walk through the Yii framework’s built-in authentication system for adding login functionality to a Web site.

There are a number of files and components involved, but simple authentication works fine out of the box, or with just a little tweaking. That’s the focus of that previous post. In this post, I explain how you can customize the authentication process further.The default authentication behavior allows users to login with hardcoded username/password combinations. In this post, I want to change that behavior so that: Simple access control. For those who feel, the Controller->accessRules() or RBAC (Role-Based Access Control) is too complicated or doesn't want the username(s) to be hard-coded in accessRules(), here is a very simple, easy-to-implement solution. Considerations ¶ As usual, you will have a table, holding the user's data, such as: username, password, email, real_name, etc. To store the user rights, you need an additional field, named admin_level. This will be an unsigned tinyint, and will hold the user's rights to do things around the site.

You will define the admin levels, according to your needs. Implementation ¶ Mvc - Yii urlmanager crazy rules. CHtml. Look up a class, method, property or event CHtml is a static class that provides a collection of helper methods for creating HTML views. Property Details public static string $afterRequiredLabel; the HTML code to be appended to the required label. public static string $beforeRequiredLabel; the HTML code to be prepended to the required label. public static boolean $closeSingleTags; whether to close single tags. Public static integer $count; the counter for generating automatic input field names. public static string $errorContainerTag; the tag name for the error container tag. Public static string $errorCss; the CSS class for highlighting error inputs. Special Topics: Authentication and Authorization.

Authentication and authorization are required for a Web page that should be limited to certain users. Authentication is about verifying whether someone is who they claim to be. It usually involves a username and a password, but may include any other methods of demonstrating identity, such as a smart card, fingerprints, etc. Yii-shop - Webshop for the Yii Framework.

Bare bone codes to create a user session in Yii. How to write secure Yii applications. Warning: While this security guide tries to be quite complete, is not exhaustive. If security matters for you, you ought to check several other references. General principles ¶ Validate the user input (see below for details).Protect (escape) your application output according to context (see below for a few output types, mostly HTML and SQL).Test your application in debug mode. Set the constant YII_DEBUG to true (by default, it is defined in index.php) and put alongside error_reporting(E_ALL);. Then errors and warnings will stop the execution and Yii will display the message, the source code and the call stack. Validating the user input ¶ WayToBlogger. Getting everything Yii application offers without creating one. Understanding Scenarios. Scenarios are an extremely useful tool for separating validation tasks on any class you use derived from CModel.

In this tutorial we will use CActiveRecord.