PHP code example of janst123 / jsmf

1. Go to this page and download the library: Download janst123/jsmf library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

janst123 / jsmf example snippets



define('DEV_SERVER', true); // define this 
define('SRC', realpath(dirname(__FILE__) . '/../'));
hp');

  // 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
}