-
Notifications
You must be signed in to change notification settings - Fork 54
SQL Buddy v2.0: Adding a Route
Gilbert Pellegrom edited this page May 6, 2016
·
2 revisions
Open up bootstrap/routes.php
and add a new route:
$router->add('/example', 'ExampleController::index');
If you need to do anything more complex you can access the underlying RouteCollection instance by doing:
$router->routes()->add(...);
For more info see the Symfony routing docs.
Create a new controller in src/Controllers
with the same name you added in your route. It should look something like:
<?php
namespace SQLBuddy\Controllers;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ExampleController extends BaseController
{
public function index()
{
return $this->view('example');
}
}
If you need it you can type hint Request $request
in the method parameters. Controller methods should return a Symfony Response.
For convenience a view($template, $data = [])
method exists to return a Blade template (in the resources/views
folder).