PHP code example of opdss / nroute

1. Go to this page and download the library: Download opdss/nroute library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

opdss / nroute example snippets


namespace App\Controllers;

use App\Models\Users;
use Slim\Http\Request;
use Slim\Http\Response;

class User
{
	/**
	 * 首页
	 *
	 * @pattern /users
	 * @method get
	 * @middleware \App\Middleware\Auth
	 * @param Request $request
	 * @param Response $response
	 * @param array $args
	 * @return Response
	 */
	public function index(Request $request, Response $response, array $args)
	{
	    return Users::all();
	}
}

$config = array('cacheDir'=>CACHE_DIR, 'forceUseCache'=> true);
\Opdss\Nroute\Nroute::factory($config)->register($app, array(APP_DIR . 'Controllers' => 'App\\Controllers'));