View exec-defer-finally.php
<?php | |
$handle = fopen($location, 'r+'); | |
if ($handle === false) { | |
return false; | |
} | |
try { | |
$firstLine = fgets($handle, 1024); |
View base.html.twig
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>{% block pagetitle %}{{ block('title') }} | MyPage{% endblock %}</title> | |
{% block stylesheets %}{% endblock %} | |
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" /> | |
<meta name="title" content="{% block metatitle %}{{ block('title') }} | MyPage{% endblock %}"/> | |
</head> | |
<body> |
View detect-ajax-request-twig.twig
{% extends app.request.xmlHttpRequest | |
? '::ajax.html.twig' | |
: '::base.html.twig' %} | |
{# contenido #} |
View detect-ajax-request-symfony.php
<?php | |
namespace AppBundle\Controller; | |
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
use Symfony\Component\HttpFoundation\Request; | |
class DefaultController extends Controller | |
{ | |
/** |
View detect-ajax-request-plain.php
<?php | |
//Acciones que calculen el contenido | |
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { | |
//Mostramos el contenido en el formato especifico para las llamadas ajax | |
//Acabamos con un return o un die para evitar seguir ejecutando el codigo | |
} | |
//Mostramos el contenido en el formato normal |
View mockbuilder-post.php
<?php | |
namespace Tests\AppBundle\Manager; | |
use AppBundle\Manager\DocumentManager; | |
class DocumentManagerTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function testAddDocument() | |
{ |
View mockbuilder-pre.php
<?php | |
namespace Tests\AppBundle\Manager; | |
use AppBundle\Manager\DocumentManager; | |
use AppBundle\Document\Post; | |
class DocumentManagerTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function testAddDocument() |
View optimizar-tablas-mysql.php
<?php | |
/** | |
* Configuración de la aplicación | |
* Idealmente en un fichero aparte | |
*/ | |
$dsn = 'mysql:dbname=nuestrabasededatos;host=127.0.0.1'; | |
$user = 'dbuser'; | |
$password = 'dbpass'; |
View htaccess-sin-www
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{HTTP_HOST} !^tudominio.com$ [NC] | |
RewriteRule ^(.*)$ http://tudominio.com/$1 [L,R=301] |
View htaccess-con-www
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{HTTP_HOST} !^www.tudominio.com$ [NC] | |
RewriteRule ^(.*)$ http://www.tudominio.com/$1 [L,R=301] |
NewerOlder