-
Notifications
You must be signed in to change notification settings - Fork 56
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
Error inlcude file (cannot declare class) #174
Comments
Okay, declare error i fixed with
now the question remains, how to initialize variables in init_worker so that they are visible and available for change in other workers, for example, in rewrite |
Please, don't use The problem is basic knowledge of PHP. IncludeIf you include the same file two or more times in a php file, the error will always exist of cannot declare class (function, ...) Try this in any PHP SAPI (php-fpm, cli, ...) function rewrite() {
include "/etc/nginx/php/index.php";
}
rewrite();
rewrite();
.... Ngx-php is embeded PHP in Nginx, so the application is persistent. Once included a file, it isn't necessary to include again or you will have that problems. A simple fix is use NamespacesThe second error ExamplesCheck the files in the Techempower benchmark. Exist examples with global variables, with classes, .... |
Yes, your right. |
Hello! I try execute code on rewrite_block. My code config nginx
file index.php
file memchache.php i take here - https://github.com/rryqszq4/ngx-php-memcached
Log file error.log
I can't figure out how to connect php files correctly and make it so that every time the memory is not connected to the library.
Maybe this can be done in Init_worker?
How can you store data in php memory as it is done for example in Lua via a shared dict? So that I can get data not limited to the scope of the current process, but from another.
Or is only memcached going to help here?
The text was updated successfully, but these errors were encountered: