I'm not sure I'm really qualified to pitch in here, as I'm not much of a developer, but the topic interests me, so...
I run a content-based website. To me, there are essentially two types of pages:
- "Application" or "special" pages -- login, signup, account management, etc.
- Content pages
My workflow for these two types is completely different. In one case, I'm a programmer; in the other, I'm a writer.
My content does not live in a database. I just use files. This means my content is version-controlled (in a separate repository from the code).
For content pages, my url is the file name. That's it. If I want to change the URL, I change the file name. Because this will break links (regardless of how you code it), I also maintain a list of redirects from old file names to new ones.
My routing logic works like this: first check any "special" page routes, such as login. If none are found, look for a content page. If no content is found, 404.
The content pages route is the last one in my routes file. It looks like this:
// No "special" routes match, so try matching a content page
Route::get('{path?}', 'PagesController@index')->where('path', '.+');
The PagesController isn't doing anything particularly special:
class PagesController extends BaseController {
public function index($path)
{
$viewPath = \App::getFacadeRoot()->BBappView;
// Laravel prefers path.file for views, not path/file
$view = 'pages.' . str_replace('/', '.', $viewPath);
// Look for a "normal" page
if ( View::exists($view) )
{
return View::make($view);
}
// ...otherwise look for a directory, and serve its index file
if ( View::exists($view . '.index') )
{
return View::make($view . '.index');
}
// We couldn't find the page, so 404
App::abort(404);
}
The first line with "BBappView" is a bit of a hack to do with my link management (redirects, canonicalisation, etc.).