I've just started using Symfony. I've put a test page (API) together and to get the JSON body being passed in I use Request:getContent(). This works well and as expected on my dev machine (Mac OS X 10.11.4, MAMP with PHP 5.6.10. When I deploy to the test server, Ubuntu Server 16.04 LTS with PHP 7.0.4 it throws the error:
request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Fatal error: Using $this when not in object context" at /var/www/html/symfony_api/var/bootstrap.php.cache line 1008 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Fatal error: Using $this when not in object context at /var/www/html/symfony_api/var/bootstrap.php.cache:1008)"} []
Simply commenting out the request line and using normal PHP to get the body using file_get_contents('php://input') caused the class to work as expected on both machines.
Thanks for any help.
The getContent() metod is not static method of Request class (http://api.symfony.com/2.8/Symfony/Component/HttpFoundation/Request.html#method_getContent), use:
$request->getContent();
Related
I have an application running in my localhost developed in codeigniter. I uploaded to server but the application doesn't run. All credentials have been changed to match the server settings. I have viewed this answers but seem irrelevant to my situation as it is running in localhost: Error message Strict standards: Non-static method should not be called statically in php and Codeigniter Model Fatal error: Using $this when not in object context
The error I'm getting is here:
A PHP Error was encountered
Severity: 8192
Message: Non-static method login::index() should not be called statically
Filename: MX/Controller.php
Line Number: 169
Fatal error: Uncaught Error: Using $this when not in object context in
/var/www/html/stallion/application/modules/admin/controllers/login.php:13
Stack trace: #0
/var/www/html/stallion/application/third_party/MX/Controller.php(169): login::index() #1
/var/www/html/stallion/system/core/CodeIgniter.php(326):
MX_Controller->_remap('index', Array)
#2 /var/www/html/stallion/index.php(203):
require_once('/var/www/html/s...') #3 {main} thrown in
/var/www/html/stallion/application/modules/admin/controllers/login.php on line 13
Thanks.
I'm running this on Ubuntu 14.0 php version 7.0 so I can't understand why it's working in my localhost and on the server I get this error!
I reckon it's a php issue because I just uploaded to a different server and it works fine. Same OS but different php versions
I am working on a Symfony 3.3 based application. I have my project locally installed and installed on a server. My laptop and server are both running Ubuntu 16.04.
On my local machine the prod and dev are both error-free. However when I want to visit the prod on the server I get the following messages in my var/logs/prod.log
php.CRITICAL: Undefined class constant 'HEADER_X_FORWARDED_FOR' {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Undefined class constant 'HEADER_X_FORWARDED_FOR' at /home/webwijs/birdbook/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php:122)"} []
request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Undefined class constant 'HEADER_X_FORWARDED_FOR'" at /home/webwijs/birdbook/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php line 122 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Undefined class constant 'HEADER_X_FORWARDED_FOR' at /home/webwijs/birdbook/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php:122)"} []
It might be important to know that it is an installation upgraded from symfony 3.1.
I had the exact same issue.
Basically I dump the Request filepath and it was the old one from SF3.2 loaded from the var/bootstrap.php.cache loaded instead of the new one in Symfony\Component\HttpFoundation\Request.
Just remove your var/bootstrap.php.cache file then clear your cache and everything will be fine.
I am trying to install opensourcepos from https://github.com/jekkos/opensourcepos
But I am getting this error:
Fatal error: Can't use method return value in write context in D:\Xampp\htdocs\opensourcepos\application\helpers\locale_helper.php on line 67
A PHP Error was encountered
Severity: Compile Error
Message: Can't use method return value in write context
Filename: helpers/locale_helper.php
Line Number: 67
Backtrace:
I followed instructions, this is a brand new install, I'm at a loss...
I'm on WIndows 7, using Localhost with Xampp
The line 67 is question is this one:
if (empty($config->item('thousands_separator')))
When I comment it out, the site loads, but it doesn't work
check readme txt
You are getting following error Message: Can't use method return value in write context saying that you are probably using PHP7 which is not completely supported yet. Check your hosting configuration to verify whether you have a supported PHP version installed
I use JsonRequestTransformerListener service to convert AngularJS request to normal request. In dev env it works fine, in prod env I have this error:
$ php5.3 index.php
PHP Fatal error: Class 'Qandidate\Common\Symfony\HttpKernel\EventListener\JsonRequestTransformerListener' not found in /home/a/appliveorg/thank/app/cache/prod/appProdProjectContainer.php on line 584
I'm using TCPDF to sign son PFD documents.
I was testing the examples via web: http://www.tcpdf.org/examples.php, and they worked fine, but when I downloaded the lib and tested it # localhost I got this error in "example 52":
Fatal error: Call to undefined function openssl_pkcs7_sign() in
C:\xampp\htdocs\pruebas\pdf_firma\tcpdf\tcpdf.php on line 9043
My PHP is Version 5.3.8.
Any has any idea how to fix it?
Openssl must be installed
Enabling the OpenSSL in XAMPP
http://www.php.net/manual/en/openssl.setup.php