Skip to content

Instantly share code, notes, and snippets.

@VTacius
Last active August 29, 2015 14:16
Show Gist options
  • Save VTacius/010b02d227b77e5237a2 to your computer and use it in GitHub Desktop.
Save VTacius/010b02d227b77e5237a2 to your computer and use it in GitHub Desktop.
Empezando con silex
# Enable rewrite engine and route requests to framework
# Requiere activar el módulo desde consola
# a2enmod rewrite
RewriteEngine On
# Some servers require you to specify the `RewriteBase` directive
# In such cases, it should be the path (relative to the document root)
# containing this .htaccess file
#
# Adecúe esto con la base real de su aplicación si es necesario
#RewriteBase /var/www/
RewriteCond %{REQUEST_URI} \.ini$
RewriteRule \.ini$ - [R=404]
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# http://stackoverflow.com/questions/4576851/simple-problem-with-mod-rewrite-in-the-fat-free-framework
RewriteRule .* /index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
<?php
require_once __DIR__.'/vendor/autoload.php';
$app = new Silex\Application();
$app->get('/hello/{name}', function ($name) use ($app) {
return 'Hello '.$app->escape($name);
});
$app->run();

Instalar los paquetes más básicos para servidor web en Debian. (Desde cero y no hay que preocuparse por resolver dependencias)

aptitude install libapache2-mod-php5 -y

Instalar composer desde consola:

php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin --filename=composer

Empezar el proyecto:

php composer.phar require silex/silex "~1.2"

En la configuración del host en Apache, (En Debian, busque /etc/apache2/sites-enabled/000-default), cambie

AllowOverride None 

por

AllowOverride All 

Cuidado con la directiva Options, que por defecto viene como:

Options Indexes FollowSymLinks MultiViews

Lo mejor será retirar el MultiViews Fuente

Options Indexes FollowSymLinks

Los ficheros .htaccess e index.php mínimo necesarios se muestran a continuación:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment