All Questions
527 questions
3
votes
0
answers
657
views
How to replace silex in a project and adapt it to php8
I have this in my project php.
$app = new Silex\Application();
$app->register(new DerAlex\Silex\YamlConfigServiceProvider(realpath(__DIR__ . '/config/settings.yml')));
$app->register(new \Knp\...
0
votes
1
answer
157
views
Silex 2.3 and Symfony 4.4 - Uncaught Error: Call to a member function has() on null
We have an old but very large Silex application using a fork of Silex 2.2.5 and Symfony 3.4. We intend to migrate away from Silex, but the application is still under heavy development from multiple ...
1
vote
0
answers
55
views
Silex Doctrine ORM Create Entity
I am trying to connect the doctrine, but I do not quite understand how I can create entities from the console, so for example, to make it easier to create Many to Many
I have already connected the ...
0
votes
0
answers
850
views
How to disable CSRF checks for html-based forms in Symfony app?
I have this open source Symfony app and I need to disable CSRF checks either globally or at least for some <forms>. Besides 2 methods described below, I also tried removing various lines of code ...
0
votes
0
answers
119
views
Silex with ORM access layer and Entity, how to?
I want to add entities together with Silex. So that I can move the queries out of the controller.
I have created an entity class, but when I call like:
$sql = "SELECT * FROM todos WHERE id = '$id'";
...
0
votes
1
answer
51
views
Why silex don't resolve App in consructor?
When I'm trying to use auto resolving dependencies in constructor I get an error, although in method it works ok.
<?php
namespace App\Controller;
use Silex\Application;
use Symfony\Component\...
0
votes
1
answer
1k
views
How to migrate a tiny Silex application to Symfony 4 with as low effort as possible?
I have a couple backends written as single-file Silex applications - basically the example from https://silex.symfony.com/ just with a couple more routes. No classes, no frills.
Is there any way to ...
0
votes
1
answer
35
views
The "portal_homepage" route must have code to run when it matches error
I am working on a project locally and get a LogicException thrown when trying to access the homepage. The back-end login and front-end login pages work fine, I can login to the back-end without a ...
-1
votes
1
answer
147
views
how to deal with silex end of life for single page REST app
We have a large Silex/Angular app that is essentially a single page REST app. We use Silex security throughout the PHP side.
With the end of life of Silex here, we're trying to figure out the best ...
0
votes
1
answer
574
views
How to convert curl to fopen stream
I am working with a custom Silex (Symphony) CMS.
One of the custom modules uses google/apiclient (https://packagist.org/packages/google/apiclient) module for fetching YouTube video channels and video ...
4
votes
0
answers
640
views
[swagger-codegen][php-symfony] No entrypoint in generated code?
I am attempting to generate a php-symfony server stub using swagger-codgen but I am not getting an index.php (or app.php or anything like that).
When I generate a server stub using the php-silex ...
0
votes
1
answer
68
views
Mount/Use controller in console
In a Silex console command I want to perform a sub-request on a controller route. Unfortunately routes don't seem to be imported when executing a command by default.
I always get the following error:
...
1
vote
1
answer
3k
views
Grouped routes in multiple controllers in Symfony 4
I'm rewriting my Silex-based application to Symfony 4, as the Silex will be deprecated in a while from now. Everything works great so far, but I have a problem with nested routes.
I had lots of ...
0
votes
2
answers
341
views
How can I find unused libraries in a Symfony project with PhpStorm?
I try to find and also to delete all the unused libraries in a project. For example I have a folder lib/ with lot of other folder which are the famous libraries. I want to know how I can identify ...
-1
votes
1
answer
88
views
How to put part of my Controller logic outside my Controller? (one "big" service or multiple services)
Maybe it's a trivial question but I'm beginner with Silex and I don't know how to do it...so here is my situation :
I have a Silex app, everything works but I'm not a big fan of my Controller because ...
1
vote
1
answer
848
views
Cannot override frozen service "twig.app_variable" - Dynamic path to asset function
I understand the error I get but can't figure why...
So here is my problem and why I got this error :
1/ I have a php variable $wdep that give my the path where I need to find my /web file (css, js, ...
3
votes
1
answer
249
views
Silex 2 : Security firewall error with locale (Silex SecurityServiceProvider + Pmaxs\LocaleServiceProvider)
I saw this solution but I can't make it works...
So here is my code, what I tried and what I get :
My code
1/ My Security Provider :
$app->register(new Silex\Provider\SessionServiceProvider());
...
5
votes
4
answers
608
views
Silex : allow user to change langage by clicking on html element and keeping clean URL
I am using Silex and Twig for a website and I want to allow the user to change the langage of the site.
My problem
Right now, it works if I change the locale in the URL :
/my-account: my page ...
1
vote
0
answers
103
views
Doctrine Select with Join -- Silex
I am trying to make a SELECT within a Doctrine join, and am getting Error: Invalid PathExpression. Must be a StateFieldPathExpression.
I have the following Doctrine query, which correctly returns ...
3
votes
0
answers
64
views
Silex infinite-redirect routing issue with mounted ControllerProviders
I am trying to mount a book-register under domain.tld/list which should print the default list when nothing is appended other than /list, but also provide actions including parameters like for example:...
0
votes
1
answer
322
views
Silex basic Authentication -custom failure handler
I'm building an api using Silex and I require the end-user to send credentials via basic authentication http header tag. I want to create a custom authentication failure handler
I tried this but it ...
2
votes
1
answer
230
views
Silex web test fails
I'm trying to write a simple web test to test my silex api using phpunit but
I keep getting this error when i try to run it..
1) App\Tests\BlogControllerTest::testInitialPage
TypeError: Argument 1 ...
0
votes
1
answer
153
views
Assert in silex with defined options
Want to assert a function in Silex with some pre-defined slugs. My idea is to have this code, but to have the choice to add in the slug assert some different assertions as 'about-us', 'contact' and '...
1
vote
1
answer
206
views
Silex, how to translate login error messages?
How to translate security error messages like 'Bad credentials' in Silex?
Currently I show login form using this code from Silex docs https://silex.symfony.com/doc/2.0/providers/security.html:
$...
1
vote
1
answer
77
views
How can I overwrite Yaml variables in Silex
So I have this yaml config file.
And at a certain point I have to overwrite a variable when loaded in $app['config']
But it just don't seem to be possible? Are Yaml variables protected?
$parser = ...
0
votes
1
answer
898
views
How to work with sessions in Silex (Symfony)
My objective is to learn how to work with sessions in Silex 1.2 / Symfony.
First step is to create a session with Session().
I want to store it into $app['session'].
Second step is to access the data ...
1
vote
2
answers
1k
views
Twig generate url / Routing error / Function unknow
I'm using Silex 1.2 and Twig 1.0.
I'm trying to generate an URL with Twig.
<a href="{{ path('signUp') }}">Sign Up</a>
However I get this error :
Twig_Error_Syntax Unknown "path" ...
0
votes
1
answer
104
views
Handle ResourceNotFoundException in Silex
I am trying to refactor an older codebase to use Silex - my thinking was that I could have Silex handle all actions it understands - and defer everything it doesn't to the legacy controller ...
1
vote
0
answers
433
views
Simple Silex/Symfony Form
I am totally green with silex and currently I am trying to follow a documentation and make a simple form. Even while following a official documentation I have an error which I can't handle.
This is ...
-1
votes
1
answer
73
views
Remove script filename from url in silex
I'm trying to remove from the URL bar the index.php script name with htaccess. This is my htaccess file:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteRule ^ index.php [...
0
votes
1
answer
2k
views
How to have twig path() with silex slug?
In silex I have something like
$controllers->get('/{id}', 'Controllers\\Login::index')->bind('login');
when in twig I try to get path('login') I get exception
("Some mandatory parameters are ...
0
votes
1
answer
131
views
Connect silex 2 dbal connect app engine with cloud sql
I lost several hours trying to connect to cloud SQL from PHP flex env, but I found the answer.
I hope this help other people.
An exception occured in driver: SQLSTATE[HY000] [2002] No such file or ...
0
votes
1
answer
294
views
Dynamic database connection in Silex with Doctrine 2
I am trying to do something very similar to this post - Dynamic database connection symfony2 - but with Silex.
I have successfully setup my base database and the one I want to connect to dynamically.
...
1
vote
1
answer
116
views
Rewrite and silex in a subdirectory
I'm completely lost after try and fail for hours with this...
I have an application with Silex inside a dir called "/backend".
The silex app is working correctly in "domain.com/backend/web" and I ...
0
votes
1
answer
229
views
Silex2: Security firewall and locale
How do I add the current locale to paths like /user/login or /user/logout? Controllers do support the '{_locale}' placeholder, but within the security pattern it is reported as an error.
$app['...
0
votes
1
answer
67
views
Symfony Silex : Runing new Silex project
I have a Silex project and I want to start understand how that micro framework work, I've configured the database and I don't know how to update the schema with command line. in the json file I have:
...
0
votes
2
answers
365
views
PHP/MySQL foreign keys saves as id=0 to database
I'm new to php and mysql but there is a project I have to do on my classes with Silex 2.0 and Symfony and I have problems with my php code and foreign keys in my products table in database.
The ...
0
votes
1
answer
115
views
Silex: Security authentication system attempts to run 'login_check' route
I'm trying to configure the authentication system in Silex. However, the following error pops up:
Of course I've been searching for a solution on the internet. But every topic says the 'login_check' ...
2
votes
0
answers
322
views
Silex: Authentication system does not login
I'm trying to implement the authentication system in my Silex project. However, I can't get it working. I've consulted so many websites that covered this system, but combining them all still does not ...
0
votes
1
answer
106
views
Silex - Listeners not executed when dispatching from a test
I've written a class to load some fixtures in DB each time a functional test is executed. These fixtures are created calling a service which after creating some data, dispatches an event so that other ...
1
vote
1
answer
323
views
Silex saving variable on middleware and acces it on controller
I need to get a variable from before on silex, and access it outside the middleware :
$app->before(function (Request $request, Application $app) {
if ($request->getMethod() !== "OPTIONS") ...
0
votes
0
answers
1k
views
Custom 404 in Silex
Trying to have my own 404 error twig page on Silex, I'm having problems while I'm rendering the template. I guess should be an authentication problem, but can't find where and what :/
This is my app....
1
vote
1
answer
50
views
Twig and Silex, generating dynamic forms
I'm trying to generate a form on Twig using two for loops to generate the names and every form element. For some reason I'm getting some expression problem, but really can't find the issue. Maybe ...
0
votes
1
answer
137
views
Symfony/Silex: Remove prefix and suffix (code [...]) of validation message
I can change the message of the validation, or even translate it using the translation component.
$errors = $app['validator']->validate($email, new Assert\Email(array(
'message' => 'The ...
1
vote
1
answer
415
views
Silex 2/Symfony: Check CSRF token from security login form
I do not use the "Form Service Provider" and manually output the CSRF token to my twig login form:
$csrf_token = $app['csrf.token_manager']->getToken('token_id'); //'TOKEN'
And in the login.html....
0
votes
2
answers
842
views
Silex/Symfony Response doesn't returns image data correctly
I want to show Image with the size user requested with PHP.
Working code. No framework.
<?php
require_once __DIR__ . '/vendor/autoload.php';
define('BASE_SIZE', 1000);
$original = ...
1
vote
2
answers
275
views
PHP silex Formbuilder and object with array of object
I am using PHP with the Silex framework and after some hours trying to find a satisfying solution I am still blocked with the following problem regarding forms and objects containing array of Objects. ...
1
vote
1
answer
93
views
Define Silex routes as it goes
Is it possible to define Silex routes as the route definition goes. For instance, define the following routes depending on what the previous routes are:
/a/{user}/{app_name}/list/ -> /a/{user}/{...
1
vote
1
answer
263
views
Silex2 : overwrite `checkAuthentication` method of the `DaoAuthenticationProvider` class
Using Silex 2, I am stuck for hours to find a way to overwrite checkAuthentication method of the DaoAuthenticationProvider class?
About the context: I defined an authentication listener and provider ...
0
votes
1
answer
108
views
Silex - check if user is already in database
I'm new with Silex Framework and I tried to put a validation check when a visitor try to register a new account (about its username) to do not abble to save his request in database. I saw we have ...