Skip to content

Instantly share code, notes, and snippets.

@ellefsen
Forked from tommymarshall/routes.php
Created August 17, 2016 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ellefsen/bf2e92df41702502612380aeede24950 to your computer and use it in GitHub Desktop.
Save ellefsen/bf2e92df41702502612380aeede24950 to your computer and use it in GitHub Desktop.
Simple Laravel + Craft integration
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', function()
{
return View::make('hello');
});
// The passed anonymous function is simply the contents
// of craft/public/index.php with a modified $craftPath
Route::get('{route}', function($route)
{
// Path to your craft/ folder
$craftPath = '../../craft';
// Do not edit below this line
$path = rtrim($craftPath, '/').'/app/index.php';
if (!is_file($path))
{
exit('Could not find your craft/ folder. Please ensure that <strong><code>$craftPath</code></strong> is set correctly in '.__FILE__);
}
require_once $path;
})->where('route', '.*');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment