We have developed an API with Symfony3 with a MySQL DB for the persistence. We are running this on Wamp (Apache 2.4, MySQL 5.6, PHP 7.0.10).
The API works well most of the time but, sometimes, after a restart, the bootstrap.php.cache throws an exception caused by this notice:
PHP Notice: Undefined variable: _COOKIE in ....
Here is the entire stack trace coming from the Symfony bowels:
14-Feb-2017 07:36:29 UTC PHP Notice: Undefined variable: _COOKIE in C:\xxx\wamp\www\xxx\var\bootstrap.php.cache on line 453
14-Feb-2017 07:36:29 UTC PHP Fatal error: Uncaught TypeError: Argument 4 passed to Symfony\Component\HttpFoundation\Request::createRequestFromFactory() must be of the type array, null given, called in C:\xxx\wamp\www\xxx\var\bootstrap.php.cache on line 453 and defined in > > C:\xxx\wamp\www\xxx\var\bootstrap.php.cache:1268
Stack trace:
#0 C:\xxx\wamp\www\xxx\var\bootstrap.php.cache(453): Symfony\Component\HttpFoundation\Request::createRequestFromFactory(Array, Array, >Array, NULL, Array, Array)
#1 C:\xxx\wamp\www\xxx\web\app.php(15): Symfony\Component\HttpFoundation\Request::createFromGlobals()
#2 {main}
And this is the line where the stack begins:
$request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $server);
It's something strange because, from the stack trace I can know that $_GET, $_POST, and $_FILES are Arrays, but $_COOKIE is not...
Why this var is getting undefined?
Related
PS C:\xampp\htdocs\dashboard-db> php spark serve
PHP Fatal error: Uncaught TypeError: Argument 1 passed to CodeIgniter\HTTP\URI::setScheme() must be of the type string, null given, called in C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php on line 443 and defined in C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\URI.php:749
Stack trace:
#0 C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(443): CodeIgniter\HTTP\URI->setScheme(NULL)
#1 C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(207): CodeIgniter\HTTP\IncomingRequest->setPath('', Object(Config\App))
#2 C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(169): CodeIgniter\HTTP\IncomingRequest->detectURI('REQUEST_URI', ' http://localho...')
#3 C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\Config\Services.php(589): CodeIgniter\HTTP\IncomingRequest->__construct(Object(Config\App), Object(CodeIgniter\HTTP\URI), '', Objec in C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\URI.php on line 749
Fatal error: Uncaught TypeError: Argument 1 passed to CodeIgniter\HTTP\URI::setScheme() must be of the type string, null given, called in C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php on line 443 and defined in C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\URI.php:749
Stack trace:
#0 C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(443): CodeIgniter\HTTP\URI->setScheme(NULL)
#1 C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(207): CodeIgniter\HTTP\IncomingRequest->setPath('', Object(Config\App))
#2 C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(169): CodeIgniter\HTTP\IncomingRequest->detectURI('REQUEST_URI', ' http://localho...')
#3 C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\Config\Services.php(589): CodeIgniter\HTTP\IncomingRequest->__construct(Object(Config\App), Object(CodeIgniter\HTTP\URI), '', Objec in C:\xampp\htdocs\dashboard-db\vendor\codeigniter4\framework\system\HTTP\URI.php on line 749
Sorry for the late answer. You probably solved it but this observation might help others too.
The problem may be due to the app.base URL in the .env file. Typing it such as 'localhost' or 'localhost:8080' will be incorrect, you should try typing 'http://localhost' instead.
enter image description herei'm getting this error and i don't know how to debug this.
Fatal error: Uncaught TypeError: Argument 1 passed to Google\ApiCore\Middleware\RetryMiddleware::Google\ApiCore\Middleware{closure}() must be an instance of Exception, instance of Error given, called in /Users/../Desktop/VISION MAIN/vendor/guzzlehttp/promises/src/Promise.php on line 203 and defined in /Users/../Desktop/VISION MAIN/vendor/google/gax/src/ApiCore/Middleware/RetryMiddleware.php:90
Stack trace:
0 /Users/../Desktop/VISION MAIN/vendor/guzzlehttp/promises/src/Promise.php(203): Google\ApiCore\Middleware\RetryMiddleware->Google\ApiCore\Middleware{closure}(Object(Error))
1 /Users/../Desktop/VISION MAIN/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(2, Object(Error), Array)
2 /Users/../Desktop/VISION MAIN/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
3 /Users/../Desktop/VISION MAIN/vendor/guzzleh in /Users/../Desktop/VISION MAIN/vendor/google/gax/src/ApiCore/Middleware/RetryMiddleware.php on line 90
Request in php file
main.php(call the request php file)
swift code call the main.php
I am frequently getting the following error in Laravel 5.4.
Notice: Undefined variable: _SERVER in
C:\wamp64\www\hxponline\vendor\symfony\http-foundation\Request.php on
line 305
Notice: Undefined variable: _GET in C:\wamp64\www\hxponline\vendor\symfony\http-foundation\Request.php on
line 315
Fatal error: Uncaught TypeError: Argument 1 passed to Symfony\Component\HttpFoundation\Request::createRequestFromFactory()
must be of the type array, null given, called in
C:\wamp64\www\hxponline\vendor\symfony\http-foundation\Request.php on
line 315 and defined in
C:\wamp64\www\hxponline\vendor\symfony\http-foundation\Request.php:2014
Stack trace: #0
C:\wamp64\www\hxponline\vendor\symfony\http-foundation\Request.php(315):
Symfony\Component\HttpFoundation\Request::createRequestFromFactory(NULL,
Array, Array, Array, Array, NULL) #1
C:\wamp64\www\hxponline\vendor\laravel\framework\src\Illuminate\Http\Request.php(59):
Symfony\Component\HttpFoundation\Request::createFromGlobals() #2
C:\wamp64\www\hxponline\public\index.php(53):
Illuminate\Http\Request::capture() #3 {main} thrown in
C:\wamp64\www\hxponline\vendor\symfony\http-foundation\Request.php on
line 2014
Also in the phpmyadmin page I am getting,
Fatal error: Uncaught Error: Call to a member function setCookie() on
null in C:\wamp64\apps\phpmyadmin4.7.4\libraries\ThemeManager.php:260
Stack trace: #0
C:\wamp64\apps\phpmyadmin4.7.4\libraries\common.inc.php(616):
PMA\libraries\ThemeManager->setThemeCookie() #1
C:\wamp64\apps\phpmyadmin4.7.4\sql.php(18):
require_once('C:\wamp64\apps\...') #2 {main} thrown in
C:\wamp64\apps\phpmyadmin4.7.4\libraries\ThemeManager.php on line 260
I couldn't figure out any reason what is the reason for all these errors.
Any help would be really appreciated.
When I am running laravel new blog or any name, I get the following error:
Crafting application...
PHP Fatal error: Uncaught TypeException: Argument 2 passed to GuzzleHttp\Adapter\StreamAdapter::createResponseObject() must be of the type array, null given, called in C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Adapter\StreamAdapter.php on line 67 and defined in C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Adapter\StreamAdapter.php:71
Stack trace:
#0 C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Adapter\StreamAdapter.php(67): GuzzleHttp\Adapter\StreamAdapter->createResponseObject(Object(GuzzleHttp\Message\Request), NULL, Object(GuzzleHttp\Adapter\Transaction), Object(GuzzleHttp\Stream\Stream))
#1 C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Adapter\StreamAdapter.php(52): GuzzleHttp\Adapter\StreamAdapter->createResponse(Object(GuzzleHttp\Adapter\Transaction))
#2 C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Client.php(193): GuzzleHttp\Adapter\StreamAdapter->send(Object(GuzzleHttp\Adapter\Transaction)) #3 C:\U in C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Adapter\StreamAdapter.php on line 71
Fatal error: Uncaught TypeException: Argument 2 passed to GuzzleHttp\Adapter\StreamAdapter::createResponseObject() must be of the type array, null given, called in C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Adapter\StreamAdapter.php on line 67 and defined in C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Adapter\StreamAdapter.php:71
Stack trace:
#0 C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Adapter\StreamAdapter.php(67): GuzzleHttp\Adapter\StreamAdapter->createResponseObject(Object(GuzzleHttp\Message\Request), NULL, Object(GuzzleHttp\Adapter\Transaction), Object(GuzzleHttp\Stream\Stream))
#1 C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Adapter\StreamAdapter.php(52): GuzzleHttp\Adapter\StreamAdapter->createResponse(Object(GuzzleHttp\Adapter\Transaction))
#2 C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Client.php(193): GuzzleHttp\Adapter\StreamAdapter->send(Object(GuzzleHttp\Adapter\Transaction)) #3 C:\U in C:\Users\Felix\AppData\Roaming\Composer\vendor\guzzlehttp\guzzle\src\Adapter\StreamAdapter.php on line 71
I don't understand how this can happen. Here is my PhpInfo file
Thanks
The answer was simple. I was running PHP CLI from PHP7 and not XAMPP/PHP5. Only have to uncomment the extension=php_curl.dll line.
I never use PDO on my project, especially serialize and unserialize. But I got this error.
Fatal error: Class
'Symfony\Component\HttpKernel\Exception\FlattenException' not found in
/var/www/test/mikroskil/mikroweb/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
on line 56 Fatal error: Uncaught exception 'PDOException' with message
'You cannot serialize or unserialize PDO instances' in [no active
file]:0 Stack trace: #0 [internal function]: PDO->__sleep() #1
[internal function]: session_write_close() #2 {main} thrown in [no
active file] on line 0
it's so frustrating. Anybody can help me? It appears suddenly when i refresh my page.
Note :
I have an error before.
I use a form with POST method. And then i put a session on it.
After that, i got this error.
failed to start the session: already started by php ($_session is
set).
I tried to fix that error. But suddenly the page is showing this error
Fatal error: Class
'Symfony\Component\HttpKernel\Exception\FlattenException' not found in
/var/www/test/mikroskil/mikroweb/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
on line 56 Fatal error: Uncaught exception 'PDOException' with message
'You cannot serialize or unserialize PDO instances' in [no active
file]:0 Stack trace: #0 [internal function]: PDO->__sleep() #1
[internal function]: session_write_close() #2 {main} thrown in [no
active file] on line 0
I have recently had this issue and the problem was I was storing my model on session (which has active pdo connection inside) and when the request is done, php automatically try to serialize $_SESSION to store on tmp file.
The main problem is PDO connection can not be serialized. If you encounter this issue, you need to check where do you serialize any object that contains active pdo connection.
I have found this answer.
You just need to clear your Cookies on your browser.
Maybe the previous error has been create a cookies and cannot replace it.
i try to clear all my browser cookies and it successfull !
:)
I had the same error when using Medoo PHP Framework, I realized you cannot encode(serialize) a PDOStatement instances.
In my case I was using PHP json_encode to encode data to be sent to my appliction and part of that data contained the PDOStatement instances - data returned after executing a database operation. I just removed the PDOStatement instances from my data and everything worked okay.
I got this too but reading this question and, especially, zerkms responses helped me locate the problem in my code. Clearing one's cache is not an appropriate response to the problem! Having recently re-vamped my classes to use dependency-injection (?), storing them as session variables is no longer appropriate.