Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error between two pages #12329

Closed
rchockxm opened this issue Oct 17, 2016 · 9 comments
Closed

Fatal error between two pages #12329

rchockxm opened this issue Oct 17, 2016 · 9 comments
Labels
duplicate Duplicate issue. The duplicate issue is referenced in the comments

Comments

@rchockxm
Copy link

rchockxm commented Oct 17, 2016

I have read this article from https://github.com/phalcon/cphalcon/issues/12056

Expected and Actual Behavior

I want to test the API from A to B, the user will log in from A and see the data from B.

A: test.php

use Phalcon\Mvc\Micro;

$app = new Micro();

$app->post(
    "/",
    function () use ($app) 
    {
        echo "User Post";
    }
);

$app->get(
    "/",
    function () use ($app) 
    {
        echo "User Get";
        echo file_get_contents("http://127.0.0.1/test_phalcon.php");
    }
);

$app->handle();

B: test_phalcon.php

use Phalcon\Mvc\Micro;

$app = new Micro();

$app->post(
    "/",
    function () use ($app) 
    {
        echo "From test.php Post";
    }
);

$app->get(
    "/",
    function () use ($app) 
    {
        echo "From test.php Get";
    }
);

$app->handle();

And response show the error.

User Get
Fatal error: Uncaught Error: Access to undeclared static property: Phalcon\Di::$_default in C:\wamp\www\test_phalcon.php:11

If I just simply use the file_get_contents function in test.php

echo file_get_contents("http://127.0.0.1/test_phalcon.php");

Everything will be fine.

From test.php Get

There is no problem with PHP 5.6.19.

What should I do?

Details

  • Phalcon version: 3.0.1
  • PHP Version: 7.0.4
  • Operating System: Windows 8.1 x64
  • Installation type: WAMP
  • Zephir version (if any):
  • Server: Apache 2.4.18
@Jurigag
Copy link
Contributor

Jurigag commented Oct 17, 2016

This is known bug with windows and apache php handler. To fix this you need to use one of this:

  • vagrant/docer + linux
  • nginx + php-cgi
  • apache + php-cgi

The problem is only with apache and his php handler. If using php-cgi problems disappear.

@rchockxm
Copy link
Author

Hi, Jurigag,

I've changed my test environment to CentOS 7.

Thank you

@Jurigag
Copy link
Contributor

Jurigag commented Oct 17, 2016

No problem, just tbh we not sure what really is causing it, be ause it works on php-cgi, it must be some bug with apache php handler itself. Sine by default wamp and xampp are coming with php-cgi is waste of resources and time to trying to fix this.

And also most likely on production environment no one will use apache + windows + apache php handler.

@rchockxm
Copy link
Author

Yes, our production environment is use CentOS 7+ Nginx + PHP-FPM. I just want to confirm there is a new bug or my code question.

Thanks you for your kindly support.

@Jurigag
Copy link
Contributor

Jurigag commented Oct 17, 2016

This is a not new bug, it was already reported many times.

@sergeyklay
Copy link
Contributor

@Jurigag Could you provide link to the opened issue

@Jurigag
Copy link
Contributor

Jurigag commented Oct 17, 2016

#12056

@sergeyklay
Copy link
Contributor

Thanks

@sergeyklay sergeyklay added the duplicate Duplicate issue. The duplicate issue is referenced in the comments label Oct 17, 2016
@nikolay-mihaylov
Copy link

I can confirm that when using Windows and switching from default Apache PHP Handler to CGI solves the problem as Jurigag suggested! Here is a nice guide how to make the upgrades: https://commaster.net/content/installing-php-fastcgi-and-zend-opcache-xampp-windows

Note: you don't have to do all the steps, I've just added the mod_fcgid.so module in apache/modules and updated my httpd-xampp.conf file. Thats it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Duplicate issue. The duplicate issue is referenced in the comments
Projects
None yet
Development

No branches or pull requests

4 participants