Symfony2: $_POST variables are empty on deployment - symfony

I'm currently working on symfony2 projects. Each time, the deployment process is a real pain in the back (even with the cookbook advices).
I have this strange feature that I can't explain. My post variables are always empty in some bundles of symfony 2, no matter how I access them ($_POST['foo'] or request->get('foo')). This feature is online only. On my local server, it works perfectly well.
Example 1: coresphere console bundle
I'm using the coresphere console bundle to run command line on my ovh remote server. But the bundle commands were never working (no matter what my installation was) ie my post variables were always empty causing each command to crash. I thought that may be an error in some of my other installed bundles was causing the post variables of the console bundle to be empty. So I installed it on an empty symfony2 project (I even removed Acme and of course I tested that everything was working on my local server before uploading the project). The console still didn't work. My only solution (a bad one though) was to hack the javascript console.js of the bundle and transform the post request into get request. It then worked fine. At this stage I thought: "ok may be the problem comes from ajax post request on ovh?"
Example2: A home made bundle for a project
I build a bundle for a project. In this project I don't use ajax post request at all. And still, my post variables are always empty (I remind that locally, everything works just smoothly). For this bundle I'm using FOSUserBundle with HWIOAuthBundle for authentication (if it has anything to do with that?)
Summary
I'm clueless about what is going on and I would like to have some sort of track to follow. Just as a reminder: I'm using an OVH shared server with the performance package. I can use git up there. But I can't really use console command (even in ssh). So that's why I'm using the coresphere console bundle.
Thank you for your help.

I got a solution for my home made bundle:
The problem was coming from my routing.yml file (in app/config). I was using fosjsrouting and it seems that the routing of fosjsrouting needs to be called at the very end of the routing.yml file (in app/config).
See below:
app/config/routing.yml:
... and at the very end:
fos_js_routing:
resource: "#FOSJsRoutingBundle/Resources/config/routing/routing.xml"
However, I still don't understand the problem with the coresphere bundle. This doesn't solve it.

Related

API setup missing something?

I am setting up a web api for the first time and I have another project for reference. It is a .NET framework project that will have a React frontend. I am running it using Visual Studio and IIS Express.
I have no build errors when I start the api project. It has swagger added so I can test database calls, so I know the api itself is working. But I am missing adding something as I am looking to add more security to it.
I am trying to verify authentication and I want to use integrated Windows authentication. When I set a break point, the user in the HttpContext.Current is never set and is never authenticated, so I can't add any authorization filters.
I went back to just the basic empty api project that has the frontend web pages removed to see if I removed something and it shows the same issue. So I either removed it again or I am actually missing adding something.
I am not sure where to look for what is missing, so any pointers would be appreciated.
The left browser is what I am expecting and the right browser is what I am seeing.
I don't need the directory browse turned on, so seeing a 403.14 - Forbidden is fine. But I am clearly missing something to get to that point. Is there a better way to figure out which resource/dependency is causing this error?
I can also see the working version requested url is what I am expecting, but the other is just a /.
Is there a way to resolve that if this is the error?
I can add code snippets if needed, but I haven't yet as I am not sure where the issue is.
I ended up finding the answer using blank test web apis to see what I may have left in that wasn't needed. The project was set up using this option:
After removing the views, etc., to make it strictly an api project. I started removing references (and clearing the associated errors) and seeing what happened with the build after each change.
Under the App_Start folder, there were some additional files that weren't present in the project I had for comparison - FilterConfig, and RouteConfig - which were also called in the Global.asax.
I removed the call in Global.asax for all three and I was able to see the expected http error page.
I dont have enough reputation for a comment, but you got 404 error, which, as you know, means there is nothing on that url. So check the route config and startup.cs Edit: I am on the phone so I didnt saw you already solved it. Good :)

Using SimpleSAMLphp in symfony with composer

I would like to implement the SimpleSamlPHP bundle in my symfony project But, I'm having some issues with the redirect after the login.
Let me explain a little:
I have loaded "simplesamlphp/simplesamlphp" in my composer. So, the bundle sits in the vendor directory.
Then I wrote my own bundle where I configured the simplesaml, made controllers with login actions,...
Everything works (in the sense that I effectively have a button that redirects to the Idp (I configured) and does its thing). But then I get redirected to: http://BASEURL/module.php/saml/sp/saml2-acs.php/IDENTIFIER, which it does not find, because the files are in the vendor bundle.
When reading the documentation carefully, I saw that the baseUrl should point to the simplesaml package. But, because that package is in the vendor, I can't do that.
Is there a way to still use the simpleSAMLphp bundle or do I need to look for a symfony bundle to use simpleSAML?
Thank you.
I highly recommend you to give a try to :
https://www.lightsaml.com
I've tried to do a simple IDP / SP service and it works pretty well and straightforward. Along that I find the website examples also well written so you can start with a base.
If still want to use simplesaml search for "simplesamlphp-bundle" in packagist.org there is at least 3 packages that bundlify this and can help you out to set it up.

Load Javascript just for admin in silverstripe 3.1

Im trying to add some custom javascript to my admin but not having such a good time. What I tried so far is.
Requirements::javascript('../mysite/modules/widgets/widgets/calculator/admin/js/admin.js');
The path is correct because when I do fopen to that it returns true.
I have also tried the following.
LeftAndMain::require_javascript('../mysite/modules/widgets/widgets/calculator/admin/js/admin.js');
Same thing with fopen.
It doesn't give any error niether is it loaded(I checked network tab in dev tools)
The path should be relative to the site root not the cms or framework folders. In other words: 'mysite/modules/widgets/widgets/calculator/admin/js/admin.js'
Depending on your situation, I've had more luck using yml for this. I'm not convinced the dynamic loading always works perfectly on ajax requests. In this case it would look like:
LeftAndMain:
extra_requirements_javascript:
- mysite/modules/widgets/widgets/calculator/admin/js/admin.js

login failure with symfony, still redirected

I am building a Symfony2 project, using FosUserbundle and have a serious security issue. When a user tries to connect, it correctly redirects to the home page when the credentials are correct, but most of the time without actually loading the user, still with the anonymous token, not logged.
It sometimes logs me successfully at the first try, usually after 2-4 attempts, sometimes more. It seems to fail 70 to 80% of the time.
There is no error message at all, everything seems to work just fine, except it doesn't. I cloned my project without FosUser, using the login and security system in the cookbook in the documentation on the Symfony website, still the same.
The application has been developed with Symfony 2.3, but upgrading to 2.6 and 2.7 doesn't solve the problem.
The security code is completely vanilla except to extends my template in one twig file, and the behaviour is still the same without the extends.
The config files have been modified according to the FosUserBundle doc.
I am obviously missing something, but no idea what.
After a couple of week, it stopped doing weird stuff, that is good, but no idea why, that is not so good.
As i have said, the config files are straight out off the official doc. If they were at fault, i think that dozens would have had the same issue.
For the curious, it started doing weird stuff while i was playing with websockets and Ratchet. I don't know if it give an idea to someone as to the why.

display blank page in production

Currently working on Symfony2, I'm trying to make my website work on a server on production environment.
But I get a blank page, it's OK on developpement environment.
Some things I saw :
No log file on app/logs
No specific error on Apache error log
With Firebug, I see a HTTP Error 500 for GET /web/.
Any ideas?
I've seen this happen if you use {{ dump(var) }} and the var has nested arrays. Try removing any dump, and if that does not work, tryign removing any variables you are using in twig to display a static page.
You may want to manually delete the prod cache and install assets again for prod mode. See Symfony Production Checklist for a list of basic steps with D and E covering the cache and assets.

Resources