Issues (16)

exemple/controller/index.php (1 issue)

Labels
Severity
1
<?php
2
3
require dirname(__DIR__, 2) . "/vendor/autoload.php";
4
require __DIR__ . "/Test/Coffee.php";
5
require __DIR__ . "/Test/Name.php";
6
7
use WorkCode\WCRouter\WCRouter;
0 ignored issues
show
The type WorkCode\WCRouter\WCRouter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
define("BASE", "https://www.localhost/workcode/wcrouter/exemple/controller");
10
$router = new WCRouter(BASE);
11
12
/**
13
 * routes
14
 */
15
$router->namespace("Test");
16
17
$router->get("/", "Work:home");
18
$router->get("/edit/{id}", "Coffee:edit");
19
$router->post("/edit/{id}", "Coffee:edit");
20
21
/**
22
 * group by routes and namespace
23
 */
24
$router->group("admin");
25
26
$router->get("/", "Work:admin");
27
$router->get("/user/{id}", "Coffee:admin");
28
$router->get("/user/{id}/profile", "Coffee:admin");
29
$router->get("/user/{id}/profile/{photo}", "Coffee:admin");
30
31
/**
32
 * named routes
33
 */
34
$router->group("name");
35
$router->get("/", "Name:home", "name.home");
36
$router->get("/hello", "Name:hello", "name.hello");
37
38
$router->get("/redirect", "Name:redirect", "name.redirect");
39
$router->get("/redirect/{category}/{page}", "Name:redirect", "name.redirect");
40
$router->get("/params/{category}/page/{page}", "Name:params", "name.params");
41
42
/**
43
 * Group Error
44
 */
45
$router->group("error")->namespace("Test");
46
$router->get("/{errcode}", "Work:notFound");
47
48
/**
49
 * execute
50
 */
51
$router->dispatch();
52
53
if ($router->error()) {
54
    var_dump($router->error());
55
    //router->redirect("/error/{$router->error()}");
56
}