@Maerlyn "You have folders app and controller, not App and Controller like in your namespace." This made me on the right track ! I have renamed my folders with first letter uppercase and it was worked. But I thought about the Silex vendor wich was working with uppercase namespace...

You should never add your dependencies in your autoload map (composer does that for you). In this case, google PHP API client is not namespaced so composer can't autoload the library using namespaces. In order to use it you just need to append the root namespaces before the class: <?php...

This parameter is a service id of a token provider to use. Services id are strings (then Symfony looks for the class in the DIC, Silex does the same) so you need to declare a FQDN of your token provider class. By default Symfony uses the Symfony\Component\Security\Core\Authentication\RememberMe\InMemoryTokenProvider class If you...

The session api is quite minimalistic, has no functionality that you need. The quick fix is to retrieve the current value, add to it and then set it again: $foo = $app["session"]->get("foo", array()); $foo[] = $newData; $app["session"]->set("foo", $foo); If you're ready to dive into code, you may also create your...

Sigh, it was a capitalization issue. My macbook has a case insensitive filesystem and my linux VPS has a case sensitive filesystem so when deploying to Linux I had to capitalize the directories in my project so that Silex could correctly resolve the controllers.

And what is a problem? In the second piece of code db returns the array of associated arrays. and to show each item from it you have to use some kind of loop. The return example you provided is ugly, actually. Why don't you use some template engine (like twig...

So, I've figured this out. As said above, I was getting messages about Exception handling, but Silex and $app->error(Exception $e) should catch exceptions. In fact, exceptions were thrown and being caught properly. In my original question, I mention Xdebug, which was the problem. Xdebug has a setting xdebug.show_exception_trace that when...

Thanks for responding guys, I took another look at the error right before I wanted to post it and I found the problem. I assumed the error was created inside the piece of code I posted above but actually it seemed that this route got mixed up with another one,...

I had to ignore the error by wrapping it with a try/catch block for it to work. It's a dirty solution but worked. try { $twig->addFunction(new \Twig_SimpleFunction('asset', function ($asset) use ($app) { return $app['request_stack']->getMasterRequest()->getBasepath().'/'.$asset; })); } catch (Exception $e) { // do nothing } ...

Silex 2.0 is using Pimple 3.0 which has removed the shared method, now all services are shared by default, if you want a new instance you must call the factory method as stated in the changelog for version 2.0. So if you want a login service you should create it...

Vendor folder is supposed to contain only composer dependencies, so it is for sure a bad design to add some specific classes there manually. You can put your custom Service providers into separate git repositories and use them in your project via composer. Or, if this way too hard to...

The server globals (like $_GET) are populated by Apache. When running the functional test, Apache is skipped so $_GET is not populated anymore. Instead of using the server globals, you should use the Request object to extract the GET parameters. This way, the framework will intercept both the PHPUnit injected...

PHP will use the extension's one. This is because autoloading will only happen if you are attempting to access a class which does not already exist. Extension functions and classes will exist after PHP's startup meaning before the code starts to run. (answers from hek2mgl user)...

What about using some PHP? usort($data, function($a, $b) { return strtotime($a['timestamp']) < strtotime($b['timestamp']) ? -1 : 1; }); If you are getting the data from a database then you should let the database sort it for you. It is a lot faster than doing it yourself....

Silex uses the Symfony Components. You can set the expiration using the migrate method for a certain session. E.g.: $app['session']->migrate(false, 3600); Docs To set the expiration for all sessions: $app['session.storage.options'] = [ 'cookie_lifetime' => 3600 ]; Source...

For that specific case, I solved the problem declaring a base url like so in app.php: $app['customBaseUrl'] = 'https://mybaseurl'; then prefixed all my links with this custom baseUrl. Those links aren't generated by the url() twig function anymore. Not the prettiest way to do it though. I would recommend Artamiel's...

Since the error message says that the error happens in layout.html, I'm guessing it is used on every page even the ones like /login that is not behind a firewall. The error is caused by calling is_granted when not behind a firewall. So there are a few options: Use a...

Having your example in mind, you can send the url as a GET parameter, and check the request for it, instead of checking the referer. Another way would be to store the url in the session before doing the redirect, and then check the session in the route/s you are...

I am not sure that this is correct, but I believe you have to return object of another instance, see this question for details (particularly the answer of igorw) Another option is to intercept the AUTHENTICATION_SUCCESS event of the dispatcher, I tried the following: $app['dispatcher']->addListener(AuthenticationEvents::AUTHENTICATION_SUCCESS , function($authEvent) use ($app) {...

I believe your problem is caused by the way you named your directory controllers. According to the documentation about PSR-4 standard: 5) Alphabetic characters in the fully qualified class name MAY be any combination of lower case and upper case. 6) All class names MUST be referenced in a case-sensitive...

Silex does parameter conversion in controllers (and in controllers only), so in the controllers methods you can type hint and expect to "automatically" have the instance, but not anywhere else. From the official docs: You can (in the controller method) use Request and Silex\Application type hints to get $request and...

I use this Gist to add EntityType field in Silex. But the trick is register the DoctrineOrmExtension form extension by extending form.extensions like FormServiceProvider doc says. DoctrineOrmExtension expects an ManagerRegistry interface in its constructor, that can be implemented extending Doctrine\Common\Persistence\AbstractManagerRegistry as the follow: <?php namespace MyNamespace\Form\Extensions\Doctrine\Bridge; use Doctrine\Common\Persistence\AbstractManagerRegistry; use Silex\Application;...

It's quite simple actually. After you decode your json object, pull_request becomes an array, and therefore if you want to access state you need to refer to pull_request first. One way would be the so called array dereferencing, like this: 'state' => $request->request->get('pull_request')['state'] but in order to use that syntax,...

You should be able to grab the info you want like this: $metadata = $em->getClassMetadata('My\Entity'); $myPropertyMapping = $metadata->getFieldMapping('myProperty'); A "field" in Doctrine is a property of an "entity" that has mapping information, but is not an "association". In other words: if you've defined a @Column annotation in the docblock, it's...

The issue lies in the ControllerCollection's implementation of __call(). The ControllerCollection first checks if it supports the method: if (!method_exists($this->defaultRoute, $method)) { throw new \BadMethodCallException(sprintf('Method "%s::%s" does not exist.', get_class($this->defaultRoute), $method)); } And then it cascades the calls to it's Controllers (it is a Collection of Controllers, afterall): foreach ($this->controllers...

The Silex documentation show the following code as example: $app['twig'] = $app->share($app->extend('twig', function($twig, $app) { $twig->addGlobal('pi', 3.14); $twig->addFilter('levenshtein', new \Twig_Filter_Function('levenshtein')); return $twig; })); I think you should try to add the filter in this way....

Just use the RewriteBase with the correct folder: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /test-project-x/api/ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L] </IfModule> And there you have, your routes now are on the /test-project-x/api folder....

This is just a question of understanding the Request/Response process in Silex. The initialize method in your extension is run before the request cycle starts, to access it you need to register a controller which can then setup routes to handle requests. Here's a simple example. // In Extension.php public...

The problem is that you bypass the security listerner to create the authentiated token by yourself. To create the remember-me cookie, you must trigger the loginSuccess method of your RememberMeServices. $app['security.remember_me.service.my-firewall']->loginSuccess($request, $response, $token); Otherwise, you should implement your own PreAuthenticator : http://symfony.com/doc/current/cookbook/security/api_key_authentication.html...

You use $this inside a closure. Prior to 5.4, the $this could not be used inside the closure. Since 5.4, $this refers to the object that it is declared in. To be able to run your tests in PHP 5.3, you have to use something like: public function register(Application $app)...

Two of your dependencies require different versions of pimple package: silex/silex v1.2.0 requires pimple/pimple ~1.0 dflydev/doctrine-orm-service-provider v2.0.0 requires pimple/pimple >=2.1 You can switch to latest silex or previous version of doctrine-orm-service-provider to resolve this. Look at packagist.org to see available versions with their dependencies: silex, doctrine-orm-service-provider....

To pass an array in a GET request check this answer how to pass an array in GET in PHP?. You can also do that on a POST request, for instance using a form as described here Passing arrays from HTML form to PHP. But in your case it seems...

You can see it being used in line 100, when $app["form.csrf_provider"] is first accessed: $app['form.csrf_provider'] = function ($app) { if (isset($app['session'])) { return new SessionCsrfProvider($app['session'], $app['form.secret']); } return new DefaultCsrfProvider($app['form.secret']); }; Since whatever you pass is ignored and overwritten with the md5 call you mention, correct usage would be: $app->register(new...

I had the same problem. Did you register HttpFragmentServiceProvider before registering the Web Profiler? It is not obvious, but the documentation mentions about it here. It worked nicely for me. Regards...

Oh yeah twig is really nice... I thought I have to link the objects in the controller, but now I simply wrote: {% for teamGroup in teamGroups %} <div class="row row-centered"> <h3 class="text-center">{{ teamGroup.name }}</h3> {% for teamMember in teamMembers %} {% if teamMember.team_group_id is same as(teamGroup.id) %} <div class="col-xs-6...

You need to add your source folder into the composer autoloading (https://getcomposer.org/doc/01-basic-usage.md#autoloading) "autoload": { "psr-4": {"Acme\\": "./"} } In your case the path "./" should work (have not tested), if not you should try to put cms folder into a folder like src and set the path to "src/" Remember...

Ok so here's what I did in case someone wonders: First in my Security folder, I created my own version of the BasicAuthenticationEntryPoint.php <?php /* * Redefinition of the Symfony's BasicAuthenticationEntryPoint */ namespace multikanban\multikanban\Security\Http\EntryPoint; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; /** *...

There is a difference between mounting a collection of routes and simply limiting a route to post. Adding mount means that a collection of routes are being created under specific namespace, in your case that would be /other. Meaning that the default URL for this namespace would be /other/ -...