src/services/Sketchpad.php
public function run($route = '', array $params, array $form = null)
		{
			// set up the router, but don't scan
			$this->init();

			/** @var CallReference $ref */
			$ref = $this->router->getCall($route, $params);

			//vd([$ref, $route, $params]);
            //exit;

			// controller has method
			if($ref instanceof CallReference)
			{
				// test controller / method exists
				try
				{
					new ReflectionMethod($ref->class, $ref->method);
				}
				catch(\Exception $e)
				{
					if($e instanceof \ReflectionException)
					{
						//$sketchpad = str_replace($this->config->route, '', $ref->route) . $ref->method . '/';
						$this->abort($ref->route . '::' . $ref->method . '()', 'method');
					}
				}

				// assign static properties
				Sketchpad::$route = $ref->route . '/' . $ref->method . '/';
				Sketchpad::$params = $ref->params;
				Sketchpad::$form = empty($form) ? null : $form;

				// get controller response or content
				ob_start();
				$response   = $this->exec($ref->class, $ref->method, $ref->params);
				$content    = ob_get_contents();
				ob_end_clean();

				// handle echoed output
				if ($content)
				{
					return $content;
				}

				// handle laravel view responses
				if ($response instanceof \Illuminate\Contracts\View\View)
				{
					return $response;
				}

				// handle laravel json responses
				if ($response instanceof \Illuminate\Http\JsonResponse)
				{
					return json($response->getData());
				}

				// handle Arrrayable
				if ($response instanceof \Illuminate\Contracts\Support\Arrayable)
				{
					return json($response->toArray());
				}

				// handle Jsonable
				if ($response instanceof \Illuminate\Contracts\Support\Jsonable)
				{
					return json(json_decode($response->toJson()));
				}

				// anything else send as JSON (classes, objects, arrays, numbers, strings, booleans)
				return json($response);
			}

			// if there's not a valid controller or method, it's a 404
			$this->abort($route, 'path');
			return false;
		}
public function run($route = '', array $params, array $form = null)
		{
			// set up the router, but don't scan
			$this->init();

			/** @var CallReference $ref */
			$ref = $this->router->getCall($route, $params);

			//vd([$ref, $route, $params]);
            //exit;

			// controller has method
			if($ref instanceof CallReference)
			{
				// test controller / method exists
				try
				{
					new ReflectionMethod($ref->class, $ref->method);
				}
				catch(\Exception $e)
				{
					if($e instanceof \ReflectionException)
					{
						//$sketchpad = str_replace($this->config->route, '', $ref->route) . $ref->method . '/';
						$this->abort($ref->route . '::' . $ref->method . '()', 'method');
					}
				}

				// assign static properties
				Sketchpad::$route = $ref->route . '/' . $ref->method . '/';
				Sketchpad::$params = $ref->params;
				Sketchpad::$form = empty($form) ? null : $form;

				// get controller response or content
				ob_start();
				$response   = $this->exec($ref->class, $ref->method, $ref->params);
				$content    = ob_get_contents();
				ob_end_clean();

				// handle echoed output
				if ($content)
				{
					return $content;
				}

				// handle laravel view responses
				if ($response instanceof \Illuminate\Contracts\View\View)
				{
					return $response;
				}

				// handle laravel json responses
				if ($response instanceof \Illuminate\Http\JsonResponse)
				{
					return json($response->getData());
				}

				// handle Arrrayable
				if ($response instanceof \Illuminate\Contracts\Support\Arrayable)
				{
					return json($response->toArray());
				}

				// handle Jsonable
				if ($response instanceof \Illuminate\Contracts\Support\Jsonable)
				{
					return json(json_decode($response->toJson()));
				}

				// anything else send as JSON (classes, objects, arrays, numbers, strings, booleans)
				return json($response);
			}

			// if there's not a valid controller or method, it's a 404
			$this->abort($route, 'path');
			return false;
		}
public function run ( $ route = '' , array $ params , array $ form = null ) { // set up the router, but don't scan $ this -> init ( ) ; /** @var CallReference $ref */ $ ref = $ this -> router -> getCall ( $ route , $ params ) ; //vd([$ref, $route, $params]); //exit; // controller has method if ( $ ref instanceof CallReference ) { // test controller / method exists try { new ReflectionMethod ( $ ref -> class , $ ref -> method ) ; } catch ( \ Exception $ e ) { if ( $ e instanceof \ ReflectionException ) { //$sketchpad = str_replace($this->config->route, '', $ref->route) . $ref->method . '/'; $ this -> abort ( $ ref -> route . '::' . $ ref -> method . '()' , 'method' ) ; } } // assign static properties Sketchpad :: $ route = $ ref -> route . '/' . $ ref -> method . '/' ; Sketchpad :: $ params = $ ref -> params ; Sketchpad :: $ form = empty ( $ form ) ? null : $ form ; // get controller response or content ob_start ( ) ; $ response = $ this -> exec ( $ ref -> class , $ ref -> method , $ ref -> params ) ; $ content = ob_get_contents ( ) ; ob_end_clean ( ) ; // handle echoed output if ( $ content ) { return $ content ; } // handle laravel view responses if ( $ response instanceof \ Illuminate \ Contracts \ View \ View ) { return $ response ; } // handle laravel json responses if ( $ response instanceof \ Illuminate \ Http \ JsonResponse ) { return json ( $ response -> getData ( ) ) ; } // handle Arrrayable if ( $ response instanceof \ Illuminate \ Contracts \ Support \ Arrayable ) { return json ( $ response -> toArray ( ) ) ; } // handle Jsonable if ( $ response instanceof \ Illuminate \ Contracts \ Support \ Jsonable ) { return json ( json_decode ( $ response -> toJson ( ) ) ) ; } // anything else send as JSON (classes, objects, arrays, numbers, strings, booleans) return json ( $ response ) ; } // if there's not a valid controller or method, it's a 404 $ this -> abort ( $ route , 'path' ) ; return false ; }
Initial function that works out the controller, method and parameters to call from the URI string

@param string $route
@param array $params
@param array $form
@return mixed|string
Initial function that works out the controller method and parameters to call from the URI string