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
15
votes
3 answers

How to autoload classes without namespaces with Composer without reinstalling?

I just need to autoload some classes, and I don't like the psr-0 namespace insanity (no offense). This used to work just fine in my project: "psr-0": { "": [ "app/controller/", "app/model/" ] } For some reason it doesn't…
ChocoDeveloper
  • 12,930
  • 19
  • 74
  • 113
14
votes
3 answers

Backbone.js and REST api with Silex (PHP)

lets say I have a model called John with those params: { Language : { code : 'gr', title : 'Greek' }, Name : 'john' } So now when I trigger John.save() it POST those to server: post params…
panosru
  • 2,229
  • 2
  • 25
  • 36
14
votes
3 answers

openssl encypt/decrypt inconsistently working/failing

I'm seeing some weird behaviour with the openssl_* methods in PHP. 50% of the time, it will fail, throwing Unknown cipher algorithm, and the other 50% of the time, it will correctly encode my data. Here's the relevant snippet from my code: $iv =…
Tyler Sebastian
  • 7,244
  • 5
  • 33
  • 56
14
votes
2 answers

Silex: Redirect with Flash Data

I need to redirect one page to another with a message in Silex. Hopefully there's a Laravelesque way of doing it, but I highly doubt it: $app->redirect('/here', 301)->with('message', 'text'); I'd then want to display the message in my template: {{…
Mike Rockétt
  • 8,617
  • 4
  • 40
  • 81
13
votes
5 answers

How do you register a namespace with Silex autoloader

I'm experimenting with creating an extension with the Silex php micro framework for user authentication but I can't seem to get the autoloader to work. Can anyone shed any light? I have a directory structure like this (truncated) usertest |_lib |…
meouw
  • 40,162
  • 10
  • 48
  • 67
13
votes
3 answers

Silex - Twig_Error_Syntax: The function "path" does not exist

According to the Silex documentation: Symfony provides a Twig bridge that provides additional integration between some Symfony2 components and Twig. Add it as a dependency to your composer.json file. I include the following in my composer.json…
Jimbo
  • 24,043
  • 14
  • 77
  • 118
13
votes
1 answer

Unexpected character in input: '\' (ASCII=92) state=1 in a Silex Application

I moved my website from local to a hosting, and something happened to me. I include this config file into my index.php (it's the first thing I do):
Sergi Juanola
  • 6,273
  • 7
  • 52
  • 88
12
votes
1 answer

Dynamic CSS/Javascript in Twig using Silex/SilexExtensions and Assetic

What I want to do: Get CSS properties from a database and dump it into a less file. Then apply a less/yui compress-filter on it and dump the output in my twig template. Let me just come to the point right away: I have a PHP web application using…
mayrs
  • 2,164
  • 2
  • 23
  • 34
12
votes
1 answer

Is this data being overwritten by another component?

I'm doing some programming in Silex with the symfony components and I think I have found a bug with the symfony/serializer and the symfony/validator components. First let me explain what I'm traing to achieve, then let's go to the code. My objective…
jlHertel
  • 198
  • 2
  • 9
11
votes
4 answers

Bootstrap 3: formatted checkboxes with Symfony & Twig

How to create a formatted group of checkboxes as described in the Bootstrap documentation using the Symfony Form Factory and Twig? Using something like
{{ form_label(form.sample) }}
Ralf Hertsch
  • 1,267
  • 1
  • 10
  • 15
11
votes
2 answers

Symfony security return 401 response instead of redirect

I'm writing an ajax application with ajax authentication and now I started using the symfony security component in silex to handle authentication/authorization. Doing a simple test with a simple configuration, I go to a protected area by the…
olanod
  • 29,200
  • 7
  • 39
  • 73
11
votes
1 answer

Add headers to every response

How can I "automatically" add a header to every response with Silex? So far I have to do following with every response: $app->post('/photos'), function () use ($app) { return $app->json(array('status' => 'success'), 200,…
John B.
  • 1,869
  • 5
  • 21
  • 21
11
votes
1 answer

Silex SwiftMailer Not Making SMTP Connection Upon Execution

I am making a console application which uses the SwiftMail extension to send. Due to our policy, I have two virtual machines, one which serves as a SMTP relay and the other which is the application server. Sending mail manually through telnet to the…
Mike Mackintosh
  • 13,156
  • 6
  • 54
  • 83
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,600
  • 3
  • 19
  • 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
  • 19,567
  • 17
  • 69
  • 108
1
2
3
91 92