Skip to content

Instantly share code, notes, and snippets.

@Bolinha1
Created September 13, 2013 15:44
Show Gist options
  • Select an option

  • Save Bolinha1/6552393 to your computer and use it in GitHub Desktop.

Select an option

Save Bolinha1/6552393 to your computer and use it in GitHub Desktop.
Brincando com Silex micro-framework PHP, realizando testes de interação com Controllers e métodos de rotas POST e GET. Exemplo ficticio para aplicação didática.
<?php
// dir myapp/web/index.php
require_once __DIR__.'/../vendor/autoload.php';
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
class ControllerApp
{
public function indexAction()
{
$form = "<form action='index.php/inserir' method='post'>
<input type='text' name='nome' placeholder='DIgite seu nome'>
<input type='submit' value='enviar'>
</form>
";
return $form;
}
public function inserir(Request $request)
{
$nome = $request->get('nome');
return $nome;
}
}
$app = new Application();
$app->get('/', 'ControllerApp::indexAction');
$app->post('/inserir', 'ControllerApp::inserir');
$app['debug'] = 'true';
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment