SlideShare ist ein Scribd-Unternehmen logo
1 von 64
Downloaden Sie, um offline zu lesen
Yii, frameworks and where PHP is
           heading to



                             Alexander Makarov
                        Yii core team, Stay.com
Is PHP still there?
• Developers are migrating to
  – Ruby
  – Python
  – Java
  – C++
• Developers are migrating…

• Because… PHP sucks?!
Well, it sucks a bit. Not that much!
• Very good choice for web development.
• Will be there for a long time.
• Programming language is just a tool… one of
  the tools.
• With a good framework bad parts aren’t that
  visible.
PHP is good for business
• It’s web-focused.
• Lots of ready to use stuff.
• PHP makes everything easy.
• Easy to find and replace
  developers.
• Less risky.
• Project costs less.
Good choice for business → Good
     choice for developer.
PHP itself is heading towards
          simplicity and usability
•   Password hashing API.
•   Generators.
•   More consistency.
•   Built-in webserver.
•   More performance.
•   Better syntax.
•   etc.
And that’s the way to go!
What about frameworks?
Good things first
• github = standard for hosting cool PHP stuff.
• PSR-0 = interoperable & faster class loading.
• At least some stable frameworks are there
  and definitely ready for business: BC and
  maintained.
Now not that good things…
“Enterprise”
• ZF 2 and Symfony2 are very “enterprise”.
• Much more “enterprise” than ZF1 and
  symfony were.
This “enterprise” shit is too complex
“ZF2 is too "scientific". You can write a thesis
about ZF2 and its design. Don't get me wrong, I
love best practices, standards, design patterns
etc., but ZF2 devs dive too deep into "science".
Symfony2 is better but not enough.”
But why becoming complex instead of
           being simple?
Why ZF2 is what it is
• Zend is the PHP company, they’ll have enough
  customers no matter what they’ll release.
• Main customers are of enterprise type.
• Not really interested in 80% projects out
  there.
• Consulting isn’t profitable if product isn’t
  complex enough ;)
• Heading into J2EE direction they have a
  chance to get former EE-companies on board.
It works for Zend very well.
What about Symfony2?
• Personally I think they’re trying to be “enterpise”
  (=complex) as well.
• Sensio labs is a commercial company earning for
  framework support and consulting.
• http://fabien.potencier.org/article/65/why-
  symfony
• Good thing is that framework is a bit more
  practical than ZF2.
• Still very complex.
What’s bad in these “enterprise”
               things?
• Design-patterns oriented instead of practically
  oriented. Emphasizing on patterns.
• Easier to unit-test, harder to develop and
  learn.
• Almost impossible to delegate routine work to
  less competent developers w/o spending lots
  of time teaching them first.
• High risk for project owner.
That reminds me… Java past
• “Their main thesis to support that complexity
  is… hold your breath… fasten your seatbelts: if
  it were easier, more stupid people would be
  using it!. Ta-da!!”
• “J2EE is no way simple. However the reality is
  simple: for J2EE to survive - we have to make
  it simple to build, deploy and manage”
Java is simpler now compared to what
                 it was
• Play
• Apache Wicket
• Even Spring is much more usable and simple
  than what it was before
So are SF2 and ZF2 evil?
Not really. Just a different niche.
Enterprise isn’t only complexity
• Stable API.
• Well-tested code.
• Backwards-compatible regular releases.
• Guarantee that vendor will support product
  for at least X years.
• Well-documented.
• Commercial support, trainings.
• And more…
So what’s left for practical fellows?
Practical frameworks
• Development should be straightforward.
  We’re not doing complex stuff for webapps
  most of the time.
• Easy learning.
• Less magic.
• Less configuration.
• As simple API as possible.
If good parts of enterprise are still
         there it’s perfect
Yii — a practical framework
Let’s bust some myths first
Framework myths
• If framework reinvented the wheel, it's a bad
  one.
• If there is DI container and design patterns all
  over the place, it's a good one.
• If framework X implemented feature Y first,
  it's better.
• Loosely coupled framework is always a good
  choice.
• If there’s no feature X it’s a bad one.
What’s really important
• Easy to learn.
• Easy to debug and fix.
• Doesn’t mess with your code or any good third-
  party code.
• Friendly active community.
• BC and stable.
• No roadblocks when trying to extend or
  customize it.
• Feels good ;)
*
              *                 *



       *                                          
2004       2005   2006   2007       2008   2011




  Prado, с 2004 → Yii 1.0, 2008 → Yii 1.1, 2010
What is Yii?
PHP5 MVC.              Powerful cache.
Nice API.              RBAC, auth
DAO, AR, migrations.    framework.
Form builder.          Console.
Themes.                error handler, log.
Test framework.        Gii.
Well documented.
                        CLDR based I18n.
Friendly community.
                        Widgets.
                        BSD license.
Still stays the fastest modern PHP
    framework (excluding some
microframeworks and PECL ones).
• That's not ours benchmark.
  http://docs.phalconphp.com/en/latest/refere
  nce/benchmark/hello-world.html
Getting even faster and less memory-
    hungry thanks to our GitHub
            community.
*intranet
2   2
1.Balanced
2.Stable
3.Flexible
4.Well-documented
5.Doesn’t mess with
 your stuff
Balance isn’t easy to achieve
• Theoretically correct architecture or practical
  experience?
• 20% or 80%
• Features or core?
Stable API and BC = good & evil
Flexibility should not mess with
                 simplicity
• As less abstraction as possible.
• It’s simple to make things complex. Making things
  simple isn’t.
• Conventions.
• Hide complexity.
There’s not a single
setMyCoolFactoryDependencyInjection
            Container()
               in Yii
Docs are very important
— We’re documenting as soon as writing code.
— Definitive guide and blog tutorial translated
 into 16 languages.
— phpdoc.
— Examples.
— Great books.
Yii can work with components from
         Symfony 2 and ZF2.
 That's what these are for, right? ;)
Yii is practice oriented framework
The end?

• Questions?     • sam@rmcreative.ru
• Suggestions?   • @sam_dark
                 • http://yiiframework.com/
I knew you would ask about it ;)
—PHP 5.3.8+           —Better structured
—Namespaced classes   —Less entities
—PSR-0                —All the good things are
                       still there




                                 v2
Yii2: base
— New aliases             class MyComponent extends
  @yii/base/Component     yiibaseObject
                          {
— CComponent →
                            public $x;
  Object + Component        public function __construct($a, $b)
— SPL instead of custom     {
  collections                   //…
— Killed CFormModel.        }
                          }
  Model should be
  used instead.
                          $component = MyComponent::newInstance(
— Better rules and          array('x'=>10),
  scenarios.                'a', 'b'
                          );
Yii2: View Object
         —render(), widget(),
          beginCache() →
          viewObject
         —View: $owner = class
          that called render
         —$this = View.
         —No need for renderers.
         —Can be used in console.
         —CHtml is still there.
Yii2: events
$post->on('add',          • No need to declare
function($event) { ...    • jQuery-like syntax
});                       • Behaviors instead of
                            filters
$post->trigger('add',
new Event($this));

$post->off('add',
$callback);

$handlers = $post-
>getEventHandlers('add'
);
Yii2: Query object

// Query object
$query = new Query;
$query->select('id')->from('tbl_customer')->limit(10);
$command = $db->createCommand($query);
$this->assertEquals("SELECT `id` FROM `tbl_customer`
LIMIT 10", $command->sql);

// array
$command = $db->createCommand(array(
       'select' => 'name',
       'from' => 'tbl_customer',
));
Yii2: Even better ActiveRecord
$customer = Customer::find(2)   – Finder / Model
       ->active()               – Can create your own
       ->one();                   finder
$customer->name = 'Qiang';
                                – ::model()
$customer->save();
                                – Autoquotes.
$customers = Customer::find()   – Method chains.
       ->order('id')            – Dirty attributes.
       ->asArray(true)          – Less memory.
       ->all();
                                – Can get arrays from AR.
Yii2: AR
$postFinder = Post::find()       – Criteria
  ->where(array(                 – You can merge finders
    'active' => true
                                 – You can add conditions
));
                                   on the fly
if($isPrivate) {
  $postFinder->addWhere(array(
    'createdBy' => $userId,
  ));
}
$posts = $postFinder
  ->mergeWith($anotherFinder)
  ->all();
Yii2: AR
                            class Customer extends ActiveRecord {
– tableName(),                      const STATUS_ACTIVE = 1;

  relations(), scopes() =           public static function tableName() {
  static.                                   return 'tbl_customer';
                                    }
– HAS_ONE,
                                    public static function relations() {
  HAS_MANY relations.                       return array(
                                                    'orders:Order[]' => array(
– link = FKs                                                'link' => array('customer_id'
                            => 'id'),
– via = through                                     ),
                                            );
– Scopes via                        }

  anonymous functions.              public static function scopes() {
                                            return array(
– "@." and "?" tokens.                              'active' => function($q) {
  Automatic alias. Own                                      return $q-
                            >andWhere('@.`status` = ' . self::STATUS_ACTIVE);
  table. Foreign table.                             },
                                            );
                                    }
                            }
Yii2: AR
$customers =                 $customers =
Customer::find()->           Customer::find()->active()
asArray()->all();            ->all();

foreach (Customer::find()    $customers =
as $customer)                Customer::find()
                             ->where('name like :name',
$count = Customer::count()   array(
->value();                     ':name' => '%customer%'
                             ))->order('id')->all();
TODO (if there will be enough time)
•   HTTP (CURL) wrapper    • jQueryUI-based widgets
•   Package manager          (not just jQueryUI
•   Mailer                   widgets)
•   Twitter Bootstrap      • Commercial support
                             (most probably not by
•   Debug toolbar            Yii core team members)
•   Console requirements
•   More helpers
1 or 2?



Work with the stable one. 1.1 will be
 supported till December 31, 2015.
When?
Before we’ll push alpha     •   i18n
code to github repo we      •   Controller + webapp
need to finish at least →   •   A solid base for widgets
                            •   URL manager
The end (really)

• Questions?
• Suggestions?

• sam@rmcreative.ru
• @sam_dark
• http://yiiframework.com/

Weitere ähnliche Inhalte

Was ist angesagt?

Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony TechniquesKris Wallsmith
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptIngvar Stepanyan
 
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...Mail.ru Group
 
PHP Object Injection Vulnerability in WordPress: an Analysis
PHP Object Injection Vulnerability in WordPress: an AnalysisPHP Object Injection Vulnerability in WordPress: an Analysis
PHP Object Injection Vulnerability in WordPress: an AnalysisPositive Hack Days
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginningAnis Ahmad
 
PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?Sam Thomas
 
Rich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationRich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationKirill Chebunin
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Kris Wallsmith
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...Rafael Dohms
 
Scala ActiveRecord
Scala ActiveRecordScala ActiveRecord
Scala ActiveRecordscalaconfjp
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Kris Wallsmith
 
The state of your own hypertext preprocessor
The state of your own hypertext preprocessorThe state of your own hypertext preprocessor
The state of your own hypertext preprocessorAlessandro Nadalin
 
Dirty Secrets of the PHP SOAP Extension
Dirty Secrets of the PHP SOAP ExtensionDirty Secrets of the PHP SOAP Extension
Dirty Secrets of the PHP SOAP ExtensionAdam Trachtenberg
 
Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Damien Seguy
 

Was ist angesagt? (20)

Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
 
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
 
PHP Object Injection Vulnerability in WordPress: an Analysis
PHP Object Injection Vulnerability in WordPress: an AnalysisPHP Object Injection Vulnerability in WordPress: an Analysis
PHP Object Injection Vulnerability in WordPress: an Analysis
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?
 
Rich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationRich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 Application
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
 
Scala ActiveRecord
Scala ActiveRecordScala ActiveRecord
Scala ActiveRecord
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
 
The state of your own hypertext preprocessor
The state of your own hypertext preprocessorThe state of your own hypertext preprocessor
The state of your own hypertext preprocessor
 
Dirty Secrets of the PHP SOAP Extension
Dirty Secrets of the PHP SOAP ExtensionDirty Secrets of the PHP SOAP Extension
Dirty Secrets of the PHP SOAP Extension
 
WCLV13 JavaScript
WCLV13 JavaScriptWCLV13 JavaScript
WCLV13 JavaScript
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
Your code is not a string
Your code is not a stringYour code is not a string
Your code is not a string
 
Hooks WCSD12
Hooks WCSD12Hooks WCSD12
Hooks WCSD12
 
Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)
 

Ähnlich wie Yii, frameworks and where PHP is heading to

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
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a bossFrancisco Ribeiro
 
Howtobuildyourownframework
HowtobuildyourownframeworkHowtobuildyourownframework
Howtobuildyourownframeworkhazzaz
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
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
 
Scaling php applications with redis
Scaling php applications with redisScaling php applications with redis
Scaling php applications with redisjimbojsb
 
Performance tuning with zend framework
Performance tuning with zend frameworkPerformance tuning with zend framework
Performance tuning with zend frameworkAlan Seiden
 
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsCodemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsFabio Franzini
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applicationschartjes
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and DesktopElizabeth Smith
 
Getting up & running with zend framework
Getting up & running with zend frameworkGetting up & running with zend framework
Getting up & running with zend frameworkSaidur Rahman
 
Decoupling Edutopia.org
Decoupling Edutopia.orgDecoupling Edutopia.org
Decoupling Edutopia.orgdsayswhat
 
How to organize the business layer in software
How to organize the business layer in softwareHow to organize the business layer in software
How to organize the business layer in softwareArnaud LEMAIRE
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in productionChristian Papauschek
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)Paul Jones
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jqueryKostas Mavridis
 

Ähnlich wie Yii, frameworks and where PHP is heading to (20)

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
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
Howtobuildyourownframework
HowtobuildyourownframeworkHowtobuildyourownframework
Howtobuildyourownframework
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
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
 
Scaling php applications with redis
Scaling php applications with redisScaling php applications with redis
Scaling php applications with redis
 
Performance tuning with zend framework
Performance tuning with zend frameworkPerformance tuning with zend framework
Performance tuning with zend framework
 
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsCodemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 
2009-02 Oops!
2009-02 Oops!2009-02 Oops!
2009-02 Oops!
 
Getting up & running with zend framework
Getting up & running with zend frameworkGetting up & running with zend framework
Getting up & running with zend framework
 
Getting up and running with Zend Framework
Getting up and running with Zend FrameworkGetting up and running with Zend Framework
Getting up and running with Zend Framework
 
Decoupling Edutopia.org
Decoupling Edutopia.orgDecoupling Edutopia.org
Decoupling Edutopia.org
 
Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
How to organize the business layer in software
How to organize the business layer in softwareHow to organize the business layer in software
How to organize the business layer in software
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in production
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)
 
JS Essence
JS EssenceJS Essence
JS Essence
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jquery
 

Mehr von Alexander Makarov

UWDC 2013, Как мы используем Yii
UWDC 2013, Как мы используем YiiUWDC 2013, Как мы используем Yii
UWDC 2013, Как мы используем YiiAlexander Makarov
 
DevConf 2012 - Yii, его разработка и Yii2
DevConf 2012 - Yii, его разработка и Yii2DevConf 2012 - Yii, его разработка и Yii2
DevConf 2012 - Yii, его разработка и Yii2Alexander Makarov
 
YiiConf 2012 - Alexander Makarov - Yii2, что нового
YiiConf 2012 - Alexander Makarov - Yii2, что новогоYiiConf 2012 - Alexander Makarov - Yii2, что нового
YiiConf 2012 - Alexander Makarov - Yii2, что новогоAlexander Makarov
 
UWDC'12, Александр Макаров, Yii, его разработка и Yii2
UWDC'12, Александр Макаров, Yii, его разработка и Yii2UWDC'12, Александр Макаров, Yii, его разработка и Yii2
UWDC'12, Александр Макаров, Yii, его разработка и Yii2Alexander Makarov
 
UWDC'12, Александр Макаров, О командной разработке и фреймворках
UWDC'12, Александр Макаров, О командной разработке и фреймворкахUWDC'12, Александр Макаров, О командной разработке и фреймворках
UWDC'12, Александр Макаров, О командной разработке и фреймворкахAlexander Makarov
 
Devconf 2011 - PHP - Как разрабатывается фреймворк Yii
Devconf 2011 - PHP - Как разрабатывается фреймворк YiiDevconf 2011 - PHP - Как разрабатывается фреймворк Yii
Devconf 2011 - PHP - Как разрабатывается фреймворк YiiAlexander Makarov
 
Выбираем PHP-фреймворк. Особенности разработки с фреймворками
Выбираем PHP-фреймворк. Особенности разработки с фреймворкамиВыбираем PHP-фреймворк. Особенности разработки с фреймворками
Выбираем PHP-фреймворк. Особенности разработки с фреймворкамиAlexander Makarov
 

Mehr von Alexander Makarov (10)

UWDC 2013, Как мы используем Yii
UWDC 2013, Как мы используем YiiUWDC 2013, Как мы используем Yii
UWDC 2013, Как мы используем Yii
 
UWDC 2013, Yii2
UWDC 2013, Yii2UWDC 2013, Yii2
UWDC 2013, Yii2
 
DevConf 2012 - Yii, его разработка и Yii2
DevConf 2012 - Yii, его разработка и Yii2DevConf 2012 - Yii, его разработка и Yii2
DevConf 2012 - Yii, его разработка и Yii2
 
YiiConf 2012 - Alexander Makarov - Yii2, что нового
YiiConf 2012 - Alexander Makarov - Yii2, что новогоYiiConf 2012 - Alexander Makarov - Yii2, что нового
YiiConf 2012 - Alexander Makarov - Yii2, что нового
 
UWDC'12, Александр Макаров, Yii, его разработка и Yii2
UWDC'12, Александр Макаров, Yii, его разработка и Yii2UWDC'12, Александр Макаров, Yii, его разработка и Yii2
UWDC'12, Александр Макаров, Yii, его разработка и Yii2
 
UWDC'12, Александр Макаров, О командной разработке и фреймворках
UWDC'12, Александр Макаров, О командной разработке и фреймворкахUWDC'12, Александр Макаров, О командной разработке и фреймворках
UWDC'12, Александр Макаров, О командной разработке и фреймворках
 
Devconf 2011 - PHP - Как разрабатывается фреймворк Yii
Devconf 2011 - PHP - Как разрабатывается фреймворк YiiDevconf 2011 - PHP - Как разрабатывается фреймворк Yii
Devconf 2011 - PHP - Как разрабатывается фреймворк Yii
 
Как разраба
Как разрабаКак разраба
Как разраба
 
Выбираем PHP-фреймворк. Особенности разработки с фреймворками
Выбираем PHP-фреймворк. Особенности разработки с фреймворкамиВыбираем PHP-фреймворк. Особенности разработки с фреймворками
Выбираем PHP-фреймворк. Особенности разработки с фреймворками
 
Yii rit 2010
Yii rit 2010Yii rit 2010
Yii rit 2010
 

Yii, frameworks and where PHP is heading to

  • 1. Yii, frameworks and where PHP is heading to Alexander Makarov Yii core team, Stay.com
  • 2. Is PHP still there? • Developers are migrating to – Ruby – Python – Java – C++ • Developers are migrating… • Because… PHP sucks?!
  • 3. Well, it sucks a bit. Not that much! • Very good choice for web development. • Will be there for a long time. • Programming language is just a tool… one of the tools. • With a good framework bad parts aren’t that visible.
  • 4. PHP is good for business • It’s web-focused. • Lots of ready to use stuff. • PHP makes everything easy. • Easy to find and replace developers. • Less risky. • Project costs less.
  • 5. Good choice for business → Good choice for developer.
  • 6. PHP itself is heading towards simplicity and usability • Password hashing API. • Generators. • More consistency. • Built-in webserver. • More performance. • Better syntax. • etc.
  • 7. And that’s the way to go!
  • 9. Good things first • github = standard for hosting cool PHP stuff. • PSR-0 = interoperable & faster class loading. • At least some stable frameworks are there and definitely ready for business: BC and maintained.
  • 10. Now not that good things…
  • 11. “Enterprise” • ZF 2 and Symfony2 are very “enterprise”. • Much more “enterprise” than ZF1 and symfony were.
  • 12.
  • 13. This “enterprise” shit is too complex
  • 14. “ZF2 is too "scientific". You can write a thesis about ZF2 and its design. Don't get me wrong, I love best practices, standards, design patterns etc., but ZF2 devs dive too deep into "science". Symfony2 is better but not enough.”
  • 15. But why becoming complex instead of being simple?
  • 16. Why ZF2 is what it is • Zend is the PHP company, they’ll have enough customers no matter what they’ll release. • Main customers are of enterprise type. • Not really interested in 80% projects out there. • Consulting isn’t profitable if product isn’t complex enough ;) • Heading into J2EE direction they have a chance to get former EE-companies on board.
  • 17. It works for Zend very well.
  • 18. What about Symfony2? • Personally I think they’re trying to be “enterpise” (=complex) as well. • Sensio labs is a commercial company earning for framework support and consulting. • http://fabien.potencier.org/article/65/why- symfony • Good thing is that framework is a bit more practical than ZF2. • Still very complex.
  • 19. What’s bad in these “enterprise” things? • Design-patterns oriented instead of practically oriented. Emphasizing on patterns. • Easier to unit-test, harder to develop and learn. • Almost impossible to delegate routine work to less competent developers w/o spending lots of time teaching them first. • High risk for project owner.
  • 20. That reminds me… Java past • “Their main thesis to support that complexity is… hold your breath… fasten your seatbelts: if it were easier, more stupid people would be using it!. Ta-da!!” • “J2EE is no way simple. However the reality is simple: for J2EE to survive - we have to make it simple to build, deploy and manage”
  • 21. Java is simpler now compared to what it was • Play • Apache Wicket • Even Spring is much more usable and simple than what it was before
  • 22. So are SF2 and ZF2 evil?
  • 23. Not really. Just a different niche.
  • 24. Enterprise isn’t only complexity • Stable API. • Well-tested code. • Backwards-compatible regular releases. • Guarantee that vendor will support product for at least X years. • Well-documented. • Commercial support, trainings. • And more…
  • 25. So what’s left for practical fellows?
  • 26. Practical frameworks • Development should be straightforward. We’re not doing complex stuff for webapps most of the time. • Easy learning. • Less magic. • Less configuration. • As simple API as possible.
  • 27. If good parts of enterprise are still there it’s perfect
  • 28. Yii — a practical framework
  • 29.
  • 30. Let’s bust some myths first
  • 31. Framework myths • If framework reinvented the wheel, it's a bad one. • If there is DI container and design patterns all over the place, it's a good one. • If framework X implemented feature Y first, it's better. • Loosely coupled framework is always a good choice. • If there’s no feature X it’s a bad one.
  • 32. What’s really important • Easy to learn. • Easy to debug and fix. • Doesn’t mess with your code or any good third- party code. • Friendly active community. • BC and stable. • No roadblocks when trying to extend or customize it. • Feels good ;)
  • 33. * * * *  2004 2005 2006 2007 2008 2011 Prado, с 2004 → Yii 1.0, 2008 → Yii 1.1, 2010
  • 34. What is Yii? PHP5 MVC. Powerful cache. Nice API. RBAC, auth DAO, AR, migrations. framework. Form builder. Console. Themes. error handler, log. Test framework. Gii. Well documented. CLDR based I18n. Friendly community. Widgets. BSD license.
  • 35. Still stays the fastest modern PHP framework (excluding some microframeworks and PECL ones).
  • 36. • That's not ours benchmark. http://docs.phalconphp.com/en/latest/refere nce/benchmark/hello-world.html
  • 37. Getting even faster and less memory- hungry thanks to our GitHub community.
  • 38.
  • 40.
  • 41. 2 2
  • 43. Balance isn’t easy to achieve • Theoretically correct architecture or practical experience? • 20% or 80% • Features or core?
  • 44. Stable API and BC = good & evil
  • 45. Flexibility should not mess with simplicity • As less abstraction as possible. • It’s simple to make things complex. Making things simple isn’t. • Conventions. • Hide complexity.
  • 46. There’s not a single setMyCoolFactoryDependencyInjection Container() in Yii
  • 47. Docs are very important — We’re documenting as soon as writing code. — Definitive guide and blog tutorial translated into 16 languages. — phpdoc. — Examples. — Great books.
  • 48. Yii can work with components from Symfony 2 and ZF2. That's what these are for, right? ;)
  • 49. Yii is practice oriented framework
  • 50. The end? • Questions? • sam@rmcreative.ru • Suggestions? • @sam_dark • http://yiiframework.com/
  • 51. I knew you would ask about it ;)
  • 52. —PHP 5.3.8+ —Better structured —Namespaced classes —Less entities —PSR-0 —All the good things are still there v2
  • 53. Yii2: base — New aliases class MyComponent extends @yii/base/Component yiibaseObject { — CComponent → public $x; Object + Component public function __construct($a, $b) — SPL instead of custom { collections //… — Killed CFormModel. } } Model should be used instead. $component = MyComponent::newInstance( — Better rules and array('x'=>10), scenarios. 'a', 'b' );
  • 54. Yii2: View Object —render(), widget(), beginCache() → viewObject —View: $owner = class that called render —$this = View. —No need for renderers. —Can be used in console. —CHtml is still there.
  • 55. Yii2: events $post->on('add', • No need to declare function($event) { ... • jQuery-like syntax }); • Behaviors instead of filters $post->trigger('add', new Event($this)); $post->off('add', $callback); $handlers = $post- >getEventHandlers('add' );
  • 56. Yii2: Query object // Query object $query = new Query; $query->select('id')->from('tbl_customer')->limit(10); $command = $db->createCommand($query); $this->assertEquals("SELECT `id` FROM `tbl_customer` LIMIT 10", $command->sql); // array $command = $db->createCommand(array( 'select' => 'name', 'from' => 'tbl_customer', ));
  • 57. Yii2: Even better ActiveRecord $customer = Customer::find(2) – Finder / Model ->active() – Can create your own ->one(); finder $customer->name = 'Qiang'; – ::model() $customer->save(); – Autoquotes. $customers = Customer::find() – Method chains. ->order('id') – Dirty attributes. ->asArray(true) – Less memory. ->all(); – Can get arrays from AR.
  • 58. Yii2: AR $postFinder = Post::find() – Criteria ->where(array( – You can merge finders 'active' => true – You can add conditions )); on the fly if($isPrivate) { $postFinder->addWhere(array( 'createdBy' => $userId, )); } $posts = $postFinder ->mergeWith($anotherFinder) ->all();
  • 59. Yii2: AR class Customer extends ActiveRecord { – tableName(), const STATUS_ACTIVE = 1; relations(), scopes() = public static function tableName() { static. return 'tbl_customer'; } – HAS_ONE, public static function relations() { HAS_MANY relations. return array( 'orders:Order[]' => array( – link = FKs 'link' => array('customer_id' => 'id'), – via = through ), ); – Scopes via } anonymous functions. public static function scopes() { return array( – "@." and "?" tokens. 'active' => function($q) { Automatic alias. Own return $q- >andWhere('@.`status` = ' . self::STATUS_ACTIVE); table. Foreign table. }, ); } }
  • 60. Yii2: AR $customers = $customers = Customer::find()-> Customer::find()->active() asArray()->all(); ->all(); foreach (Customer::find() $customers = as $customer) Customer::find() ->where('name like :name', $count = Customer::count() array( ->value(); ':name' => '%customer%' ))->order('id')->all();
  • 61. TODO (if there will be enough time) • HTTP (CURL) wrapper • jQueryUI-based widgets • Package manager (not just jQueryUI • Mailer widgets) • Twitter Bootstrap • Commercial support (most probably not by • Debug toolbar Yii core team members) • Console requirements • More helpers
  • 62. 1 or 2? Work with the stable one. 1.1 will be supported till December 31, 2015.
  • 63. When? Before we’ll push alpha • i18n code to github repo we • Controller + webapp need to finish at least → • A solid base for widgets • URL manager
  • 64. The end (really) • Questions? • Suggestions? • sam@rmcreative.ru • @sam_dark • http://yiiframework.com/