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

1368 questions
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,642
  • 5
  • 31
  • 61
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
  • 54,445
  • 72
  • 197
  • 297
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
  • 891
  • 11
  • 30
9
votes
2 answers

Inherit form or add type to each form

I am searching for an easy way to add a bundle of fields to each form. I have found a way to extend the AbstractType and use the buildForm method to add more fields. When creating the form I give the name of my new type (How to Create a Custom Form…
CSchulz
  • 10,102
  • 9
  • 54
  • 107
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
  • 76,615
  • 21
  • 156
  • 193
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,531
  • 4
  • 36
  • 64
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
  • 629
  • 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,663
  • 4
  • 33
  • 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
  • 271
  • 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
2 answers

How to send a POST request using HTTPie?

I have a basic silex application, and I try to test it using HTTPie. Yet when posting using: http POST http://localhost:1337 data="hello world" The data, that I get from the Request object via: $data = $request->request->get('data'); will always…
k0pernikus
  • 41,137
  • 49
  • 170
  • 286
8
votes
1 answer

How do I create a wildcard route (/something/*) in Silex?

How can I create a route like /something/* where * could be one or mode 'subfolders'? (Using Silex framework) For example: /something/foo or /something/foo/bar The purpose: I need to replicate a Webservice and send a POST request to another URL…
Ricardo Martins
  • 4,793
  • 1
  • 33
  • 50
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
  • 239
  • 1
  • 3
  • 10
8
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,287
  • 3
  • 35
  • 53
8
votes
2 answers

Silex passing app and request to controller classes

I want a simple way to access $app and $request in my controller classes. The document says to do this, public function action(Application $app, Request $request) { // Do something. } but it doesn't look right to have to inject $app and $request…
tdbui22
  • 337
  • 1
  • 3
  • 12
1 2
3
91 92