41
꿩대신닭? 대안Rails,CakePHP 임현수(프리버즈) [email protected] / http://fribirdz.net

Barcamp Seoul2 : inspired by Rails, CakePHP

Embed Size (px)

Citation preview

Page 1: Barcamp Seoul2 : inspired by Rails, CakePHP

꿩대신닭?대안Rails,CakePHP

임현수(프리버즈)[email protected]/http://fribirdz.net

Page 2: Barcamp Seoul2 : inspired by Rails, CakePHP

레일스가그렇게재미있다던데...

Page 3: Barcamp Seoul2 : inspired by Rails, CakePHP

개발자를행복하게해준다던데..

Page 4: Barcamp Seoul2 : inspired by Rails, CakePHP

생산성이좋다던데..

Page 5: Barcamp Seoul2 : inspired by Rails, CakePHP

우리서비스도레일스로?

Page 6: Barcamp Seoul2 : inspired by Rails, CakePHP

검증?

Page 7: Barcamp Seoul2 : inspired by Rails, CakePHP

“허락”받기

Page 8: Barcamp Seoul2 : inspired by Rails, CakePHP

퍼포먼스,트러블슈팅,레퍼런스,관련자료

Page 9: Barcamp Seoul2 : inspired by Rails, CakePHP

했다가문제생기면,니가책임질래?

Page 10: Barcamp Seoul2 : inspired by Rails, CakePHP

대안

Page 11: Barcamp Seoul2 : inspired by Rails, CakePHP

흉내내기?따라하기?

Page 12: Barcamp Seoul2 : inspired by Rails, CakePHP

RailsCloneFramework

Page 13: Barcamp Seoul2 : inspired by Rails, CakePHP

개발언어는그대로PHP로하죠?요즘프레임워크를많이들쓰던데,CakePHP한번써보죠?

Page 14: Barcamp Seoul2 : inspired by Rails, CakePHP

러닝커브감소=>생산성향상

팀장님안심시키기

PHP의수많은문서,Lib,경험이용하기

레일스개발방법익숙해지기

Page 15: Barcamp Seoul2 : inspired by Rails, CakePHP

PHPFrameworks

Page 17: Barcamp Seoul2 : inspired by Rails, CakePHP

PHPFrameworks• Ambivalence:AJava-MaverickPort

• WACT:WebApplicationComponentToolkit

• Achievo:AgoodRADframework

• Phrame:AJava-Strutsport

• Studs:AJava-StrutsporttoPHP

• Prado:ThewinnerofZendcodingcontest

• PHPOnTrax:aRailsport-PHP5Only

• CakePHP:InspiredbyRailsPHP4/5

• Mojavi:ThefirstMVCframeworkIfellinlovewith

• Symfony:BasedonMojaviandinspiredbyRails

Page 18: Barcamp Seoul2 : inspired by Rails, CakePHP

PHPFrameworks

• PHPOnTrax:aRailsport-PHP5Only

• CakePHP:InspiredbyRailsPHP4/5

• Symfony:BasedonMojaviandinspiredbyRails

Page 19: Barcamp Seoul2 : inspired by Rails, CakePHP

구글신을영접해보니• CakePHP

• Symfony

• ZendFramework

• PHPonTRAX

Page 20: Barcamp Seoul2 : inspired by Rails, CakePHP

구글신을영접해보니• CakePHP

• Symfony

• ZendFramework

• PHPonTRAX

3,760,000개

3,550,000개

1,560,000개

1,380,000개

Page 21: Barcamp Seoul2 : inspired by Rails, CakePHP

FlameWars?

• PHPZone:Top10PHPMVCframeworks

• http://www.mustap.com/phpzone_post_73_top-10-php-mvc-frameworks

Page 22: Barcamp Seoul2 : inspired by Rails, CakePHP

CakePHP&RoR

• 무엇이무엇이똑같을까?

Page 23: Barcamp Seoul2 : inspired by Rails, CakePHP

Rails의대표적인기능(?)

• MVC구조

• 설정보다는관례• Scaffolding

• Validation

• Routing

• Ajax,Javascript,HTMLHelpers

• 플러그인• 마이그레이션

Page 24: Barcamp Seoul2 : inspired by Rails, CakePHP

Rails의대표적인기능(?)

• MVC구조

• Model:ORM-ActiveRecord

• View:RHTMLTemplate

• Controller:Controller/Action

Page 25: Barcamp Seoul2 : inspired by Rails, CakePHP

Rails

• NamingConvention

• DBTable:Model복수(People)

• Model:단수(Person)

• find_by_<column>

• Controller:Model의복수(People)

Page 26: Barcamp Seoul2 : inspired by Rails, CakePHP

CakePHP

• NamingConvention

• DBTable:Model복수(People)

• Model:단수(Person)

• findBy<Column>

• Controller:Model의복수(People)

Page 27: Barcamp Seoul2 : inspired by Rails, CakePHP

RoR&CakePHP:관례• User

• id

• name

• email

• created

• ...

• Log

• id

• user_id

• created

• ...

Page 28: Barcamp Seoul2 : inspired by Rails, CakePHP

Rails• 폴더구조• app/

• components/

• config/

• db/

• doc/

• lib/

• log/

• public/

• script/

• test/

• tmp/

• vender/

Page 29: Barcamp Seoul2 : inspired by Rails, CakePHP

Rails• 폴더구조-app/• app/controllers

• app/helpers

• app/models

• app/views

• app/views/layouts

Page 30: Barcamp Seoul2 : inspired by Rails, CakePHP

CakePHP• 폴더구조-app• controllers

• helpers

• models

• views

• views/layouts

• config

• components

• db

• test

• venders

• webroot

• plugins

• tmp

• tmp/log

Page 31: Barcamp Seoul2 : inspired by Rails, CakePHP

Rails

• Model-Controller-Action-View

• http://fribirdz.net/people/list/5

• Controller:PeopleController

• Model:Person

• DBTable:people

• ActionMethod:list

• Params:5

• View:/people/list.rhtml

Page 32: Barcamp Seoul2 : inspired by Rails, CakePHP

CakePHP

• Model-Controller-Action-View

• http://fribirdz.net/people/list/5

• Controller:PeopleController

• Model:Person

• DBTable:people

• ActionMethod:list

• Params:5

• View:/people/list.thtml

Page 33: Barcamp Seoul2 : inspired by Rails, CakePHP

Rails&CakePHP

• Model

• created_at=created

• validationcheck

• Model.find형태도동일

• script/generate->phpbake.php

Page 34: Barcamp Seoul2 : inspired by Rails, CakePHP

Rails&CakePHP

• @user=User.find(:first,:conditions=>[“login=?ANDpassword=?”,str1,str2])

• @user=User.find(:all,:select=>“id,name”,:conditions=>{:login=>str1,:password=>str2})

• $this->User->find(array(‘id’,‘name’),array(‘login’=>$str1,‘password’=>$str2));

• $this->User->findAll(array(‘login’=>$str1,‘password’=>$str2));

• User.find_by_login(“matz”)

• User->findByLogin(“matz);

Page 35: Barcamp Seoul2 : inspired by Rails, CakePHP

Routing

• Rails

• config/routes.rb

• map.connect‘:controller/:action/id’

• CakePHP

• config/route.php

• $Route->connect('/URI',array('controller'=>'controllerName','action'=>'actionName'));

Page 36: Barcamp Seoul2 : inspired by Rails, CakePHP

스케폴딩

classPhonebookConroller<ApplicationController

scaffold:person

end

classPhonebookControllerextendsAppController{

var$scaffold;

}

Page 37: Barcamp Seoul2 : inspired by Rails, CakePHP

Controller/ActionclassPhonebookController<ApplicationController deflist @people=Person.find(:all) endend-->/app/views/phonebook/list.rhtml호출

classPhonebookControllerextendsAppController{ var$uses=array(‘Person’); publicfunctionlist() { $rec=$this->Person->findAll(); }}-->/app/views/phonebook/list.thtml호출

Page 38: Barcamp Seoul2 : inspired by Rails, CakePHP

써보니까..

• 나중에레일스로갈아타기쉽겠다.

• 당연한이야기지만,90%,100%똑같진않다.

• 루비나레일스의변화만큼빨리변하지않는다.

• 하지만,좋은요소가있다면플러그인으로라도나온다.WebBaker,migrate;;

Page 39: Barcamp Seoul2 : inspired by Rails, CakePHP

적용사례

• IDtail.com

• Pumfit.com

• 다나와(카더라통신)• Olalog(PHPonTRAX)

Page 40: Barcamp Seoul2 : inspired by Rails, CakePHP

써보니까..

• 굳이“아이건Rails에서되는데...CakePHP에서도똑같이하고싶다..찾아보자!!”하는건아닌듯

• 자료는많이부족.당연히,국내자료전무.소스코드보게됨

• 기본구조,흐름이같다는것에서6-70%의기대만미리해두면좋지않을까.

• CakePHP1.2에서는Rails를벗어나서자체적인길로가고있는듯한느낌도...

Page 41: Barcamp Seoul2 : inspired by Rails, CakePHP

적용을생각해볼만한분

• Ruby나RoR을배우기에는부담(정신적,시간적)이있는사람

• 사내신규서비스개발에Rails도입을곧바로하기에는결정권이약한사람

• 사내신규서비스개발에Rails도입을곧바로하기에는부담이큰사람

• Rails를써봤는데,재미있던사람

• 나중에RoR로개발환경을바꿀생각이있는사람(익숙해지기)