php indonesia meetup - what's new in yii2 and php5.5

Post on 10-May-2015

9.426 Views

Category:

Technology

4 Downloads

Preview:

Click to see full reader

DESCRIPTION

My presentation at PHP Indonesia Iftar event, July 20th 2013 at Microsoft Indonesia HQ. The presentation is about several new features for the upcoming Yii2 and the newly released PHP5.5. Video can be accessed here: http://www.youtube.com/watch?v=dZpn34rmtzk

TRANSCRIPT

What's New InWhat's New In

Yii2 & PHP5.5Yii2 & PHP5.5

Petra Novandi BarusChief Technology Officer

UrbanIndo.com

PHP Indonesia MeetupPHP Indonesia Meetup

Who Am IWho Am I

● 2009 Graduated from Informatics Eng. ITB– Activities: OS and Internet programming lecture assistant, table

tennis unit, etc.

● 2011 Graduated from Master Informatics Eng. ITB– Specialize in distributed systems and parallel programming

● 2011 Recruited as CTO for UrbanIndo.com

Contact Me:- mail: petra@urbanindo.com- twitter: @petrabarus- linkedin: http://linkedin.com/in/petrabarus

UrbanIndoUrbanIndo● A real-estate marketplace for Indonesia: house, land,

apartment, commercial, room.

● Board members consist of professionals from Silicon Valley: Apple, Google, Yahoo.

● Launched November 2011

● Got investment from East Ventures 4 months later

● Got investment from Gree Ventures & IMJ Fenox in 2013

● Currently listing

– 16 thousand registered users

– 7 thousand agents

– 100 thousand properties

UrbanIndo Technology StackUrbanIndo Technology Stack

elasticsearchelasticsearch

What I'm Going To Talk AboutWhat I'm Going To Talk About

●Yii2● PHP 5.5

(Not really related with Yii2, just filling some time for the Iftar)

Let's talk about Yii firstLet's talk about Yii first

● A macro PHP framework● A lot of functionalities● Great design● Easy to extend● Easy to configure

● But hard learning-curve

Yii FeaturesYii Features

● MVC● DAO, Active Record, Database Migration● Authentication/Authorization● Skinning/Theming● Web Services● I18n, L10N● Cache● And many more

Yii2Yii2

● Yii2 is now in public preview.– It's not even alpha– Don't use it for production– Not all functionalities from Yii1.1 has been

imported.

● Supports PHP5.3+● Most of the changes are in redesigning the

architecture.

What's new in What's new in Yii2?Yii2?

NamespaceNamespace

● Actually Yii1.1 has support namespace usage in user's code (since 1.1.5) using autoloading

● For PHP5.3+ usage only (Yii1.1 still supports PHP5.2)

● Support PSR-0

Better IDE support

Can easily be mistaken with other Strings

NamespaceNamespace

● Yii1.1 classes has to be in global namespaces

● To prevent conflict, allclasses in Yii1.1 use 'C' prefix.

Namespace in Yii2Namespace in Yii2

● Better namespace organization– e.g. we used to have–

– No more longclass name

Components and ObjectComponents and Object

● In Yii1.1, we have CComponents– Getter/Setter through magic __get, __set, __call– Behavior– Event.

● In Yii2 we have Object and Component– Object, basic data structure, getter/setter,

toArray, object configuration, className (added in PHP5.5).

– Component, extends Object, added event and behavior

Object ConfigurationObject Configuration

● In Yii1.1●

● In Yii2

Event HandlerEvent Handler

● More straightforward using jQuery-like event handler

View ObjectView Object

● In Yii1.1 'view' is implemented as plain php file.

View ObjectView Object

● In Yii2, the view is implemented as a View object

View ObjectView Object

● Controller and Widget now accessed as View's context

● Easily do view-rendering every where, not just in controller

● CClientScript responsibility is now part of View object.

● Fragment cache moved from Controller to View object

● Supports multiple non-native renderer like Smarty and Twig

ModelsModels

● Yii2 introduces formName– Yii1.1 uses hardcoded class name

ModelsModels

ModelModel

● Easy loading (mass attribute assignment from $_POST or $_GET)

ModelModel

● Mass object assignment, e.g. Tabular Input

WidgetsWidgets

● In Yii1.1, Widget helps a lot. But declaring one can give great pain.

● Bad IDE support

WidgetsWidgets

● In Yii2, added className() method (PHP5.3) and begin(), end() method.

Query BuilderQuery Builder

● Query builder stands alone

ActiveRecordActiveRecord

● Relation now done via getter instead of relations() method

● Getter returns ActiveQuery that extends Query

ActiveRecordActiveRecord

● Method find() replaces method model() which returns ActiveQuery instance instead of the extended CactiveRecord model instance.

Many MoreMany More

● Assets Bundling● Static Helpers● ActiveForm● Auto Quoting Column Names● User and Identity● Better URL Management

More to comeMore to come

● Better Extension management● Response/Request● Integration with Composer● Widgets (Menu, Pager, Captcha)● NoSQL wrapper● MessageQueue wrapper

WarningWarning

● Yii2 is still in heavy development● It's not even in Alpha phase● What I talk about right now can be obsolete

next week● Fork the github

– http://github.com/yiisoft/yii2

● Try installing● Put your idea and your fix

What's new in What's new in PHP 5.5PHP 5.5

Not really related with Yii2, just filling some time

What's NewWhat's New

● Generators● “Finally” Keyword● Password Hashing API● Bundled OPcode cache● Class name to scalar● Array dereferencing● And many more...

GeneratorGenerator

● Simple iterator without implementing “Iterator” interface

● Iterate result without building array in memory– Exceed memory limit– Time consuming

● Introduces the keyword 'yield'

'Finally' keyword'Finally' keyword

● Just like the one in Java● Mostly concerns with resource handling

– Prevent resource leaking

● Block in `finally` will be executed no matter if the exception caught or not

Bundled Zend OpCacheBundled Zend OpCache

● is ZendOptimizerPlus by Zend

– https://github.com/zendtech/ZendOptimizerPlus

– provides faster PHP execution through opcode caching andoptimization

– storing precompiled script bytecode in the shared memory

● There is also APC (Alternative PHP Cache)

– not really maintainable● Zend OpCache is now bundled with PHP5.5

– You can still install it in PHP5.2, PHP5.3, PHP5.4

http://www.slideshare.net/jpauli/php55-new-features-23608435

Password Hashing APIPassword Hashing API

● password_hash()– Can set the algorithm, the cost, the salt– The value returned will contain the algorithm, the

cost, the salt, and the hash itself.– Only need 1 storage (or 1 column in table).

● password_verify()– Only take the plain password and the hash result

Thank You!Thank You!

Just for your information :)

We have a lot of opportunities- Web engineer- Front-end engineer- Mobile app engineer- Data scientist

- Internship

Send your resume to info@urbanindo.com

top related