简体   繁体   English

是否可以在没有配置的情况下在PHP框架的Lithium中使用APCu,还是应该更改代码?

[英]Can I use APCu in Lithium of the PHP Framework with no configuration, or should I change the code?

When I setup a lithium project (below process) and start PHP web server, I get an information of Apc disable (Apc ✗) on the framework's welcome page. 当我设置一个锂项目(在下面的过程中)并启动PHP Web服务器时,我在框架的欢迎页面上获得了Apc disable(Apc✗)的信息。

But I run sed -ir "s/'apc'/'apcu'/" libraries/lithium/storage/cache/adapter/Apc.php , then I get Apc enabled (Apc ✓). 但是我运行sed -ir "s/'apc'/'apcu'/" libraries/lithium/storage/cache/adapter/Apc.php ,然后启用了Apc(Apc✓)。

This code change is correctly? 此代码更改正确吗? or not? 或不?

Environment 环境

  • Fedora 26 (x86_64) Fedora 26(x86_64)
  • PHP 7.1.7 (cli) (built: Jul 6 2017 12:10:54) ( NTS ) PHP 7.1.7(CLI)(建立:2017年7月6日12:10:54)(NTS)
  • php-pecl-apcu 5.1.8 php-pecl-apcu 5.1.8
  • Composer version 1.4.2 2017-05-17 08:17:52 作曲者1.4.2版本2017-05-17 08:17:52

Detail: 详情:

$ rpm -qa | grep php
php-pdo-7.1.7-1.fc26.x86_64
php-pecl-apcu-devel-5.1.8-2.fc26.x86_64
php-7.1.7-1.fc26.x86_64
php-mysqlnd-7.1.7-1.fc26.x86_64
php-json-7.1.7-1.fc26.x86_64
php-devel-7.1.7-1.fc26.x86_64
php-cli-7.1.7-1.fc26.x86_64
php-pecl-apcu-5.1.8-2.fc26.x86_64
php-common-7.1.7-1.fc26.x86_64

How to setup of the Lithium, and access the framework's welcome page: 如何设置锂电,并访问框架的欢迎页面:

$ composer.phar create-project --prefer-dist unionofrad/framework app
Installing unionofrad/framework (v1.1.1)
  - Installing unionofrad/framework (v1.1.1): Loading from cache
Created project in app
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing composer/installers (v1.3.0): Loading from cache
  - Installing unionofrad/lithium (v1.1.0): Loading from cache
Writing lock file
Generating autoload files
$ cd app/
$ php -S 0.0.0.0:8080 -t app/webroot index.php

Setting diff 设置差异

.orig file is the backup. .orig文件是备份。

  • /etc/php.ini: /etc/php.ini中:

     $ diff /etc/php.ini.orig /etc/php.ini 460c460,461 < error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT --- > ;error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT > error_reporting = E_ALL 
  • /etc/php.d/40-apcu.ini: /etc/php.d/40-apcu.ini:

     $ diff /etc/php.d/40-apcu.ini.orig /etc/php.d/40-apcu.ini 9a10 > apc.enable_cli=1 

Cases 案例

with a -c /etc/php.ini parameter 使用-c /etc/php.ini参数

Run with the parameter, but it no effect,: 使用参数运行,但没有效果,

$ php -c /etc/php.ini -S 0.0.0.0:8080 -t app/webroot index.php

shows Apc disable (Apc ✗). 显示禁用Apc(Apc✗)。

Install php-pecl-apcu-bc package by dnf makes adapting to Apc ✓. 通过dnf安装php-pecl-apcu-bc软件包可以适应php-pecl-apcu-bc But php-pecl-apcu-bc is "APCu Backwards Compatibility Module"... oh. 但是php-pecl-apcu-bc是“ APCu向后兼容模块” ...哦。

Before installed: 安装前:

$ php -m
[PHP Modules]
apcu
bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
sockets
SPL
sqlite3
standard
tokenizer
zlib

[Zend Modules]

After installed: 安装后:

$ php -m
[PHP Modules]
apc
apcu
bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
sockets
SPL
sqlite3
standard
tokenizer
zlib

[Zend Modules]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM