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 | |
// framework/index.php | |
$input = isset($_GET['name']) ? $_GET['name'] : 'World'; | |
header('Content-Type: text/html; charset=utf-8'); | |
printf("Hello %s", htmlspecialchars($input, ENT_QUOTES, 'UTF-8')); | |
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 | |
// framework/tests/indexTest.php | |
use PHPUnit\Framework\TestCase; | |
class IndexTest extends TestCase | |
{ | |
public function testHello() | |
{ | |
$_GET['name'] = 'Fabien'; |
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 | |
// framework/index.php | |
require_once __DIR__.'/vendor/autoload.php'; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
$request = Request::createFromGlobals(); |
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 | |
// a URI requisitada (ex: /about) menos a query string | |
$request->getPathInfo(); | |
// recebe variáveis GET['foo'] e POST['bar'] respectivamente | |
$request->query->get('foo'); | |
$request->request->get('bar', 'valor padrão, caso "bar" no exista'); | |
// recebe variáveis do array $_SERVER |
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 | |
$response = new Response(); | |
$response->setContent('Hello world!'); | |
$response->setStatusCode(200); | |
$response->headers->set('Content-Type', 'text/html'); | |
// configura os cabeçalhos de cache HTTP | |
$response->setMaxAge(10); |
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 // framework/bye.php | |
require_once __DIR__.'/vendor/autoload.php'; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
$request = Request::createFromGlobals(); | |
$response = new Response('Goodbye!'); |
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 // framework/init.php | |
require_once __DIR__.'/vendor/autoload.php'; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
$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 // framework/index.php | |
require_once __DIR__.'/init.php'; | |
$input = $request->get('name', 'World'); | |
$response->setcontent(sprintf('Hello %s', htmlspecialchars($input, ENT_QUOTES, 'UTF-8'))); | |
$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
<?php // framework/bye.php | |
require_once __DIR__.'/init.php'; | |
$response->setContent('Goodbye!'); | |
$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
<?php //framework/front.php | |
require_once __DIR__.'/vendor/autoload.php'; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
$request = Request::createFromGlobals(); | |
$response = new Response(); |