SlideShare uma empresa Scribd logo
1 de 29
Yii Framework
Zakieh Alizadeh
zakiehalizadeh@gmail.com
APA Laboratory – Ferdowsi University of Mashhad
Chapter 1
Yii introduce
Yii introduce
 Yii is a high-performance component-based PHP framework for developing large-
scale Webapplications. It enables maximum reusability in Web programming and can
significantly accelerate the development process. The Yii framework is free software.
It is released under the terms of the BSD License.
 Yii (Yes it is) :-It is a PHP framework based on Object oriented php5.Developed by
Qiang Xue.who started to work on YII on 1st January 2008.Qiang Xue was with
experience in development of frameworks PRADO one of famous framework for PHP
was also developed by Qiang Xue.
 It is said that YII framework is best because it is based on DRY(Don't repeat
yourself)design pattern that is why is is called fast application development
framework.
Features of Yii
Features of Yii
 Model-View-Controller (MVC) design pattern
 Database Access Objects (DAO), Query Builder, Active Record
 Form input and validation
 AJAX-enabled widgets
 Authentication and authorization
 Skinning and theming
 Web services
 Internationalization (I18N) and localization (L10N)
Features of Yii
 Features of Yii
 Layered caching scheme
 Error handling and logging
 Security
 Unit and functionality testing
 Automatic code generation
 Friendly with third-party code
 Detailed documentation
 Extension library
Features of Yii
 Object-Oriented Framework
 Yii is a pure OOP framework.
 Component-base Framework
 Its component-based design allows us to customize it for our needs without directly
modifying it -- maintaining upgradability.
 Yii applications are built upon components which are objects written to a specification
 Yii base on PHP5
 Yii is a PHP framework based on Object oriented php5.
 It Uses some class such as finfo class.
 Yii is clearly-documented
 Yii web site
 Yii forum
 Yii books
Features of Yii
 Performance of Yii
 Yii is a high-performance framework. The graph below shows how efficient Yii is when compared
with other popular PHP frameworks. In the graph,
 RPS : "request per second”
 APC : The Alternative PHP Cache (APC) is a free and open opcode cache for PHP.
Features of Yii
 Model-View-Controller (MVC) design pattern
 Model
o A model is an instance of its child class. Models are used to keep data and
their relevant business rules. A model represents a single data object. It could
be a row in a database table or a form of user inputs.
 View
o A view is a PHP script consisting of mainly elements of user interface the
spirit of seperation of logic and presentation, large chunk of logic should be
placed in controller or model instead of view.
 Controller
o This controller pattern creates applications that separate the different aspects
of the application (input logic, business logic, and UI logic), while providing a
loose coupling between these elements.
Example of MVC
Model:
Public username;
Public pass;
Public email;
……..
Public function Validate (username);
Public function Validate (password);
Public function login(user,pass);
Controller:
Public layout;
Public email;
……..
Public function actionLogin();
Public function render();
Public function actionChangePass();
………..
see
Validate?
IsLogin?
…..
DB
Features of Yii
 Object-relational mapping (ORM,O/R mapping)
 Object-relational mapping in computer software is a programming technique for converting data between
incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual
object database " that can be used from within the programming language.
Example of ORM
CRUD Functions:
Create();
Reade();
Update();
Delete();
……….
findById();
findAllByAttribute();
Attribute of
objest
Object Person :
Non-object-oriented System
Features of Yii
 Active Record
 Active Record (AR) is a popular Object-Relational Mapping (ORM) technique. Each AR class
represents a database table (or view) whose attributes are represented as the AR class
properties, and an AR instance represents a row in that table. Common CRUD operations
are implemented as AR methods. As a result, we can access our data in a more object-
oriented way.(example exist in p:13)
table attributes
AR ClassDatabase Table
AR class properties
row in that table AR Instance
CRUD operations AR Methods
Map
Map
Map
Map
Features of Yii
 built-in authentication
 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 has a built-in authentication framework which is easy to use and can be customized for
special needs
 built-in authorization
 Authorization is finding out if the person, once identified, is permitted to manipulate specific
resources. This is usually determined by finding out if that person is of a particular role that has
access to the resources.
 Yii supports authorization via hierarchical role-based access control (RBAC). In computer
systems security,RBAC is an approach to restricting system access to authorized users.
Features of Yii
RBAC Hierarchical RBAC of Yii
Features of Yii
 Layered caching scheme
 Yii supports data caching, page caching, fragment caching and dynamic content.
 Error handling and logging
 Errors are handled and presented more nicely, and log messages can be categorized,
filtered and routed to different destinations.
Features of Yii
 Test-driven development
 Test-driven development (TDD) is a software development process that relies on the repetition of a very
short development cycle: first the developer writes an (initially failing) automated test case that defines a
desired improvement or new function, then produces the minimum amount of code to pass that test, and
finally refactorsthe new code to acceptable standards.
 Yii provides support for writing and running unit tests as well as functionality tests, based on PHPUnit and
Selenium
Features of Yii
 Automatic code generation
 GiiModule is a module that provides Web-based code generation capabilities.
 Security
 Yii is equipped with many security measures to help prevent your Web applications from attacks such as
SQL injection, cross-site scripting (XSS), cross-site request forgery (CSRF), and cookie tampering.
 Friendly with third-party code
 Yii is carefully designed to work well with third-party code. For example, you can use code from PEAR or
Zend Framework in your Yii application
 Extension library
 Yii provides an extension library consisting of user-contributed components. This makes the above feature
list never ending.
Features of Yii
 Skinning and theming
o Yii implements a skinning and theming mechanism that allows you to quickly switch the outlook of a Yii-power
website
 AJAX-enabled widgets
o Integrated with jQuery, Yii comes with a set of AJAX-enabled widgets, such as auto-complete input field,
treeview, data grid, which enables writing highly efficient and versatile user interface extremely simple
 Internationalization (I18N) and localization (L10N)
o Yii supports message translation, date and time formatting, number formatting, and interface localization.
Recommended software and sites
 NetBeans + (enable xdebuge)
 WAMP server
 Firefox + Firebug extension + HTML validator extension
 Icons (iconfinder, iconarchive)
 MySQL Workbench
 Yii Site
Getting Started
 Installing Yii
o Requirment
o Install
 Creating a new application
 Conventions
o URL
o Code
o File
o Configuration
Getting Started
The following screenshot shows the results we see for
our configuration:
Getting Started
 Installing Yii
1. Download the Yii Framework from http://www.yiiframework.com/ download/.
2. Unpack the downloaded file to a web-accessible folder.
3. Open windows CMD
4. Change to your WebRoot folder and execute the following:
o %Cd Webroot (for example : cd c:wampwww)
o %YiiRoot/framework/yiic webapp demo
• YiiRoot is the folder where you have installed Yii
• • WebRoot is configured as the document root of your web server (www in wamp and new web application
will create this place)
c:wampwww>c:wampwwwyiiframeworkyiic webapp test
WebRoot YiiRoot New Application name
Getting Started
 If you useing wamp/xamp server, Might face the following error:
 For fix it:
 go yiiroot/framework/yiic.bat and edit
PHP_COMMAND=php.exe
Replace with:
Wamp:
PHP_COMMAND=C:wampbinphpphp5.3.13php.exe
Xamp:
PHP_COMMAND=C:wampphpphp.exe
Getting Started
 The directory structure of the Yii site
Conventions
 URL
 The r GET variable refers to the route that can be resolved by Yii into controller and action. If
ActionID is omitted, the controller will take the default action (defined via
CController::defaultAction); and if ControllerID is also omitted (or the r variable is absent), the
application will use the default controller (defined via CWebApplication::defaultController).
o http://hostname/index.php?r=ControllerID/ActionID
 Code
 Class Name : all Yii framework classes are prefixed with letter "C“.
 Controller Name : A special rule for controller class names is that they must be appended with the
word Controller. For example, the PageController class will have the ID page.
 Action Name : A functions in controller class that do actions , must be appended with the word
action. For example, actionIndex().
o Notice : Linux is case sensitive.
o for example : FileManagerController=fileManagerController ≠ filemanagerController
Conventions
 Configuration
 A configuration is an array of key-value pairs. Each key represents the name of a property of the object to be
configured, and each value the corresponding property's initial value. For example, array('name'=>'My application',
'basePath'=>'./protected„)
 Any writable properties of an object can be configured. If not configured, the properties will take their default values.
When configuring a property, it is worthwhile to read the corresponding documentation so that the initial value can be
given properly
 File
 Conventions for naming and using files depend on their types:
o Class files:Class files should be named after the public class they contain. For example, the CController class is in
the CController.php file. A public class is a class that may be used by any other classes. Each class file should
contain at most one public class. Private classes may reside in the same file with the public class.
o View file : View files should be named after the view name. For example, the index view is in the index.php file. A
view file is a PHP script file that contains HTML and PHP code mainly for presentational purpose.
o Configuration file : Configuration files can be named arbitrarily. A configuration file is a PHP script whose sole
purpose is to return an associative array representing the configuration.
Conventions
 Directory
 WebRoot/protected: this is the application base directory holding all security-sensitive PHP scripts and data
files. Yii has a default alias named application associated with this path. It can be customized via
CWebApplication::basePath.
 WebRoot/protected/runtime: this directory holds private temporary files generated during runtime of the
application. It can be customized via CApplication::runtimePath.
 WebRoot/protected/extensions: this directory holds all third-party extensions. It can be customized via
CApplication::extensionPath.
 WebRoot/protected/modules: this directory holds all application modules, each represented as a subdirectory.
 WebRoot/protected/controllers: this directory holds all controller class files. It can be customized via
CWebApplication::controllerPath.
 WebRoot/protected/views: this directory holds all view files, including controller views, layout views and
system views. It can be customized via CWebApplication::viewPath.
Conventions
 Directory
 WebRoot/protected/views/ControllerID: this directory holds view files for a single controller class. Here
ControllerID stands for the ID of the controller. It can be customized via CController::viewPath.
 WebRoot/protected/views/layouts: this directory holds all layout view files. It can be customized via
CWebApplication::layoutPath.
 WebRoot/protected/views/system: this directory holds all system view files. System views are templates used
in displaying exceptions and errors. It can be customized via CWebApplication::systemViewPath.
 WebRoot/assets: this directory holds published asset files. An asset file is a private file that may be published
to become accessible to Web users. This directory must be writable by Web server process. It can be
customized via CAssetManager::basePath.
 WebRoot/themes: this directory holds various themes that can be applied to the application. Each subdirectory
represents a single theme whose name is the subdirectory name. It can be customized via
CThemeManager::basePath.
Yii Introduction

Mais conteúdo relacionado

Destaque

YiiConf 2012 - Alexander Makarov - Yii2, what's new
YiiConf 2012 - Alexander Makarov - Yii2, what's newYiiConf 2012 - Alexander Makarov - Yii2, what's new
YiiConf 2012 - Alexander Makarov - Yii2, what's newAlexander Makarov
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in YiiIlPeach
 
1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.
1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.
1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.Bicol IT.org
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedAlexander Makarov
 
A site in 15 minutes with yii
A site in 15 minutes with yiiA site in 15 minutes with yii
A site in 15 minutes with yiiAndy Kelk
 
Introduction Yii Framework
Introduction Yii FrameworkIntroduction Yii Framework
Introduction Yii FrameworkTuan Nguyen
 

Destaque (12)

Yii Introduction
Yii IntroductionYii Introduction
Yii Introduction
 
YiiConf 2012 - Alexander Makarov - Yii2, what's new
YiiConf 2012 - Alexander Makarov - Yii2, what's newYiiConf 2012 - Alexander Makarov - Yii2, what's new
YiiConf 2012 - Alexander Makarov - Yii2, what's new
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in Yii
 
1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.
1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.
1ST TECH TALK: "Yii : The MVC framework" by Benedicto B. Balilo Jr.
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developed
 
Yii workshop
Yii workshopYii workshop
Yii workshop
 
A site in 15 minutes with yii
A site in 15 minutes with yiiA site in 15 minutes with yii
A site in 15 minutes with yii
 
Yii framework
Yii frameworkYii framework
Yii framework
 
yii framework
yii frameworkyii framework
yii framework
 
Yii framework
Yii frameworkYii framework
Yii framework
 
Introduction Yii Framework
Introduction Yii FrameworkIntroduction Yii Framework
Introduction Yii Framework
 
Yii Framework
Yii FrameworkYii Framework
Yii Framework
 

Semelhante a Introduce Yii

Introduction to YII framework
Introduction to YII frameworkIntroduction to YII framework
Introduction to YII frameworkNaincy Gupta
 
Yii Framework Security
Yii Framework SecurityYii Framework Security
Yii Framework SecurityIlko Kacharov
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterKHALID C
 
10 reasons to choose the yii framework
10 reasons to choose the yii framework10 reasons to choose the yii framework
10 reasons to choose the yii frameworkjananya213
 
Hibernate reference1
Hibernate reference1Hibernate reference1
Hibernate reference1chandra mouli
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview QuestionsSyed Shahul
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGiuliano Iacobelli
 
Hibernate interview questions
Hibernate interview questionsHibernate interview questions
Hibernate interview questionsvenkata52
 
Yii web application development company
Yii web application development companyYii web application development company
Yii web application development companyEnuke Software Pvt Ltd
 
Php Frameworks
Php FrameworksPhp Frameworks
Php FrameworksRyan Davis
 
Why choose Yii framework?
Why choose Yii framework?Why choose Yii framework?
Why choose Yii framework?goodcore
 

Semelhante a Introduce Yii (20)

Fwdtechseminars
FwdtechseminarsFwdtechseminars
Fwdtechseminars
 
Yii php framework_honey
Yii php framework_honeyYii php framework_honey
Yii php framework_honey
 
Yii2
Yii2Yii2
Yii2
 
Introduction to YII framework
Introduction to YII frameworkIntroduction to YII framework
Introduction to YII framework
 
P H P Framework
P H P  FrameworkP H P  Framework
P H P Framework
 
Yii framework
Yii frameworkYii framework
Yii framework
 
CODE IGNITER
CODE IGNITERCODE IGNITER
CODE IGNITER
 
Yii Framework Security
Yii Framework SecurityYii Framework Security
Yii Framework Security
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniter
 
Php Web Frameworks
Php Web FrameworksPhp Web Frameworks
Php Web Frameworks
 
10 reasons to choose the yii framework
10 reasons to choose the yii framework10 reasons to choose the yii framework
10 reasons to choose the yii framework
 
Hibernate reference1
Hibernate reference1Hibernate reference1
Hibernate reference1
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview Questions
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
 
Hibernate interview questions
Hibernate interview questionsHibernate interview questions
Hibernate interview questions
 
Yii web application development company
Yii web application development companyYii web application development company
Yii web application development company
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Php Frameworks
Php FrameworksPhp Frameworks
Php Frameworks
 
Why choose Yii framework?
Why choose Yii framework?Why choose Yii framework?
Why choose Yii framework?
 
Introducing symfony
Introducing symfonyIntroducing symfony
Introducing symfony
 

Mais de zakieh alizadeh

Session11-NoSQL InjectionPHP Injection
Session11-NoSQL InjectionPHP Injection Session11-NoSQL InjectionPHP Injection
Session11-NoSQL InjectionPHP Injection zakieh alizadeh
 
Session10-PHP Misconfiguration
Session10-PHP MisconfigurationSession10-PHP Misconfiguration
Session10-PHP Misconfigurationzakieh alizadeh
 
Session9-File Upload Security
Session9-File Upload SecuritySession9-File Upload Security
Session9-File Upload Securityzakieh alizadeh
 
Session6-Protecct Sensetive Data
Session6-Protecct Sensetive DataSession6-Protecct Sensetive Data
Session6-Protecct Sensetive Datazakieh alizadeh
 
Session3 data-validation-sql injection
Session3 data-validation-sql injectionSession3 data-validation-sql injection
Session3 data-validation-sql injectionzakieh alizadeh
 
Session2-Application Threat Modeling
Session2-Application Threat ModelingSession2-Application Threat Modeling
Session2-Application Threat Modelingzakieh alizadeh
 
Session1-Introduce Http-HTTP Security headers
Session1-Introduce Http-HTTP Security headers Session1-Introduce Http-HTTP Security headers
Session1-Introduce Http-HTTP Security headers zakieh alizadeh
 
Validating and Sanitizing User Data
Validating and Sanitizing  User DataValidating and Sanitizing  User Data
Validating and Sanitizing User Datazakieh alizadeh
 
Session3 data-validation
Session3 data-validationSession3 data-validation
Session3 data-validationzakieh alizadeh
 

Mais de zakieh alizadeh (15)

Session11-NoSQL InjectionPHP Injection
Session11-NoSQL InjectionPHP Injection Session11-NoSQL InjectionPHP Injection
Session11-NoSQL InjectionPHP Injection
 
Session10-PHP Misconfiguration
Session10-PHP MisconfigurationSession10-PHP Misconfiguration
Session10-PHP Misconfiguration
 
Session9-File Upload Security
Session9-File Upload SecuritySession9-File Upload Security
Session9-File Upload Security
 
S8-Session Managment
S8-Session ManagmentS8-Session Managment
S8-Session Managment
 
Session7-XSS & CSRF
Session7-XSS & CSRFSession7-XSS & CSRF
Session7-XSS & CSRF
 
Session6-Protecct Sensetive Data
Session6-Protecct Sensetive DataSession6-Protecct Sensetive Data
Session6-Protecct Sensetive Data
 
S5-Authorization
S5-AuthorizationS5-Authorization
S5-Authorization
 
Session4-Authentication
Session4-AuthenticationSession4-Authentication
Session4-Authentication
 
Session3 data-validation-sql injection
Session3 data-validation-sql injectionSession3 data-validation-sql injection
Session3 data-validation-sql injection
 
Session2-Application Threat Modeling
Session2-Application Threat ModelingSession2-Application Threat Modeling
Session2-Application Threat Modeling
 
Session1-Introduce Http-HTTP Security headers
Session1-Introduce Http-HTTP Security headers Session1-Introduce Http-HTTP Security headers
Session1-Introduce Http-HTTP Security headers
 
yii framework
yii frameworkyii framework
yii framework
 
Web security Contents
Web security ContentsWeb security Contents
Web security Contents
 
Validating and Sanitizing User Data
Validating and Sanitizing  User DataValidating and Sanitizing  User Data
Validating and Sanitizing User Data
 
Session3 data-validation
Session3 data-validationSession3 data-validation
Session3 data-validation
 

Último

How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 

Último (20)

How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 

Introduce Yii

  • 1. Yii Framework Zakieh Alizadeh zakiehalizadeh@gmail.com APA Laboratory – Ferdowsi University of Mashhad
  • 3. Yii introduce  Yii is a high-performance component-based PHP framework for developing large- scale Webapplications. It enables maximum reusability in Web programming and can significantly accelerate the development process. The Yii framework is free software. It is released under the terms of the BSD License.  Yii (Yes it is) :-It is a PHP framework based on Object oriented php5.Developed by Qiang Xue.who started to work on YII on 1st January 2008.Qiang Xue was with experience in development of frameworks PRADO one of famous framework for PHP was also developed by Qiang Xue.  It is said that YII framework is best because it is based on DRY(Don't repeat yourself)design pattern that is why is is called fast application development framework.
  • 4. Features of Yii Features of Yii  Model-View-Controller (MVC) design pattern  Database Access Objects (DAO), Query Builder, Active Record  Form input and validation  AJAX-enabled widgets  Authentication and authorization  Skinning and theming  Web services  Internationalization (I18N) and localization (L10N)
  • 5. Features of Yii  Features of Yii  Layered caching scheme  Error handling and logging  Security  Unit and functionality testing  Automatic code generation  Friendly with third-party code  Detailed documentation  Extension library
  • 6. Features of Yii  Object-Oriented Framework  Yii is a pure OOP framework.  Component-base Framework  Its component-based design allows us to customize it for our needs without directly modifying it -- maintaining upgradability.  Yii applications are built upon components which are objects written to a specification  Yii base on PHP5  Yii is a PHP framework based on Object oriented php5.  It Uses some class such as finfo class.  Yii is clearly-documented  Yii web site  Yii forum  Yii books
  • 7. Features of Yii  Performance of Yii  Yii is a high-performance framework. The graph below shows how efficient Yii is when compared with other popular PHP frameworks. In the graph,  RPS : "request per second”  APC : The Alternative PHP Cache (APC) is a free and open opcode cache for PHP.
  • 8. Features of Yii  Model-View-Controller (MVC) design pattern  Model o A model is an instance of its child class. Models are used to keep data and their relevant business rules. A model represents a single data object. It could be a row in a database table or a form of user inputs.  View o A view is a PHP script consisting of mainly elements of user interface the spirit of seperation of logic and presentation, large chunk of logic should be placed in controller or model instead of view.  Controller o This controller pattern creates applications that separate the different aspects of the application (input logic, business logic, and UI logic), while providing a loose coupling between these elements.
  • 9. Example of MVC Model: Public username; Public pass; Public email; …….. Public function Validate (username); Public function Validate (password); Public function login(user,pass); Controller: Public layout; Public email; …….. Public function actionLogin(); Public function render(); Public function actionChangePass(); ……….. see Validate? IsLogin? ….. DB
  • 10. Features of Yii  Object-relational mapping (ORM,O/R mapping)  Object-relational mapping in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database " that can be used from within the programming language.
  • 11. Example of ORM CRUD Functions: Create(); Reade(); Update(); Delete(); ………. findById(); findAllByAttribute(); Attribute of objest Object Person : Non-object-oriented System
  • 12. Features of Yii  Active Record  Active Record (AR) is a popular Object-Relational Mapping (ORM) technique. Each AR class represents a database table (or view) whose attributes are represented as the AR class properties, and an AR instance represents a row in that table. Common CRUD operations are implemented as AR methods. As a result, we can access our data in a more object- oriented way.(example exist in p:13) table attributes AR ClassDatabase Table AR class properties row in that table AR Instance CRUD operations AR Methods Map Map Map Map
  • 13. Features of Yii  built-in authentication  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 has a built-in authentication framework which is easy to use and can be customized for special needs  built-in authorization  Authorization is finding out if the person, once identified, is permitted to manipulate specific resources. This is usually determined by finding out if that person is of a particular role that has access to the resources.  Yii supports authorization via hierarchical role-based access control (RBAC). In computer systems security,RBAC is an approach to restricting system access to authorized users.
  • 14. Features of Yii RBAC Hierarchical RBAC of Yii
  • 15. Features of Yii  Layered caching scheme  Yii supports data caching, page caching, fragment caching and dynamic content.  Error handling and logging  Errors are handled and presented more nicely, and log messages can be categorized, filtered and routed to different destinations.
  • 16. Features of Yii  Test-driven development  Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactorsthe new code to acceptable standards.  Yii provides support for writing and running unit tests as well as functionality tests, based on PHPUnit and Selenium
  • 17. Features of Yii  Automatic code generation  GiiModule is a module that provides Web-based code generation capabilities.  Security  Yii is equipped with many security measures to help prevent your Web applications from attacks such as SQL injection, cross-site scripting (XSS), cross-site request forgery (CSRF), and cookie tampering.  Friendly with third-party code  Yii is carefully designed to work well with third-party code. For example, you can use code from PEAR or Zend Framework in your Yii application  Extension library  Yii provides an extension library consisting of user-contributed components. This makes the above feature list never ending.
  • 18. Features of Yii  Skinning and theming o Yii implements a skinning and theming mechanism that allows you to quickly switch the outlook of a Yii-power website  AJAX-enabled widgets o Integrated with jQuery, Yii comes with a set of AJAX-enabled widgets, such as auto-complete input field, treeview, data grid, which enables writing highly efficient and versatile user interface extremely simple  Internationalization (I18N) and localization (L10N) o Yii supports message translation, date and time formatting, number formatting, and interface localization.
  • 19. Recommended software and sites  NetBeans + (enable xdebuge)  WAMP server  Firefox + Firebug extension + HTML validator extension  Icons (iconfinder, iconarchive)  MySQL Workbench  Yii Site
  • 20. Getting Started  Installing Yii o Requirment o Install  Creating a new application  Conventions o URL o Code o File o Configuration
  • 21. Getting Started The following screenshot shows the results we see for our configuration:
  • 22. Getting Started  Installing Yii 1. Download the Yii Framework from http://www.yiiframework.com/ download/. 2. Unpack the downloaded file to a web-accessible folder. 3. Open windows CMD 4. Change to your WebRoot folder and execute the following: o %Cd Webroot (for example : cd c:wampwww) o %YiiRoot/framework/yiic webapp demo • YiiRoot is the folder where you have installed Yii • • WebRoot is configured as the document root of your web server (www in wamp and new web application will create this place) c:wampwww>c:wampwwwyiiframeworkyiic webapp test WebRoot YiiRoot New Application name
  • 23. Getting Started  If you useing wamp/xamp server, Might face the following error:  For fix it:  go yiiroot/framework/yiic.bat and edit PHP_COMMAND=php.exe Replace with: Wamp: PHP_COMMAND=C:wampbinphpphp5.3.13php.exe Xamp: PHP_COMMAND=C:wampphpphp.exe
  • 24. Getting Started  The directory structure of the Yii site
  • 25. Conventions  URL  The r GET variable refers to the route that can be resolved by Yii into controller and action. If ActionID is omitted, the controller will take the default action (defined via CController::defaultAction); and if ControllerID is also omitted (or the r variable is absent), the application will use the default controller (defined via CWebApplication::defaultController). o http://hostname/index.php?r=ControllerID/ActionID  Code  Class Name : all Yii framework classes are prefixed with letter "C“.  Controller Name : A special rule for controller class names is that they must be appended with the word Controller. For example, the PageController class will have the ID page.  Action Name : A functions in controller class that do actions , must be appended with the word action. For example, actionIndex(). o Notice : Linux is case sensitive. o for example : FileManagerController=fileManagerController ≠ filemanagerController
  • 26. Conventions  Configuration  A configuration is an array of key-value pairs. Each key represents the name of a property of the object to be configured, and each value the corresponding property's initial value. For example, array('name'=>'My application', 'basePath'=>'./protected„)  Any writable properties of an object can be configured. If not configured, the properties will take their default values. When configuring a property, it is worthwhile to read the corresponding documentation so that the initial value can be given properly  File  Conventions for naming and using files depend on their types: o Class files:Class files should be named after the public class they contain. For example, the CController class is in the CController.php file. A public class is a class that may be used by any other classes. Each class file should contain at most one public class. Private classes may reside in the same file with the public class. o View file : View files should be named after the view name. For example, the index view is in the index.php file. A view file is a PHP script file that contains HTML and PHP code mainly for presentational purpose. o Configuration file : Configuration files can be named arbitrarily. A configuration file is a PHP script whose sole purpose is to return an associative array representing the configuration.
  • 27. Conventions  Directory  WebRoot/protected: this is the application base directory holding all security-sensitive PHP scripts and data files. Yii has a default alias named application associated with this path. It can be customized via CWebApplication::basePath.  WebRoot/protected/runtime: this directory holds private temporary files generated during runtime of the application. It can be customized via CApplication::runtimePath.  WebRoot/protected/extensions: this directory holds all third-party extensions. It can be customized via CApplication::extensionPath.  WebRoot/protected/modules: this directory holds all application modules, each represented as a subdirectory.  WebRoot/protected/controllers: this directory holds all controller class files. It can be customized via CWebApplication::controllerPath.  WebRoot/protected/views: this directory holds all view files, including controller views, layout views and system views. It can be customized via CWebApplication::viewPath.
  • 28. Conventions  Directory  WebRoot/protected/views/ControllerID: this directory holds view files for a single controller class. Here ControllerID stands for the ID of the controller. It can be customized via CController::viewPath.  WebRoot/protected/views/layouts: this directory holds all layout view files. It can be customized via CWebApplication::layoutPath.  WebRoot/protected/views/system: this directory holds all system view files. System views are templates used in displaying exceptions and errors. It can be customized via CWebApplication::systemViewPath.  WebRoot/assets: this directory holds published asset files. An asset file is a private file that may be published to become accessible to Web users. This directory must be writable by Web server process. It can be customized via CAssetManager::basePath.  WebRoot/themes: this directory holds various themes that can be applied to the application. Each subdirectory represents a single theme whose name is the subdirectory name. It can be customized via CThemeManager::basePath.