This file contains hidden or 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 | |
// ... | |
$routes->add('hello', new Routing\Route('/hello/{name}', array( | |
'name' => 'World', | |
'_controller' => function ($request) { | |
return render_template($request); | |
} | |
))); |
This file contains hidden or 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 | |
// ... | |
/* Define the routes for our application */ | |
$routes = new Routing\RouteCollection(); | |
$routes->add('hello', new Routing\Route('/hello/{name}', array('name' => 'World'))); | |
$routes->add('bye', new Routing\Route('/bye')); | |
/* Set up the context and establish whether this request matches a route */ |
This file contains hidden or 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 | |
/* Import the autoloader and classes from external namespaces */ | |
require_once __DIR__.'/../src/autoload.php'; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
/* Build the request and response objects using HttpFoundation */ | |
$request = Request::createFromGlobals(); | |
$response = new Response(); |
This file contains hidden or 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 | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
/* Using the HTTP Foundation class */ | |
$request = Request::createFromGlobals(); | |
$input = $request->get('name', 'World'); | |
$response = new Response('Hello ' . $input); | |
$response->send(); |
This file contains hidden or 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
{ | |
"require": { | |
"symfony/class-loader": "2.1.*" | |
} | |
} |
This file contains hidden or 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 | |
interface UserProviderInterface | |
{ | |
/** | |
* Loads the user object for the given username. | |
* | |
* @param string $username The username | |
* @return UserInterface | |
* @throws UsernameNotFoundException If the user is not found | |
*/ |
This file contains hidden or 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 | |
interface UserInterface | |
{ | |
/** | |
* Returns an array of strings, where each string is a role that this user has. | |
* | |
* @return Role[] An array containing the roles this user has | |
*/ | |
function getRoles(); |
This file contains hidden or 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 | |
namespace MyCompany\BlogBundle\Entity; | |
use Doctrine\ORM\EntityRepository; | |
// Make sure we include UserProviderInterface | |
use Symfony\Component\Security\Core\User\UserProviderInterface; | |
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; | |
use Symfony\Component\Security\Core\Exception\UnsupportedUserException; |
This file contains hidden or 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 | |
namespace MyCompany\BlogBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
// Add this so that we load the UserInterface class | |
use Symfony\Component\Security\Core\User\UserInterface; | |
class User implements UserInterface // Make sure we implement UserInterface |
This file contains hidden or 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
<form action="{{ path('user_create') }}" method="post" {{ form_enctype(form) }}> | |
{{ form_widget(form) }} | |
<input type="submit" /> | |
</form> |