good symfony slides
분류없음 2009/06/22 01:151. Symfony 2 by Fabien Potencier
2. Sympal – The flexible Symfony CMS by Jonathan H. Wage
3. What’s New In Doctrine by Jonathan H. Wage
'Symfony'에 해당되는 글 7건good symfony slides분류없음 2009/06/22 01:15 http://www.symfonylab.com/symfony-conference-most-interesting-slides-ideas/
1. Symfony 2 by Fabien Potencier 2. Sympal – The flexible Symfony CMS by Jonathan H. Wage 3. What’s New In Doctrine by Jonathan H. Wage tags : Symfony
Note 프로젝트Projects/note 2007/01/16 09:57 Note 프로젝트
'자기 계발은 복리로 돌아온다'1. 맞는 말이 아닐 수 없습니다. 자기 계발을 한 시간만큼 우리는 미래에 편안해질 수 있습니다. 그럼 자기계발은 언제 얼마나 해야 할까요? 위 김창준님 글에서 또 하나 간과할 수 없는 부분은 자기 계발은 끊임없이 해야 한다는 것입니다. 지금 일년간 하고 땡이 아니라는 말이죠. 자기 계발이라는것이 조금만 방심하면 금세 흐트러질 수 있지 않나 싶습니다. 그중에서도 저는 자료관리와 시간관리 얘기를 해보고자 합니다. 자료 관리나 시간관리를 위해서, 개인 위키를 만들어서 자료 관리를 해 왔고, 프랭클린 플래너도 써봤고, '시간관리? 인생관리!'2 를 재밌게 읽고서 나만의 시간관리 방법을 만들어 사용해보기도 했습니다. 하지만 끝에 가서는 흐지부지 되고 말았습니다. 개인 위키의 경우는 서버를 옮기다가, 또는 새로운 버전이 나와서 테스트 해보다가 자료를 날리기도 했고, 프랭클린 플래너는 너무 규격화된 방식이라 마음에 들지 않았고, 나만의 시간관리 방법은 직접 만들어서 하다 보니 조금은 귀찮았던 것 같습니다. 그래도 마지막에 시도하였던 나만의 방법이 제게 너무 잘 맞았던 것 같습니다. 그 때 했던 방법은, 노트에 아침에 일어나서부터 무엇을 했는지를 10분이나 30분 단위로 적고, 매일 통계를 내보고, 일주일간 하고자 했던 일들 중에 어느 부분을 얼마만큼 했는지를 분석하는 일이었습니다. 매일매일 내 일과를 통계를 내는 일은 정말 즐거웠던 일 중에 하나였던것 같습니다. 동시에 내가 이렇게 살고 있구나를 뼈저리게 느끼게한 일이었습니다. 정말로 일을 한 시간이 하루의 8시간을 넘지 못 했으니까요. 아무리 노력해도 하루 8시간 정말 일 을 한다는 것은 너무 어려운 일이었습니다. 하지만 이 방법은 집안일을 해야하면서 부터는 잘 동작하지 않았습니다. 아이를 돌보고 집안일을 한다는것은 정말 말 그대로 full-time job 인 듯 합니다. never really ends, never really starts. 끊임없이 발생하는 상황 속에서 내가 내 시간을 기록하고 사용한다는 것이 무의미해져버렸던 것 같습니다. 그렇게 시간 기록을 하지 않고 살아온지 어느덧 일년가까이 되었습니다. 이제는 다시 뭔가를 찾아봐야 하지 않을까요. 그래서 Note 프로젝트를 해보려고 합니다. Symfony 를 사용해서 저만의 시간 관리 시스템을 만들 것입니다. 물론 기존에 나와있는 여러 프로젝트가 있는 것으로 압니다. 만고불변의 진리, Don't invent the wheel 이 있지만, 결국 내가 나에게 맞는 것을 찾아가는 과정은 그만큼 가치가 있지 않나 싶습니다. 진행되는 프로젝트 소스는 계속 업로드 될 것입니다. (저에게 커스터마이즈 된 프로젝트라 얼마나 다른 분들에게 가치가 있을까 싶습니다만..) 다음에는 이 프로젝트의 목적이나 지향하는 바를 쓰겠습니다. Extending Symfony Adjacent ListProgramming 2007/01/08 14:42 지난번에 만들었던 Adjacent List 를 확장해볼 생각입니다. 추가할 기능은, 체크박스를 넣고 상태 토글 기능을 넣어보겠습니다.
1. schema.yml 수정 각 item 에 상태를 추가하기 위해서 status 테이블을 만들고, item 테이블을 status 테이블과 조인할것입니다. # config/schema.yml원래, `status_id` 란 필드명을 사용하고 `status` 란 테이블이 존재할 경우에는 propel 이 알아서 foreign key 를 생성해 주는데, 이번 경우에서는 `_foreign_keys` 옵션이 있어서 그런지 자동으로는 안 되는군요. `status_id` 를 위한 foreign_keys 항목을 추가합니다. 테스트 데이터는 다음과 같이 변경합니다. # data/fixtures/fixtures.yml이제 `symfony propel-build-all-load item` 명령으로 테이블을 생성하고, 테스트데이터를 입력합니다. 이후 테이블을 살펴보면 데이터가 입력된 것을 확인하실 수 있습니다. 2. Item 클래스의 `->setStatusId()` 메쏘드 오버라이드 BaseItem 클래스의 `->setStatusId()` 메쏘드는 `status_id` 필드에 저장될 아이디를 지정합니다. 하지만 이 자료는 숫자형이기 때문에, 나중에 상태 변경을 할때 문제가 생길 수 있습니다. 따라서 여기서는 `status` 테이블의 `tag` 필드값을 바탕으로 `item` 의 `status` 를 지정할 수 있도록 해보겠습니다. # lib/model/StatusPeer.php # lib/model/Item.php이제 $item->setStatusId('opened') 와 같이 함으로써 상태를 지정할 수 있게 되었습니다. 3. status 테이블과 조인 `item/list` 액션에서 `status` 관련 정보는 `$item->getStatus()` 를 함으로써 얻을 수 있습니다. 하지만 이는 추가적인 데이터베이스 쿼리를 발생시킵니다. 따라서 미리 조인을 하여서 이런 추가적인 쿼리를 하지 않도록 할 수 있습니다. `lib/model/itemPeer.php` 의 `getAllByThread()` 를 아래와 같이 수정합니다. static function getAllByThread() 4. View 수정 View 를 수정하기 위해, 먼저 `lib/model/Status.php` 에 `__toString()` 메쏘드를 추가합니다. public function __toString()이제 `$item->getStatus()` 호출을 통해서 `status` 테이블의 `title` 필드를 출력할 수 있습니다. (이렇게 하지 않는다면 `$item->getStatus()->getTitle()` 을 해야겠지요..) 마지막으로 템플릿을 수정합니다. <style> 5. AJAX Interaction 추가 `listSuccess.php` 템플릿에 다음을 추가하여 AJAX 링크를 만든다. <?php foreach ($items as $item): ?>그리고 `Item` 모듈에 `toggle` 액션을 추가하고, 클래스에 `toggle` 메쏘드를 추가하여 AJAX 결과를 처리할 수 있도록 한다. # apps/item/modules/item/actions/actions.class.php # lib/model/Item.php # apps/item/modules/item/templates/toggleSuccess.php 6. Next Steps - Nested status toggle: If a parent node is toggled to closed, its child nodes would be closed. And if every child nodes are closed, their parent node should be closed also. - Reduce database query: In toggle action, there are three queries that we can reduce. 'Programming' 카테고리의 다른 글
Symfony Adjacent ListProgramming 2007/01/03 16:02 What I am going to build today is adjacent list. Data with hierarchic structure is very common. Today's output will looks like the image below. I, fisrtly, wanted to make a sortable and inplace editable list, but it was way too difficult. I am still learning how symfony is working. Today's work took whole my morning plus three hours. So I will do it later if I have some free time. (Anyway, symfony's in_place_edit_tag wrapper does not fully support what I want)
1. Project preparation # symfony init-project sandbox # symfony init-app item # mysqladmin -u root create item # modify config/database.yml, config/propel.ini 2. Writing Schema and CRUD generation # config/schema.yml # symfony propel-build-model # symfony propel-build-sql # symfony propel-insert-sql # symfony propel-generate-crud item item Item (app name, module name, and model name, respectively) 3. Testdata # data/fixtures/testdata.yml # symfony propel-load-data item 4. Handle child nodes To register a child node, we will make a link in `showSuccess.php` # apps/item/modules/item/templates/showSuccess.php`item/create` action checks request parameter whether a `parent` parameter exists, and if it exists, the action will fetch the parent object. (We don't need parent information when a item is edited.) # apps/item/modules/item/action/action.class.phpOpen and modify `editSuccess.php` template. We don't need to display thread number or depth number in this form, so remove them. And only if when a user is adding a child node, parent_id is needed. # apps/item/modules/item/templates/showSuccess.php 5. Override Item model Now everything is prepared for child nodes registering. Now we need some codes actually save child nodes and set parent_id, thread, and depth for them. Let's override `Item` class. # lib/model/Item.phpBased on Propel Guide1, it supports cascading delete. But I am not sure what will happen, so I just wrote some code for cascading delete. Now Let's test it using testdata. # symfony propel-load-data item Now our list has a basic representation of hierarchic structure. However, how can we display them as a nested list? 6. Implement Adjacent List Now it's time to implement adjacent list. I will use an algorithm from the article "Storing Hierarchical Data in a Database2. Two images from the same article will be helpful to understand what is it and how to implement it. First, we need a left and right field in our data model. Since 'left' and 'right' are one of mysql keywords, I will use 'lft' and 'rgt' instead. # config/schema.yml # symfony propel-build-all (It will do 'propel-build-model', 'propel-build-sql', and 'propel-insert-sql') Then, let's modify `Item` model, so that the model can insert and remove dangled nodes. # lib/model/Item.php#->save() Method # lib/model/Item.php#->save() MethodYes. We don't have any elegant method to wrap an update query like "UPDATE item SET lft = lft + 2 WHERE ...". I thought I could you Criteria::CUSTOM3, but it turned out I can't use it for an update query. Maybe Doctrine supports it. I will check them out later. Then, we need a method to fetching those items in certain order. # lib/model/ItemPeer.php # apps/item/modules/item/action/action.class.phpNow let's test our modification. # symfony propel-load-data item # item/list action 7. Validating form 8. Other References
'Programming' 카테고리의 다른 글
AJAX Post-It 만들기Programming 2006/12/29 13:37 PHP 웹 프레임워크인 Symfony1 를 이용하여 AJAX 기반의 어플리케이션을 만들어보겠습니다. 그 중에서도 특히 Script.aculo.us2 의 draggable_element 와 droppable_element 를 활용하여 Post-It 스타일의 메모장을 만들어볼 계획입니다.
1. 먼저 symfony 명령을 활용하여 프로젝트를 준비합니다. 프로젝트명은 note, 어플리케이션 이름도 note 로 하겠습니다. # mkdir note 2. 아파치 설정을 변경하시거나 해당 디렉토리를 웹이 접근가능한 폴더로 변경합니다. 그리고 테스트를 하시면 'Symfony Project Created' 페이지를 만나실 수 있습니다. 참고로 제 웹 설정을 올려보겠습니다. # /etc/httpd/users/sunhwan.conf 좀 더 상세한 프로젝트 생성방법은 심포니 홈페이지3 을 참고하시면 됩니다. 3. 이제 우리가 사용할 어플리케이션이 사용할 데이터베이스를 설정합니다. 지금 우리가 만들 어플리케이션은 규모도 크지 않고 다른 어플리케이션들과의 연동도 별로 없기때문에 XML 이나 다른 파일 형태로 저장하는 것도 나쁘지 않을 것 같았지만, 사실 Symfony 에서 이를 어떻게 구현할지 익숙하지 않아서 일단 데이터베이스를 사용하기로 했습니다. note/config 디렉토리에 있는 database.yml, propel.ini, schema.yml 파일을 수정합니다. # database.yml사실 이러면 안 되지만, 저는 방화벽이 설치된 로컬에서 MySQL 을 돌리는 관계로, root 비밀번호가 없습니다. database.yml 이나 propel.ini 파일의 아이디 뒷부분에 자신에 해당하는 비밀번호를 입력하면 됩니다. 4. 이제 데이터베이스를 생성합니다. Symfony 는 schema.yml 에 입력된 정보를 바탕으로 데이터베이스 구조를 생성할 수 있습니다. symfony propel-build-model데이터베이스에 접속해보시면 note 테이블이 생성된 것을 확인하실 수 있습니다. 또한 데이터베이스 자료와 PHP 자료형을 연결시켜주는 역할을 하는 모델들이 note/lib/model 디렉토리에 생긴것을 확인하실 수 있습니다. 5. 이제 생성된 모델을 이용해서 기본적인 데이터 입력, 호출, 수정, 그리고 삭제 (CRUD - Create, read, update, and delete) 를 하는 모듈을 만들어 보겠습니다. 모델명은.. 역시 note 입니다. symfony propel-generate-crud note note Note참고로 앞에서부터 어플리케이션, 모듈, 그리고 데이터모델 순서입니다. 즉, 만약 blog 라는 어플리케이션을 만들고, 그 아래 Article 이라는 데이터모델을 이용하여 post 라는 모듈을 만든다면 'symfony propel-generate-crud blog post Article' 이 되는 것입니다. 6. 이제 템플릿을 수정할 차례입니다. 다른 부분이야 그대로 두고, note/list 액션의 템플릿을 바꿔서 노트형식으로 보이도록 할 계획입니다. 또한 이부분 draggable/dropperable element 들을 설정하여 만약 개별 노트의 위치가 변경되는 경우에 데이터베이스를 변경하도록 할 것입니다. 먼저 note/apps/note/modules/note/templates/listSuccess.php 파일을 수정합니다. <div id='notepad' class='notepad' style='position: absolute; top: 5px; left: 5px;'>note/web/main.css 에 아래 내용을 추가합니다. .note그리고 테스트를 해보신다면 아래와 같은 화면을 보실 수 있습니다. 각각의 노트는 데이터베이스에 있는 X, Y 값을 사용하여 위치가 결정될 것입니다. 7. 이제 마지막으로 AJAX 액션을 추가할 차례입니다. Symfony 에는 Prototype 과 Script.aclo.us 가 기본적으로 내장되어 있기 때문에 따로 설치할 필요는 없습니다. 개체를 드래그 앤 드랍이 가능하도록 만들어주는 명령은 draggable_element 입니다. 또한 어떠한 개체가 자신의 위에 드랍되었을때 특정한 액션을 일으킬 수 있도록 하기 위해서 drop_receiving_element 를 사용합니다. apps/note/modules/note/templates/listSuccess.php 를 여시고, 다음 내용을 맨 위쪽에 입력합니다. <?php echo use_helper('Javascript') ?>아래 내용은 'endforeach' 위에 입력합니다. <?php echo draggable_element('note_'.$note->getId(), array()) ?>그리고 아래내용은 파일의 제일 아래쪽에 입력합니다. <?php echo drop_receiving_element('notepad', array(파일 전체를 다시 살펴보시려면 클릭하십시오. more.. 7. 마지막으로 apps/note/modules/actions/action.class.php 에 'executeTranslate' 을 추가하면 끝입니다. public function executeTranslate () 'Programming' 카테고리의 다른 글
Symfony Form Helper - object_select_tagProgramming 2006/12/24 09:37Building an select box filled with various options are quite common for web programmers. For example, let's assume we are making a form to write an post for a blog. We have a category table and we want to display categories that we can use. Basically what we can do is, select categories and display its string field. In symfony, we can use 'object_select_tag', instead. Based on its declaration, it is called by: object_select_tag(object $object, string $method, array $option, mixed $default)I am building project ticket managing system. So I have tables named ticket, project, and milestone. A project can have number of milestone, and a ticket is confined to a project and a milestone. +---------------+---------+------------+Symfony generated templates for ticket will have 'object_select_tag' by default. But it will display id numbers of milestone for selection box. Since the helper utilitze object's 'toString()' method, we need to define '__toString()' method for 'Milestone' class to fill selection box with milestone tag. public function __toString() {Now the selection box displays tag of milestones. However, it displays every milestones in the table. We want to display milestones only for this project. So how we can do that? Let's assume we have a variable named 'project', which stores project id. Then we can change 'object_select_tag' command: object_select_tag($ticket, 'getMilestoneId', array (as below: object_select_tag($ticket, 'getMilestoneId', array (and add 'getProjectMilestones' method in 'MilestonePeer' class: public static function getProjectMilestones ()Check out the differences: So the helper uses options to populate select box, and fetch default value from $object->$method if it doesn't have default value. Other helpers and more detail can be found in the helper chapter1 at symfony online documentation
'Programming' 카테고리의 다른 글
Symfony v1 beta 2 has been releasedProgramming 2006/12/20 09:37 Symfony-1.0 beta 2 has been released.
Install? pear install symfony/symfony-beta and don't forget 'symfony cc' 'Programming' 카테고리의 다른 글
tags : Symfony
|