12 |
Shield Framework Examples
13 |
24 |
25 |
26 | get('/', function() use ($app){
35 |
36 | $app->view->set(array(
37 | 'fake' => '
link text',
38 | 'test' => 'foodles'
39 | ));
40 | return $app->view->render('
41 |
Basic Routing & Escaping
42 |
43 | This route sets two values to the view "fake" & "test". The "fake"
44 | value has HTML in it and is, by default, filtered.
45 |
46 |
Output
47 | index1:
[fake]
48 | ');
49 | });
50 |
51 | /**
52 | * Setting up filters on data (desides the default)
53 | */
54 | $app->get('/filters', function() use ($app){
55 |
56 | $app->view->set(array(
57 | 'test' => $app->input->get('test'),
58 | 'test1' => $app->input->get('test1')
59 | ));
60 |
61 | $app->filter->add(array(
62 | 'test' => 'email',
63 | 'test1' => function($value){
64 | return 'custom filter: '.$value;
65 | }
66 | ));
67 |
68 | return $app->view->render('
69 |
Built-in & Custom Filters
70 |
71 | There are several built-in filtering types including "email", "integer" and "url"
72 | to help you sanitize your data.
73 | You can also add custom filters using PHP\'s closures.
74 |
75 |
Output
76 | TEST1: [test1]
77 | TEST: [test]
78 | ');
79 | });
80 |
81 | /**
82 | * Shows how to use a custom configuration with a route
83 | * NOTE: This page is in an HTML template, so this XML won't render correctly
84 | * (but you get the idea....)
85 | */
86 | $app->get('/cfg', function() use ($app){
87 |
88 | $app->view->set('output','my output');
89 |
90 | return $app->view->render('
91 |
92 |
93 | [output]
94 |
95 | ');
96 |
97 | }, array(
98 | 'view.content-type' => 'text/xml'
99 | ));
100 |
101 | /** Execute the application */
102 | $app->run();
103 | ?>
104 |
105 |
106 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name":"shield/shield",
3 | "type":"library",
4 | "description":"Shield : Microframework, Major Security",
5 | "keywords":["microframework", "rest", "router"],
6 | "homepage":"https://github.com/enygma/shieldframework.git",
7 | "license":"MIT",
8 | "authors":[
9 | {
10 | "name":"Chris Cornutt",
11 | "email":"ccornutt@phpdeveloper.org",
12 | "homepage":"http://www.phpdeveloper.org/"
13 | }
14 | ],
15 | "require":{
16 | "php":">=5.3.1"
17 | },
18 | "autoload":{
19 | "psr-0":{
20 | "Shield":"Shield/"
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------