1). Starting with PHP5.0, the bytecode caching feature is built in, called Zend Opcache. Because PHP is an explanatory language, the PHP interpreter executes PHP script parsing php script code, generate a series of Zend opcode, then execute bytecode, each HTTP request is this, consumes a lot of resources, using bytecode cache can cache pre-compiled bytecode, reduce response time, Reduce the pressure on system resources.
Enable Zend Opcache
By default, Zend Opcache is not started. If you are compiling PHP yourself, the command must contain the following options when executing:
--enable-opcache
After compiling PHP, you must also specify the extension path of the Zend Opcache in the php.ini file, as follows:
Zend_extension=/path/to/opcache.so
When PHP compiles successfully, the file path of the Zend Opcache extension is displayed immediately. You can use the following command to find the path to this PHP extension
Php-config--extension-dir
Then use the following code to confirm that the extension is working properly
<?phpphpinfo ();
Configuring Zend Opcache
Recommended configuration
Opcache.validate_timestamps = 1//Set as ' 0 ' opcache.revalidate_freq = 0opcache.memory_comsumption in the production environment = 64opcache.interned_strings_buffer = 16opcache.max_accelerated_files = 4000opcache.fast_shutdown = 1
You can visit the official PHP website to view detailed settings.
Using Zend Opcache
1). The production environment can be set opcache.validate_timestamps=0. Required to be set to 1 in the development environment
Built-in HTTP server
1). Start Php-s localhost:4000-c App/config/php.ini
2).. htaccess files are not supported. means that the controller mode is not supported. The front-end controller is used to forward all HTTP requests, which need to be implemented through. htaccess files or rewrite rules.
3). You can use router scripting to achieve the above functionality. However, only a small number of URL rewrite rules are supported php-s localhost:8000 router.php
4). Determine which server is being used:
<?phpif (php_sapi_name () = = = ' Cli-server ') {//php built-in server} else {//other Web server}
Special series
PHP Special Series Directory address: github.com/xx19941215/...
The
PHP feature series is expected to write about 20 articles, mainly summarizes our daily PHP development of easy to ignore the basic knowledge and modern PHP development in the specification, deployment, optimization of some real-life recommendations, as well as the JavaScript language features in-depth study.