Questions tagged [silex]

Silex is a PHP microframework for PHP >=5.3. It is built on the shoulders of Symfony2 and Pimple and also inspired by Sinatra.

Silex is a PHP microframework for PHP. It is built on the shoulders of and and also inspired by .

As of March 2018, the latest stable release of Silex is 2.2.3. For actual improvements check out the changelog.

Silex became end-of-life in June 2018 and is not maintained anymore. Its advised to now use symfony 4 and flex to replace Silex. More information here: https://symfony.com/blog/the-end-of-silex

Information

A microframework provides the guts for building simple single-file apps. Silex aims to be:

  • Concise: Silex exposes an intuitive and concise API that is fun to use.
  • Extensible: Silex has an extension system based around the Pimple micro service-container that makes it even easier to tie in third party libraries.
  • Testable: Silex uses Symfony's HttpKernel which abstracts request and response. This makes it very easy to test apps and the framework itself. It also respects the HTTP specification and encourages its proper use.

Useful links

1363 questions
10
votes
1 answer

Error When Using Symfony Forms / Silex & Twig

I'm trying to render a Symfony form using twig in a Silex application. I'm using Symfony 2 Form library, Symfony Bridge Twig Forms Extension and Twig. Here is my bootsrap file: require_once __DIR__ . '/../app/silex.phar'; $app = new…
Ben Waine
  • 1,650
  • 3
  • 21
  • 34
9
votes
3 answers

Silex micro-framework and Twig: enable debug

My question: How do I permit use of debug in Twig templates within Silex? I'm playing around with the Silex micro-framework (a PHP framework that leverages Symfony). When using the Twig template system with it I wanted to output a particular…
rg88
  • 20,742
  • 18
  • 76
  • 110
9
votes
2 answers

Routing in Silex/Symfony. Providing a default route

I'm attempting to do something using Silex (which uses the Symfony routing component - so the answer may be applicable to Symfony as well) I am adding Silex to a legacy application to provide routing but I need to respect the existing applications…
calumbrodie
  • 4,722
  • 5
  • 35
  • 63
9
votes
2 answers

Command line Doctrine ORM with Silex: You are missing a "cli-config.php" or "config/cli-config.php" file in your project

I am trying to use Doctrine ORM with Silex, and finding it an altogether frustrating experience, due to the lack of consistent documentation. When I run vendor/bin/doctrine at the console, I get the following output: output: You are missing a…
Homunculus Reticulli
  • 65,167
  • 81
  • 216
  • 341
9
votes
2 answers

How to debug php fatal errors in Silex Framework

I wonder how can I see syntax errors like this (missing semicolon): This will cause a WSOD (white screen of death). I tried to include a debug config file which look like this: use Symfony\Component\Debug\ErrorHandler; use…
Kandinski
  • 953
  • 11
  • 30
9
votes
2 answers

CORS preflight request returning HTTP 405

I am trying to create a RESTful web service and have gotten stuck on implementing PUT requests. I have tried and failed to follow other answers on this site and various articles from Mozilla. The request is generated from the domain wwwtest.dev-box…
Matt K
  • 6,620
  • 3
  • 38
  • 60
9
votes
3 answers

Silex SecurityServiceProvider throws 'Identifier "security.authentication_providers" is not defined.'

I can't figure out how to use SecurityServiceProvider in Silex. My configuration is: $app['security.firewalls'] = array( 'admin' => array( 'pattern' => '^/_admin/.+', 'form' => array('login_path' => '/_admin/', 'check_path' =>…
martin
  • 93,354
  • 25
  • 191
  • 226
9
votes
1 answer

Silex and Doctrine ORM

I am trying to use Silex together with Doctrine ORM (not just DBAL) but I am unable to get the configuration correct. composer.json { "require": { "silex/silex": "1.0.*@dev", "symfony/monolog-bridge": "~2.1", "symfony/twig-bridge":…
kristian nissen
  • 2,809
  • 5
  • 44
  • 68
9
votes
3 answers

Difference between "use" and passing a parameter to controller function

I don't have a specific problem, just looking to deepen my understanding of what's going on with Silex and with some new-ish PHP features in general. This is based off the code samples on the "usage" page of the Silex documentation: $blogPosts =…
patricksayshi
  • 1,395
  • 3
  • 13
  • 18
9
votes
2 answers

Composer autoload not loading class in Silex

I've got a situation using composer to load a class in a Silex app. This class is located at: src/custom/UserProvider.php In my composer.json, I've added this lines: "autoload": { "psr-0": { "CustomNamespace": "src/custom/" …
joaobarbosa
  • 630
  • 5
  • 13
9
votes
2 answers

Where do I store general config parameters in Silex?

I have some general parameters I would like to share all along my application like path information ("baseurl"). Where would you ideally store this information in Silex?
herrjeh42
  • 2,782
  • 4
  • 35
  • 47
9
votes
1 answer

Silex translation stops working when validation is registered

I registered TranslationServiceProvider with YAML and it works fine: $app->register(new TranslationServiceProvider(), array( 'locale_fallback' => 'ru', )); $app['translator'] = $app->share($app->extend('translator', function($translator, $app)…
leemour
  • 11,414
  • 7
  • 36
  • 43
9
votes
2 answers

Run Silex Application in Command Line

I'd like to run a Silex Application like this in Command Line: $app = new Silex\Application(); $app->get('/hello/{name}', function($name) use($app) { return 'Hello '.$app->escape($name); }); $app->run(); I think for that purpose, i'd have…
kertal
  • 281
  • 2
  • 5
  • 20
8
votes
5 answers

Silex form validation without translation

I'd like to use Silex's service providers just to build a simple contact form with validation but it seems to be only with translation service provider because when I render the view I have a Twig_Error_Syntax 'The filter "trans" does not exist', I…
EdUp
  • 190
  • 1
  • 5
8
votes
3 answers

Silex app->redirect does not match routes

Let my application run on localhost, the path is: localhost/silex/web/index.php, defined routes as in the code below, I'd expect visiting localhost/silex/web/index.php/redirect redirects me to localhost/silex/web/index.php/foo and displays 'foo'.…
user2219435
  • 249
  • 1
  • 3
  • 10
1 2
3
90 91