이 프레임 워크를 사용하면 전체 MVC (Model-View-Controller) 기반 PHP 응용 프로그램을 구축하거나 유용한 PHP 클래스 모음으로 사용할 수 있습니다. 프레임 워크의 모든 부분은 개별적으로 사용할 수 있습니다.
사용 가능한 모든 클래스 및 방법은 APIINDEX를 참조하십시오.
문서 가이 불완전한 상태에있는 동안 예제 응용 프로그램을 참조하십시오.
작곡가를 통해 JSMF를 설치할 수 있습니다. Composer.json에 다음 종속성을 추가하십시오
{
"require" : {
"janst123/jsmf" : " >=1.0.0 "
}이 저장소에서 JSMF를 복제 할 수도 있습니다 (버전 태그 사용 또는 최신 변경을 위해 마스터 브랜치를 복제하십시오). 이 경우 자신의 자동 로더를 작성해야합니다.
전체 응용 프로그램을 JSMF에 기반으로하려는 경우에만 필요합니다. JSMF Autoloader 또는 자신의 단일 클래스를 사용할 수도 있습니다.
이 코드를 응용 프로그램 인덱스 파일에 배치하십시오. 이 파일을 통해 모든 요청을 경로로 경로 (APACHE를 사용하여 모든 요청을 index.php로 라우팅하는 방법에 대한 소개를 보려면 참조) JSMF Application 클래스가 요청 URL (http : // host/module/controller/action)에서 모델/컨트롤러/작업을 결정할 수 있습니다.
하나 이상의 URL 부품이 존재하지 않으면 응용 프로그램은 항상 "색인"작업 ( "색인"컨트롤러, "인덱스"모듈)을 사용합니다.
예 : http : // 호스트는 모듈을 호출하려고 시도합니다. "index" -> indexcontroller-> indexaction, http : // http : // host/misc/faq 요청 "misc" -> faqcontroller-> indexaction
<?php
define ( ' DEV_SERVER ' , true ); // define this
define ( ' SRC ' , realpath ( dirname ( __FILE__ ) . ' /../ ' ));
require ( SRC . ' /vendor/autoload.php ' );
try {
// optional: load an application wide config
JSMF Config:: load ( SRC . ' /config/base.config.php ' );
// optional: load application wide translations
JSMF Language:: loadTranslations ( SRC . ' /language/translations ' , ' de ' );
// optional: route special URLs to special modules / controllers / actions ( I always place the legal texts in a Module named misc)
JSMF Request:: addRoute ( ' /^/disclaimer/?$/i ' , ' misc ' , ' index ' , ' disclaimer ' ); // route a request to /disclaimer to the disclaimer Action in the IndexController in the module "misc"
JSMF Request:: addRoute ( ' /^/privacy/?$/i ' , ' misc ' , ' index ' , ' privacy ' );
// register the autoloader and run the application
JSMF Application:: registerAutoloader ();
JSMF Application:: run ();
// output the applications response (can be HTML, JSON ...)
JSMF Response:: output ();
} catch ( JSMF Exception NotFound $ e ) {
// do some special things for not-found errors e.g. redirect to a static 404 page
JSMF Request:: redirect ( ' /404.html ' );
JSMF Response:: output (); // output method also sends the headers (here: the Location header)
} catch ( JSMF Exception $ e ) {
// output is done by JSMF
JSMF Response:: setException ( $ e );
JSMF Response:: output ();
} catch ( Exception $ e ) {
// do something on common non-JSMF Exception
}