Ik heb een vraagje. Is er iemand bekend met Alto Router? Ik gebruik Alto Router voor het eerst maar krijg het niet voor elkaar om een underscore in mijn acties te gebruiken, b.v. double_roomAction.

Ik zou het zeer op prijs stellen als iemand me in de juiste richting kan helpen.Bij voorbaat dank
Ja ik gebruik het ook toevallig.
Zo weet ik toevallig dat je # moet gebruiken na je controller.

dus : Welcome#index = Welcome controller & action is index.

Hier voorbeeld code :
<?php
	/**
	 * Boot up the page.
	 */
	private function _boot() {
		$router = new \AltoRouter();
		$router->setBasePath($this->_basePath);
		
		/**
		 * 
		 * Include the router config file here.
		 * Run a loop to get all routes.
		 * Merge the hard routes and dynamic routes.
		 */
		include SYS.CFG."Routes".EXT;
		/**
		 * Load the dynamic urls in here.
		 */
		$dynamicRoutes = $this->_getDynamicUrls();

		if($dynamicRoutes !== false) : 
			$routes = array_merge($routes, $dynamicRoutes);
		endif;
		
		// pass thrue to route helper.
		require(SYS.HLP.'Routes'.EXT);
		\Routes::setRoutes($routes);
		/**
		 * Map all the routes
		 * @param array [$routes as $key => $route] create all the routes that are availeble.
		 */
		
		foreach($routes as $key => $route) {
			$router->map(
				$route[0]
				, $route[1]
				, $route[2]
				, $key
			);
		}

		$match = $router->match();

		$this->_callToAction($match);
	}

	/**
	 * Call the controller that is required
	 * @param object $match Check if the route matches an controller.
	 */
	private function _callToAction($match) {

		//var_dump($match);

		if ($match === false) {
			
			$this->_Error();
		} else {
			
			list( $controller, $action ) = explode( '#', $match['target'] );
			
			if(file_exists(APP.CON.$controller.EXT)) {
				require APP.CON.$controller.EXT;
			} elseif(file_exists(APP.CON.'Dashboard/'.$controller.EXT)) {
				require APP.CON.'Dashboard/'.$controller.EXT;
			} else {
				$this->_Error();
				exit();	
			}
			$obj = new $controller();
			call_user_func_array(array($obj,$action), array($match['params']));
		}

	}
?>


Deze code gebruik ik in mijn bootstrap.
hopelijk kun je er wat mee !
Hoi Wouter hartelijk dank voor je reactie. Ik weet niet zeker of ik begrijp wat je bedoelt?

en dit is een voorbeeld van een van de routes:

'/rooms/[a:action]?/[i:id]?' => [
'controller' => 'Controller_Rooms',
'action' => 'index'
],


Bij voorbaat dank

Reageren