These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use Anax\Route\Exception\NotFoundException; |
||
4 | |||
5 | /** |
||
6 | * Routes to ease development and debugging. |
||
7 | */ |
||
8 | return [ |
||
9 | // Path where to mount the routes, is added to each route path. |
||
10 | "mount" => "dev", |
||
11 | |||
12 | // All routes in order |
||
13 | "routes" => [ |
||
14 | [ |
||
15 | "info" => "Development and debugging information.", |
||
16 | "method" => null, |
||
17 | "path" => "*", |
||
18 | "handler" => function ($di) { |
||
19 | $title = " | Anax development utilities"; |
||
20 | $pages = [ |
||
21 | "" => "index", |
||
22 | "di" => "di", |
||
23 | "request" => "request", |
||
24 | "router" => "router", |
||
25 | "session" => "session", |
||
26 | "view" => "view", |
||
27 | ]; |
||
28 | |||
29 | $path = $di->get("router")->getMatchedPath(); |
||
30 | if (!array_key_exists($path, $pages)) { |
||
31 | throw new NotFoundException(); |
||
32 | } |
||
33 | |||
34 | $page = $di->get("page"); |
||
35 | $page->add( |
||
36 | "anax/v2/dev/{$pages[$path]}", |
||
37 | [ |
||
38 | "mount" => "dev/" |
||
39 | ] |
||
40 | ); |
||
41 | |||
42 | return $page->render([ |
||
43 | "title" => ucfirst($pages[$path]) . $title |
||
44 | ]); |
||
45 | }, |
||
46 | ], |
||
47 | [ |
||
48 | "info" => "Add +1 to session.", |
||
49 | "path" => "session/increment", |
||
50 | "handler" => function ($di) { |
||
51 | $session = $di->get("session"); |
||
52 | $number = $session->get("number", 0); |
||
53 | $session->set("number", $number + 1); |
||
54 | var_dump($session); |
||
0 ignored issues
–
show
Security
Debugging Code
introduced
by
![]() |
|||
55 | return "Reload page to increment 'number' in the session."; |
||
56 | }, |
||
57 | ], |
||
58 | [ |
||
59 | "info" => "Destroy the session.", |
||
60 | "path" => "session/destroy", |
||
61 | "handler" => function ($di) { |
||
62 | $session = $di->get("session"); |
||
63 | var_dump($session); |
||
0 ignored issues
–
show
|
|||
64 | $session->destroy(); |
||
65 | var_dump($session); |
||
66 | return "The session was destroyed."; |
||
67 | }, |
||
68 | ], |
||
69 | ] |
||
70 | ]; |
||
71 |