| */ $app = (require_once __DIR__ . '/bootstrap/start.php'); /* |-------------------------------------------------------------------------- | Load The Artisan Console Application |-------------------------------------------------------------------------- | | We'll need to run the script to load and return the Artisan console | application. We keep this in its own script so that we will load | the console application independent of running commands which | will allow us to fire commands from Routes when we want to. | */ $app->setRequestForConsoleEnvironment(); $artisan = Illuminate\Console\Application::start($app); /* |-------------------------------------------------------------------------- | Run The Artisan Application |-------------------------------------------------------------------------- | | When we run the console application, the current CLI command will be | executed in this console and the response sent back to a terminal | or another output device for the developers. Here goes nothing! | */ $status = $artisan->run(); /* |-------------------------------------------------------------------------- | Shutdown The Application |--------------------------------------------------------------------------
/** * This function will use the resource cache to lookup all controllers and their methods. Then it * will create a Triumph_Url instance for each method; note that the routes file is * also consulted and we will generate URLs for the default controller. * * @param string $sourceDir the root directory of the project in question * @param string $resourceDbFileName the location of the resource cache SQLite file; as created by Triumph * @param string $host the hostname of the application; this will be used a the prefix on all URLs * @param boolean $doSkip out parameter; if TRUE then this detector does not know how * to detect URLs for the given source directory; this situation * is different than zero URLs being detected. * @return Triumph_UrlTag[] array of Triumph_UrlTag instances the detected URLs */ function detectUrls($sourceDir, $resourceDbFileName, $host, &$doSkip) { $allUrls = array(); if (!is_file($resourceDbFileName)) { return $allUrls; } // need to check that this detector is able to recognize the directory structure of sourceDir // if not, then we need to skip detection by returning immediately and setting $doSkip to TRUE. // by skipping detection, we prevent any detected URLs from the previous detection script // from being deleted. $doSkip = TRUE; // for laravel, we look for the artisan script. if we don't have the artisan script assume // that this source is not a laravel project. $sourceDir = \opstring\ensure_ends_with($sourceDir, DIRECTORY_SEPARATOR); if (!is_file($sourceDir . 'artisan')) { return $allUrls; } $doSkip = FALSE; // load the laravel bootstrap $bootstrapFile = $sourceDir . 'bootstrap' . DIRECTORY_SEPARATOR . 'autoload.php'; $startFile = $sourceDir . 'bootstrap' . DIRECTORY_SEPARATOR . 'start.php'; if (is_file($bootstrapFile) && is_file($startFile)) { require $bootstrapFile; $app = (require_once $startFile); $app->setRequestForConsoleEnvironment(); $artisan = Illuminate\Console\Application::start($app); $router = $app['router']; $routes = $router->getRoutes(); foreach ($routes as $route) { $arr = array('host' => $route->domain(), 'uri' => $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName()); if (!empty($route->domain())) { $url = $route->domain(); } else { $url = $host; } $url .= $route->uri(); // special treatment, we dont want urls to end in double slashes // if the route is the home route'/' if (\opstring\ends_with($url, '//')) { $url = substr($url, 0, -1); } $pos = strpos($route->getActionName(), '@'); $className = ''; $methodName = ''; $fileName = ''; if ($pos !== FALSE) { $className = \opstring\before($route->getActionName(), '@'); $methodName = \opstring\after($route->getActionName(), '@'); // find the file that the class/method are in $pdo = Zend_Db::factory('Pdo_Sqlite', array("dbname" => $resourceDbFileName)); $resourceTable = new Triumph_ResourceTable($pdo); $allMethods = $resourceTable->FindPublicMethod($className, $methodName, $sourceDir); if (count($allMethods)) { $fileName = $allMethods[0]->fullPath; } } $triumphUrl = new Triumph_UrlTag($url, $fileName, $className, $methodName); $allUrls[] = $triumphUrl; } } return $allUrls; }