Skip to content

Commit fe1fb50

Browse files
committed
Setup hello world as default example.
1 parent f11ae4d commit fe1fb50

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

template/app/errorHandler.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
function handleError($errno, $errstr, $errfile = '', $errline = '')
4+
{
5+
echo("<br>" . PHP_EOL);
6+
handleErrorOutputLine("ERROR $errno $errstr $errfile, $errline");
7+
// Write a trace
8+
$e = new Exception($errstr, $errno);
9+
$step = 0;
10+
$trace = $e->getTrace();
11+
foreach ($trace as $entry) {
12+
$line = '#' . ++$step . ": {$entry['file']}({$entry['line']})";
13+
handleErrorOutputLine($line);
14+
}
15+
}
16+
17+
/**
18+
* Later I will handle differently for dev/prod
19+
*
20+
* @param $line
21+
*/
22+
function handleErrorOutputLine($line)
23+
{
24+
error_log($line);
25+
echo($line . "<br>" . PHP_EOL);
26+
}
27+
28+
set_error_handler('handleError', E_ALL|E_STRICT);

template/app/src/YourName/YourProject/Controller/DefaultController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@
1313

1414
class DefaultController extends ControllerBase
1515
{
16-
16+
public function homeAction()
17+
{
18+
// variables will continue on into the template
19+
$name = $this->request->get('name');
20+
require_once(APP_LOCATION . '/templates/helloWorld.php');
21+
}
1722
}

template/app/templates/helloWorld.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
<?php require('header.php'); ?>
2-
Hello <?php (isset($params['name'])) ? $params['name'] : 'world'; ?>!
2+
Hello <?php echo(($name) ? $name : 'world'); ?>!
3+
<form action="" method="post">
4+
Your Name:<input type="text" name="name" value="<?php echo htmlspecialchars($name); ?>">
5+
<input type="submit" value="Submit">
6+
</form>
37
<?php require('footer.php'); ?>
File renamed without changes.

template/public_html/index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<?php
2-
require_once("../app/init.php");
2+
require_once ('config.php');
3+
require_once(APP_LOCATION . "/init.php");
34
(new TSetliff\WebAppFramework\Kernel())->route();

0 commit comments

Comments
 (0)