David Flores
#Linux #Drupal #Symfony #WebDeveloper #Silex #OpenSource
David Flores
Co-Mantainer at @DrupalConsole, Linux, Drupal, Symfony, Silex, BackEnd, Seguridad, Python, Open Source, Father ...sometimes #Nerd Speaker
david@indava.com
@dmouse
Silex
Symfony
<?php
function formulario_ingresar_usuarios($config_user,$sec) {
$texto = '';
$texto .= '<form name="formulario_acceso_vista" id="formulario_acceso_vista" method="post" action="index.php?sec='.$sec.'">';
$texto .= '<div class="div_error_login" >';
$error_de_usuario = (isset($_GET["error_usuario"])) ?$_GET["error_usuario"]:'';
if($error_de_usuario == 'si')
{ $texto .= '<span class="error_usuario">'.txt_error_acceso_vista.'</span>'; }
else
{ $texto .= ' '; }
// ...
// bad, bad, bad
}
<?php
function obtenerSeccion() {
if(!isset($_GET["sec"]) || $_GET["sec"]=='')
{$sec = 1;}
else
{ $sec = $_GET["sec"]; }
return (int)$sec;
}
<?php
use Silex\Application;
# Directory
silex
- src
- Application.php
<?php
$callBack = function ($var1, $var2) {
// Do something.
}
$callBack("a", "b");
// Silex
$app->get("/", function() {
// Do something.
});
// Closure
$app->get("/", function() use ($app) {
return $app['twig']->render('index.html.twig');
});
<?php
function autoloadModel($className) {
$filename = "models/" . $className . ".php";
if (is_readable($filename)) {
require $filename;
}
}
function autoloadController($className) {
$filename = "controllers/" . $className . ".php";
if (is_readable($filename)) {
require $filename;
}
}
spl_autoload_register("autoloadModel");
spl_autoload_register("autoloadController");
<?php
$app->get("/", function() {
return "hello world";
});
$app->post("/register", function(Request $request) {
$email = $request->request->get("email");
// save email.
return "Your record has been saved.";
});
$app->match("/login", function() {
// Login method.
})
->methods("GET|POST");
By David Flores