Last active
December 16, 2015 16:59
-
-
Save nicosomb/5466955 to your computer and use it in GitHub Desktop.
problem with encoded url by a bookmarklet and routes in silex
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 | |
require_once __DIR__.'/../vendor/autoload.php'; | |
$app = new Silex\Application(); | |
$app->register(new Silex\Provider\TwigServiceProvider(), array( | |
'twig.path' => __DIR__.'/../views', | |
)); | |
$app->register(new Silex\Provider\DoctrineServiceProvider(), array( | |
'db.options' => array( | |
'driver' => 'pdo_sqlite', | |
'path' => __DIR__.'/../storage/poche.sqlite', | |
), | |
)); | |
/** | |
* example of generated url : http://silex.localhost/add/http%3A%2F%2Fsymfony.com%2F for http://symfony.com/ | |
*/ | |
$app->get('add/{url}', function($url) use ($app, $functions) { | |
// ... | |
// some stuff | |
// ... | |
return $app->redirect('/'); | |
})->assert('url', '.+'); | |
$app['debug'] = true; | |
$app->run(); |
ça marche pour http://symfony.com sans encoder le lien
<?php
require_once __DIR__.'/../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Silex\Route;
use Silex\Controller;
$app = new Silex\Application();
$app['debug'] = true;
$route = new Route('/add/{url}',array(),array('url'=>'.+'));
$route->setDefault('_controller', function($url) use ($app) {
return $url;
});
$app['routes']->add('GET_add_url',$route);
$app->run();
merci, je regarde
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The bookmarklet :