Last active
October 18, 2019 13:23
-
-
Save tommymarshall/d94db0d1cdb981848d2f to your computer and use it in GitHub Desktop.
Simple Laravel + Craft integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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', '.*'); |
Hi Tommy,
Quick question, do you integrate the craft public folder at all? I am getting the ominous "no input file specified". I've check my homestead.yml and its all good.
nm....I lied.....yml was no good. Its working great.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Few Notes
This also assumes your folder structure as follows:
The final route is a catch-all. If you just wanted to route to Craft's dashboard you could replace the relevant lines with: