Recently, we are using the Phalcon 3.3 framework, the local environment is wampserver, and php7.0 is selected. It is found in the project that using curl to request other interfaces of the project or other interfaces of the project report errors. If you switch to php5.6, you can request normally. After trying many methods, you can't solve it. It suddenly occurred to me that Apache uses its own PHP module by default. Would it be for this reason. Then try to run Apache switch in fastcgi mode.
The error reported is:
Error: Access to undeclared static property: Phalcon\Di::$_default in D:\wamp\www\myphalcon\config\services.php on line 35
This is using Apache's default php module
Here's how to switch:
1. Download fastcgi module, open https://www.apachelounge.com/download/ Choose the corresponding VC version to download. I compiled it with VC14, so I chose the VC14 version
2. After downloading and decompressing, copy the mod_fcgid.so file to the Apache installation path modules directory
3, Open the configuration file httpd.conf and add the following code
LoadModule fcgid_module modules/mod_fcgid.so
<IfModule fcgid_module>
FcgidIOTimeout 60
FcgidConnectTimeout 30
FcgidMaxProcesses 8
FcgidOutputBufferSize 64
ProcessLifeTime 240
FcgidMaxRequestsPerProcess 500
FcgidMinProcessesPerClass 0
Options ExecCGI
AddHandler fcgid-script .php
#php installation directory of your project
FcgidWrapper "D:/wamp/bin/php/php7.0.23/php-cgi.exe" .php
</IfModule>
At this time, you need to restart Apache to complete the switch
However, I have configured the virtual host, so I have to make changes to the virtual host
4. Original virtual host configuration
<VirtualHost *:80>
ServerName myphalcon.com
ServerAlias myphalcon.com
DocumentRoot "${INSTALL_DIR}/www/myphalcon/public"
<Directory "${INSTALL_DIR}/www/myphalcon/public/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
After the change (ExecCGI is the options just configured)
<VirtualHost *:80>
ServerName myphalcon.com
ServerAlias myphalcon.com
DocumentRoot "${INSTALL_DIR}/www/myphalcon/public"
<Directory "${INSTALL_DIR}/www/myphalcon/public/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require local
</Directory>
</VirtualHost>
5. Restart Apache
Use curl again to access this project or other local project interfaces, and you can access it normally