2017 © Pedro PelΓ‘ez
 

library overframe

A micro framework which works on nother frameworks.

image

withcenter/overframe

A micro framework which works on nother frameworks.

  • Tuesday, January 12, 2016
  • by thruthesky
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Overframe

Overview

Overframe is a framewhich runs upon other frameworks like codeigniter, laravel, slim, etc., (*1)

μ‚¬μš© μ„€λͺ…

  • Test.php νŒŒμΌμ„ μ‚΄νŽ΄λ³΄λ©΄, 각 λͺ¨λ“ˆ 별 ν™œμš©λ„λ₯Ό 잘 이해 ν•  수 μžˆλ‹€.

TODO

  • κΈ°λ³Έ μ„€μΉ˜λ₯Ό ν•  수 μžˆλ„λ‘ ν•œλ‹€. μ„€μΉ˜λ₯Ό ν•˜λ©΄ config_meta_entity, module_meta_entity λ₯Ό μ„€μΉ˜ν•œλ‹€. config_meta_entity μ—λŠ” module_meta_entity μ—λŠ” μ–΄λ–€ λͺ¨λ“ˆμ΄ μ„€μΉ˜λ˜μ—ˆλŠ”μ§€ ν‘œμ‹œλ₯Ό ν•˜κ³ , μ„€μΉ˜λœ λͺ¨λ“ˆμ˜ κ²½μš°μ—λŠ” 메뉴λ₯Ό κ΄€λ¦¬μž νŽ˜μ΄μ§€μ— ν‘œμ‹œ ν•  수 μžˆλ„λ‘ ν•œλ‹€., (*2)

  • λ·°(μŠ€ν‚¨, ν…Œλ§ˆ)κ°€ ν•„μš” μ—†λŠ” λͺ¨λ“ˆμ˜ 경우, λͺ¨λ“ˆ λ‚΄μ—μ„œ λͺ¨λ“  것을 λ‹€ 처리 ν•  수 μžˆλ„λ‘ ν•œλ‹€., (*3)

template() 을 호좜 ν•  λ•Œ, ν…œν”Œλ¦Ώ 폴더에 데이터가 μ—†μœΌλ©΄ λͺ¨λ“ˆ ν΄λ”μ—μ„œ ν…œν”Œλ¦Ώμ„ μ°ΎλŠ”λ‹€., (*4)

  • 뷰와 컨트둀러 κΈ°λŠ₯을 μΆ”κ°€ν•œλ‹€.

ν˜„μž¬ template 이 뷰와 컨트둀러 μ—­ν™œμ„ ν•˜λŠ”λ°, 이λ₯Ό λ³€κ²½ν•œλ‹€., (*5)

installation μ„€μΉ˜

git submodule add https://github.com/thruthesky/overframe, (*6)

루트 폴더에 μ„€μΉ˜ν•΄μ•Ό ν•œλ‹€., (*7)

* autoload.php κ°€ μ •μƒλ™μž‘μ„ ν•˜κΈ° μœ„ν•΄μ„œλŠ” 루트 폴더에 μ„€μΉ˜λ₯Ό ν•  ν•„μš”κ°€ μžˆλ‹€.

git sub-module 둜만 진행. packagist λ‘œλŠ” ν•˜μ§€ μ•ŠμŒ.

Since project is not for the public use, we do not use composer/packagist.org
, (*8)

sapcms 1.2 에 μ„€μΉ˜ ν›„ 관리 νŽ˜μ΄μ§€ ( Dash Board )

/?module=overframe&action=index

sapcms 1.2 의 κ΄€λ¦¬μž μ•„μ΄λ””λ‘œ 접속을 ν•˜λ©΄ 각쒅 메뉴λ₯Ό λ³Ό 수 μžˆλ‹€., (*9)

μ½”λ”©

접속 경둜

λͺ¨λ“  접속 κ²½λ‘œλŠ” μ•„λž˜μ™€ κ°™λ‹€., (*10)

/?module=overframe&action=index

였직 μœ„ 경둜만 μ‚¬μš©ν•œλ‹€., (*11)

μœ„ 경둜둜 μ ‘μ†ν•˜λŠ” 경우 root/overframe/template/sapcms1/sapcms1.php κ°€ μ‹€ν–‰λ˜λ©° λͺ¨λ“  μž‘μ—…μ„ 이 μŠ€ν¬λ¦½νŠΈμ—μ„œ μ§„ν–‰ν•œλ‹€., (*12)

단, mode κ°€ 'ajax' 인 κ²½μš°μ—λŠ” root/overframe/model/ajax/Ajax.php 의 run() ν•¨μˆ˜κ°€ λͺ¨λ“  μž‘μ—…μ„ λ§‘μ•„μ„œ ν•œλ‹€., (*13)

mode=ajax 인 경우 λ¦¬ν„΄λ˜λŠ” 값은 ajax 이닀., (*14)

mode=ajax 인 경우,, (*15)

μ‹€ν–‰(쿼리)λ₯Ό μœ„ν•œ condition 값이 ν•„μš”ν•œλ° 'model' 이 κ·Έ μ—­ν™œμ„ ν•œλ‹€., (*16)

( 2016λ…„ 1μ›” 25일 μ΄μ „μ—λŠ” 'do', 'what' 으둜 ν–ˆλ‹€. ), (*17)

model 의 3 개의 경둜 값을 점(.)으둜 λΆ„λ¦¬ν•˜μ—¬ 가지며, (*18)

예λ₯Ό λ“€μ–΄ &model=entity.ItemList.collect 와 같이 ν•˜λ©΄, (*19)

autoload.php 에 λ”°λΌμ„œ μ μ ˆν•œ namespace 의 ItemList.php λ₯Ό λ‘œλ“œν•˜κ³ , (*20)

object λ₯Ό μƒμ„±ν•œ λ‹€μŒ collect() λ©”μ†Œλ“œλ₯Ό ν˜ΈμΆœν•œλ‹€., (*21)

λ‹€μŒμ€ http://philgo.org/?module=overframe&action=index&model=entity.crud.collect&entity=philgo_attend 와 같이 접속을 ν•œ 경우,, (*22)

μ‹€ν–‰λ˜λŠ” μ΅œμ’… collect() λ©”μ†Œλ“œμ΄λ‹€., (*23)

예제) root/overframe/entity/ItemList.php 의 collect() λ©”μ†Œλ“œ., (*24)

public function collect() {
    json_success(array());
}

Unit Test

Overframe unit test is builtin.
It is run on web server not on CLI.
To run the unit test, input this code where ever you want., (*25)

<?php
    echo runTest();
?>

각쒅 경둜

각 framework λ§ˆλ‹€ μ‹œμž‘νŽ˜μ΄μ§€(λ©”μΈνŽ˜μ΄μ§€, front page)κ°€ 틀릴 수 μžˆλ‹€., (*26)

μ•„λž˜μ™€ 같이 url_action() ν•¨μˆ˜κ°€ 각 μ‹œμž‘ νŽ˜μ΄μ§€ URL 을 λ¦¬ν„΄ν•œλ‹€., (*27)

<a href="<?php echo url_action(); ?>">HOME</a>

autoload

if model name and php class name are the same, then you can simply put
, (*28)

namespace of;
, (*29)

as its namespace and use like below.
, (*30)

new \of\Database();
, (*31)

각 Framework 별 μ„€μΉ˜

μƒˆλ‘œμš΄ framework 에 μ μš©ν•˜κΈ° μœ„ν•΄μ„œλŠ”, (*32)

database/DatabaseLayer.php 와 user/UserLayer.php λ₯Ό μˆ˜μ •ν•΄μ•Ό ν•œλ‹€., (*33)

Entity

Entity is a group of items that has the same characters.
Entity is a table.
, (*34)

Entity λŠ” ν•˜λ‚˜μ˜ ν…Œμ΄λΈ”λ‘œμ„œ Entity λ₯Ό μƒμ„±ν•˜λ©΄ ν•΄λ‹Ή ν…Œμ΄λΈ”μ— ν•˜λ‚˜μ˜ λ ˆμ½”λ“œκ°€ μƒμ„±λœλ‹€.
그리고 κ·Έ λ ˆμ½”λ“œ 정보λ₯Ό Entity->record 에 λ³΄κ΄€ν•˜λŠ” 데, 이것이 λ°”λ‘œ item 이 λœλ‹€.
λ‹€μ‹œλ§ν•˜λ©΄, 각 entity κ°μ²΄μ—λŠ” $record private λ³€μˆ˜κ°€ μžˆλŠ”λ°, 이것은 ν•˜λ‚˜μ˜ ν…Œμ΄λΈ” λ ˆμ½”λ“œμ˜ 정보λ₯Ό 가지며 이것은 ν•΄λ‹Ή entity 의 μ•„μ΄ν…œμ΄ λœλ‹€.
, (*35)

즉, entity λŠ” ν…Œμ΄λΈ”μ΄λ©΄μ„œ λ‚΄λΆ€μ˜ record λ³€μˆ˜μ— ν•˜λ‚˜μ˜ 행을 λ‹΄κ³  μžˆλ‹€. λ”°λΌμ„œ entity κ°μ²΄λŠ” ν…Œμ΄λΈ”μ΄λ©΄μ„œ λ™μ‹œμ— ν•˜λ‚˜μ˜ λ ˆμ½”λ“œλ₯Ό 가진닀.
, (*36)

λ”°λΌμ„œ entity 의 κ°μ²΄λŠ” ν…Œμ΄λΈ” μž‘μ—…μ„ ν•  수 μžˆμœΌλ©΄μ„œ λ™μ‹œμ— ν•˜λ‚˜μ˜ 행에 λŒ€ν•œ μž‘μ—…μ„ ν•  수 μžˆλ‹€.
, (*37)

Model 루틴

각 λͺ¨λΈμ—λŠ” init.php κ°€ μ‘΄μž¬ν•˜λ©°,, (*38)

overframe 이 μ‹œμž‘ 될 λ•Œ, auotoload.php μ—μ„œ μΈν΄λ£¨λ“œλ˜μ–΄ μ‹€ν–‰λœλ‹€., (*39)

Model λͺ©λ‘/μ„€μΉ˜/제거

λͺ¨λ“ˆ λͺ©λ‘μ€ template/model-list/model-list.php μ—μ„œ 처리λ₯Ό ν•œλ‹€., (*40)

μ„€μΉ˜λŠ” ν•΄λ‹Ή λͺ¨λ“ˆμ˜ install.php 의 is_installed, install, uninstall 훅을 μ‚¬μš©ν•΄μ„œ 처리 ν•œλ‹€., (*41)

μ„€μΉ˜λŠ” hook_λͺ¨λ“ˆμ΄λ¦„_install() 을 ν˜ΈμΆœν•˜λ―€λ‘œμ„œ μ‚¬μš©κ°€λŠ₯ν•˜λ‹€., (*42)

λ”°λΌμ„œ μ–΄λ–€ λ°©μ‹μœΌλ‘œλ“  λΆ€λͺ¨ ν”„λ ˆμž„μ›Œν¬μ˜ ν…Œλ§ˆ λ˜λŠ” μ»¨νŠΈλ‘€λŸ¬μ—μ„œ "hook_λͺ¨λ“ˆμ΄λ¦„_install()"을 ν˜ΈμΆœν•˜λ©΄ λœλ‹€., (*43)

Ajax Endpoint

μ„œλ²„ λͺ¨λ“ˆλ‘œ 데이터 전솑 및 ν‘œμ‹œλŠ” Ajax 둜 ν•˜λŠ” 것이 원칙이닀., (*44)

Ajax κ°€ μ•„λ‹ˆλ©΄ μ•„μ˜ˆ ν•˜μ§€λ₯Ό μ•ŠλŠ”λ‹€., (*45)

각 λΆ€λͺ¨ λͺ¨λ“ˆλ§ˆλ‹€ Ajax Endpoint λ₯Ό μ œκ³΅ν•΄μ•Όν•œλ‹€., (*46)

κ·Έ endpoint script λŠ” 각 model 의 controller 뢀뢄을 wrapping ν•˜μ—¬ ajax json 데이터λ₯Ό λ°”λ‘œ 좜λ ₯ν•˜λ„λ‘ ν•œλ‹€., (*47)

<?php echo ajax_endpoint()?>&do=행동값

ajax_endpoint() 둜 ν˜ΈμΆœν•œ μ •λ³΄λŠ”, (*48)

Ajax ν΄λž˜μŠ€κ°€ λ‹΄λ‹Ήν•œλ‹€., (*49)

Ajax 처리

파일 μ—…λ‘œλ“œλ‚˜ κΈ€ μ—…λ‘œλ“œλ₯Ό ν•  λ•Œ, ajax λ₯Ό ν†΅ν•œ 처리 방법을 μ„€λͺ…ν•œλ‹€., (*50)

codeigniter3 λ‚˜ sapcms1.2 μ—μ„œ Ajax λ₯Ό ν†΅ν•œ ν˜ΈμΆœμΈμ§€ μ•„λ‹Œμ§€λ₯Ό νŒλ³„ν•œλ‹€., (*51)

이 것은 HTTP μž…λ ₯ λ³€μˆ˜μ— action=ajax 와 같이 λ“€μ–΄μ˜€λ©΄ ajax 호좜둜 μΈμ§€ν•œλ‹€., (*52)

그러면 ajax()->run() 을 ν˜ΈμΆœν•˜λ©°, (*53)

κ²°κ΅­ μ΄λŠ” Ajax::run() 을 ν˜ΈμΆœν•˜κ²Œ λ˜λŠ”λ°,, (*54)

이 λ©”μ†Œλ“œμ—μ„œ HTTP μž…λ ₯ λ³€μˆ˜ 'do' 에 μžˆλŠ” 값을 λ°”νƒ•μœΌλ‘œ ν•΄λ‹Ή 클래슀λ₯Ό 호좜 ν•œλ‹€., (*55)

예λ₯Ό λ“€μ–΄ &do=data 와 같이 μž…λ ₯되면, (*56)

data()->runAjax() κ°€ 호좜되며, (*57)

&do=philgo_banner 와 같이 μž…λ ₯되면, (*58)

philgo_banner::runAjax() κ°€ ν˜ΈμΆœλœλ‹€., (*59)

λ”°λΌμ„œ 각 λͺ¨λΈ λ³„λ‘œ Ajax 처리 μ½”λ“œλ₯Ό μž‘μ„± ν•  수 μžˆλ‹€., (*60)

model 처리

2016λ…„ 1μ›” 25일 μ΄ν›„λΆ€ν„°λŠ” 기쑴의 "Ajax" 방식 λ³΄λ‹€λŠ” μ’€ 더 μœ μ—°ν•œ, (*61)

"Model" 직접 호좜 방식을 μ‚¬μš©ν•˜λ©°,, (*62)

λ˜ν•œ entity/ItemList.php 의 collect() λ₯Ό μ‚¬μš©ν•΄μ„œ 보닀 λ²”μš©μ μ΄λ©° μœ μ—°ν•œ λ°©μ‹μœΌλ‘œ 코딩을 ν•œλ‹€., (*63)

Template ν†΅ν•œ μ›ΉλΈŒλΌμš°μ €λ‘œ νŽ˜μ΄μ§€ 정보(ν™”λ©΄) 좜λ ₯

λͺ¨λ“  μ²˜λ¦¬λŠ” template/overframe-index-page μ—μ„œ ν•œλ‹€., (*64)

@todo @κ²€ν†  이 template 은 view 둜 변경이 λ˜μ–΄μ•Ό ν•  것 κ°™λ‹€., (*65)

즉, μŠ€ν‚¨μ„ 보여 쀄 λ•Œμ—λŠ” template/overframe-index-page μ—μ„œ ν•˜λ©°, (*66)

데이터 솑/μˆ˜μ‹ μ€ ajax 둜 ν•œλ‹€., (*67)

Data λͺ¨λ“ˆ

FORM λ¬Έμž₯μ—μ„œ νŒŒμΌμ„ μ „λ‹¬ν•˜λŠ” λ³€μˆ˜λͺ…은 항상 'userfile' 이어야 ν•œλ‹€., (*68)

<input type='file' name='userfile'>

data_node_entity.code λŠ” indexing 이 λ˜λŠ” ν•„λ“œμ΄λ©° FORM 의 μž…λ ₯ λ³€μˆ˜λ‘œ λ“€μ–΄ 와야 ν•œλ‹€., (*69)

<input type='hidden' name='code' value='photo'>

파일 μ—…λ‘œλ“œ 폼 μž…λ ₯ λ³€μˆ˜μ— unqiue=1 의 값이 μ „λ‹¬λ˜λ©΄ ν•΄λ‹Ή code 의 λͺ¨λ“  νŒŒμΌμ„ λ‹€ μ§€μš°κ³  ν˜„μž¬ μ—…λ‘œλ“œ λ˜λŠ” 파일만 μ˜¬λ¦°λ‹€., (*70)

<input type='hidden' name='unique' value='1'>

gid λŠ” μ—…λ‘œλ“œλ˜λŠ” 파일의 그룹을 λ§ν•œλ‹€. gid λ₯Ό ν†΅ν•΄μ„œ 글에 μ²¨λΆ€λ˜λŠ” μ—¬λŸ¬ νŒŒμΌμ„ ν•˜λ‚˜μ˜ 그룹으둜 묢을 수 μžˆλ‹€., (*71)

<input type='hidden' name='gid' value='group-id'>

gid λŠ” 주둜 unique_id() 둜 μƒμ„±ν•˜κ±°λ‚˜ μžλ°”μŠ€ν¬λ¦½νŠΈ λ“±μœΌλ‘œ 생성 ν•  수 μžˆλ‹€., (*72)

글을 μ“Έ λ•Œ, 파일 μ—…λ‘œλ“œμ—μ„œ gid λ₯Ό ν†΅ν•΄μ„œ μ—…λ‘œλ“œλ₯Ό ν•œ λ‹€μŒ, 글을 μ €μž₯ ν•  λ•Œ, gid λ₯Ό "post-123", "comment-456" κ³Ό 같이 첨뢀 νŒŒμΌμ„ μΆ”μΆœν•˜κ²Œ μ‰½κ²Œ λ³€κ²½ν•œλ‹€., (*73)

예λ₯Ό λ“€μ–΄ κΈ€ λ²ˆν˜Έκ°€ 123 이면, gid κ°€ "post-123" 인 것을 찾도둝 ν•œλ‹€., (*74)

File Upload FORM λ¬Έμž₯

<form action="<?php echo sys()->url_ajax_endpoint()?>&do=data&what=file-upload" method="post" enctype="multipart/form-data">

μ‚¬μš©μž 정보

sapcms1.2 λ‚˜ Drupal8 의 κ²½μš°μ—λŠ” μ‚¬μš©μž κ΄€λ ¨ κΈ°λŠ₯이 이미 λ“€μ–΄κ°€ μžˆλ‹€., (*75)

ν•˜μ§€λ§Œ CodeIgniter3 의 경우 κ·ΈλŸ¬ν•œ κΈ°λ³Έ κΈ°λŠ₯이 μ—†λ‹€., (*76)

λ”°λΌμ„œ CodeIgniter3 의 경우 항상 κ·ΈλŸ¬ν•œ κΈ°λŠ₯을 μΆ”κ°€μ μœΌλ‘œ λ§Œλ“€μ–΄μ•Ό ν•˜λŠ”λ°,, (*77)

각 CodeIgniter3 λ§ˆλ‹€ λͺ¨λ‘ 틀릴 수 μžˆλ‹€., (*78)

UserLayer.php (λ°μ΄ν„°λ ˆμ΄μ–΄) λ₯Ό ν†΅ν•΄μ„œ, (*79)

User::getLogin(), User::getName(), User::getID(), User::getEmail(), User::isAdmin() 의 λ©”μ†Œλ“œλ₯Ό 두고, (*80)

처리λ₯Ό ν•œλ‹€., (*81)

di( user()->getLogin() );
di( user()->isAdmin() );

λͺ¨λ“ˆ μ„€μΉ˜

λͺ¨λ“ˆ μ„€μΉ˜μ˜ κΈ°λ³Έ μ˜ˆμ œλŠ” module/data/install.php μ—μ„œ 찾을 수 μžˆλ‹€., (*82)

ν•˜μ§€λ§Œ ν•˜λ‚˜μ˜ λͺ¨λ“ˆμ— μ—¬λŸ¬κ°œμ˜ entity κ°€ λ“€μ–΄κ°€λŠ” κ²½μš°μ—λŠ”, (*83)

module/philgo/install.php 와 같이 exists() λ₯Ό overriding ν•΄μ„œ entity ν…Œμ΄λΈ”μ„ λ‹€λ₯΄κ²Œ 점검해야 ν•  ν•„μš”κ°€ μžˆλ‹€., (*84)

λͺ¨λ“ˆ μ„€μΉ˜ 예제)

<?php
namespace of;
class Philgo extends Node
{
    public function __construct()
    {
        parent::__construct();

    }
    /**
     *
     */
    public function install() {
        $attend = node('philgo_attend');
        $attend->init();
        $attend->addColumn('user_id', 'varchar', 64);
        $attend->addColumn('date', 'int');
        $attend->addUniqueKey('user_id,date');
    }

    public function uninstall()
    {
        $attend = node('philgo_attend');
        $attend->uninit();
    }

    public function exists( $tablename = null )
    {
        $attend = node('philgo_attend');
        $tablename = $attend->getTableName();
        return parent::exists($tablename);
    }

}

The Versions

12/01 2016

dev-master

9999999-dev https://github.com/thruthesky/overfame

A micro framework which works on nother frameworks.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

framework overframe