Symfony routes in App Engine - php

Although we had some difficulties, we finally achieved to make our Symfony 1.4 application work fine in App Engine.
However, we are experiencing a problem related to the routes in Symfony.
From App Engine SDK (localhost) everything works perfect. If we access the URL:
http://localhost:9080/user/create
The parameters "user" and "create" are automatically detected by symfony as the "module" and "action" variables.
But when the application is deployed in App Engine, the same route /user/create does not work. Symfony shows an error message indicating that both the module and action parameters are empty.
Any idea of why these two environments have different behavior or how could it be fixed to get it work in the same way as in App Engine?

Related

Prevent Apigility from conflicting with routes from existing Zend Framework 2 projects

I have an existing Zend Framework 2 project. Now I've been experimenting and considering rebuilding the front end to be entirely AngularJS, as opposed to the now with Zend Framework 2 MvC coupled layouts and views. But for that reason, the models and controller with their respective routes exist and they use services that have a lot of business logic.
If I were to add an API to this existing project through Apigility, say, for external third parties to be able to access account information, how am I supposed to do that without interfering with my current controller routes?
Apigility Admin UI automaticly creates routes appending the base url (www.domain.com/[api url]). This does not directly conflict when I have an AccountController with /account routes and an API route that uses /accounts/[:accountId] but mistakes are bound to happen.
I should use a url like api.domain.com, however Apigility Admin UI adds the routes automaticly and has, as far as I have seen, no option to create a subdomain route through subdomain 'api'. Of course I could modify the automaticly generated routes every time I make changes through Admin UI but that seems like a hassle and prone to error.
While spreading my question around for an answer, someone on the #apigility IRC channel was friendly enough to give me an answer.
I was overthinking this, as dualmon mentioned in the comments. I had thought Apigilty Admin UI was a tool for managing the whole API. nuxwin^ on IRC told me that while Apigility Admin UI does automate routes for you which can be configured with a base url, it's still only meant for development time. It would mean if I were to route my subdomain to a module I could do that after developing the API.
Simple solution, I just had been overthinking that tool demanded me to follow a certain path.

How does redirection is performed by FOSUserBundle for /register route?

After installing and configuring successfully FOSUserBundle for Symfony 2.3.4, I observed that the two routes (path/register and path/register/) both work. In my routing configuration, I only have the route path/register/.
I don't have any .htaccess file associated with my project (which runs under Apache server).
When I inspect under developement tools, I see that path/register gives a 301 Moved Permanently status code and redirects to path/register/ with 200 status code. What is the mechanism/code that allowed this?
Any explanations are highly appreciated.
Edit based on first answer:
I am not trying to understand how routing works, or how to customize my routing. I am trying to understand the mechanism behind redirection (from /register to /register/); Is it implemented somewhere in the core Symfony2 or is it a browser related?
Thank you
Fos user bundle routing is explained in detail here:
https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/routing.md
Here you find a answer
How to customize FOS UserBundle URLs
Generally:
Routing is handled in different ways in Symfony (config files, annotations,...)
Check your routing.yml as a first entry point. Get all available routes by using the console tool:
php app/console route:debug
Annotations usage:
* #Route("/hello/{name}", name="hello")

behat symfony2 facebook api test

im using behat to test my symfony2 projects specifically a test project i have to be a sandbox for my bundles.
One of the bundles to test is my FacebookBundle that integrate facebook api into symfony2 projects. This bundle provide several twig extensions. In the authenticate url of the bundles project i use one of this twig extensions to render the facebook login url but when i test it with behat i get this error:
An exception has been thrown during the rendering of a template ("Notice: Undefined index: HTTP_HOST in /var/www/vendor/facebook/php-sdk/src/base_facebook.php line 1187") in TestBundle:Default:auth.html.twig at line 13.
But i dont see any reason why this is happening, the project work just fine but testing with behat faild.
Any help, thanks
EDIT
Extrange im testing this project on travis and there all behat test pass, see travis: travis-ci.org/bitgandtter/bundles/jobs/37200512
EDIT2
It seams only happend with symfony2 driver for mink, i chage to goutte and work just fine, i review the code and symfony2 driver extend from mink-browse-kit driver, it will be nice to have some configuration options over it, i will keep digging to find the issue

How to route symfony2 404 to symfony1 legacy app

I'm migrating a symfony1.4 application to symfony 2.5, and we need to run both applications simultaneously seamlessly to the end user.
The idea is to land on sf2 app and if a certain route does not exist, then route (fall back) to the sf1 app.
The challenge here is to use the same domain.
For instance:
www.mydomain.com/ > lands on sf2 home page.
www.mydomain.com/contact-us > routes to an existing sf2 controller/view
www.mydomain.com/some-form > does not exists in sf2 app, then it redirects/forwards to the legacy sf1.4 app keeping the same url (user doesn't need to notice the forwarding)
Any ideas on how to best approach this?
Cheers,
Fabian
I think this wrapper bundle was designed for your purpose:
https://github.com/theodo/TheodoEvolutionLegacyWrapperBundle
This bundle allows you to call the legacy framework from Symfony2. Tested and works for legacy app made with symfony 1.4.

Wrapping Zend 1 into Symfony 2. How to share session?

In my job, we are working on migrating our Zend 1 app to Symfony 2. I tried to figure how to do this harmlessly. I found the following SF2 Bundle : https://github.com/mainlycode/Zf1WrapperBundle. I installed it, followed the configuration instructions, copied my Zend app in /vendor/zend and everything is working pretty fine. When I browse my old login route, SF2 can't understand it and ask the response to Zend, and my login form appears. I can log in, and it works, the authed part of the site displays correctly.
Now I want to start revamp a feature where the user needs to be authed. So I created a new SF2 bundle, called BackendBundle. It tried this in my controller :
$securityContext = $this->container->get('security.context');
if( $securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') ){
echo 'AUTHED';
}
But I get the following error :
The security context contains no authentication token. One possible reason may be that there is no firewall configured for this URL.
I totally understand why. But I really dont know how I can "share" the authentification between Zend and SF2.
Any suggestions ?
My first guess was to share the session (configure both ZF and Sf2 to use a similar SessionHandler), but Sf2 stores session information in a very specific way that ZF would probably not support easily.
But I guess you could try to create an Sf2 RequestListener which would read your ZF session, find an auth token in it, then create an Sf2 auth token to finally inject it to the SecurityContext.
What d'you think about that?

Categories