Routing package for cekw/wp-plugin-framework-core
Using composer to install plugin dependencies:
composer install
There are several scripts to helps You testing Your code or check code-style:
| Scriptname | Example | Description |
|---|---|---|
| build:cc | composer run build:cc | Generates the coverage files |
| build:cs‑diff | composer run build:cs‑diff | Generates a file that contains difference between Your and a fixed version of code |
| check:cs | composer run check:cs | Check code-style |
| fix:cs | composer run fix:cs | Fix code-style |
| patch:cs‑diff | composer run patch:cs‑diff | Using generated .diff-file to fix code-style |
| start‑server:cc | composer run start‑server:cc | Run local webserver to display generated coverage files |
| test | composer run test | Run unit-tests |
Create a web.php file in config/routes and put the following code in it.
add_action('cekw.wp_plugin_framework.routes', function (\CEKW\WpPluginFramework\Routing\RouteCollector $routes) {
$routes
->add('/foo/', 'foo')
->setController([FooController::class, 'getBar']);
});
$routes
->add('/[en:_lang]?/foo/', 'foo')
->setController([FooController::class, 'getFoo']);
$routes
->add('/[de|en:_lang]/foo/', 'foo')
->setController([FooController::class, 'getFoo']);
$routes
->add([
'' => '/foo/',
'de' => '/bar/',
], 'foo')
->setController([FooController::class, 'getFoo']);