php心得


php心得

php-v8js 安装

  1. 经过pecl install失败,主要是不管是centos7还mac的brew,要么v8的版本太高,要么v8的版本太低,php-v8js无法编译成功;
  2. 手工编译:

gclient sync 遇到下方错误:
NOTICE: You have PROXY values set in your environment, but gsutil in depot_tools does not (yet) obey them. Also, –no_auth prevents the normal BOTO_CONFIG environment variable from being used. To use a proxy in this situation, please supply those settings in a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environment var.

创建如下文件

[root@qidizi v8]# cat ../.boto 
[Boto]
proxy = 192.168.1.80
proxy_port = 8888

再export NO_AUTH_BOTO_CONFIG=/qidizi/v8/.boto 即可解决

安装centos7缺失的命令ERROR: lsb_release not found in $PATHyum redhat-lsb -y

把源码折腾下来了,最后,一句话就把我打发了:


[root@qidizi v8]# ./build/install-build-deps.sh
ERROR: The only supported distros are
 	Ubuntu 14.04 LTS (trusty with EoL April 2022)
 	Ubuntu 16.04 LTS (xenial with EoL April 2024)
 	Ubuntu 18.04 LTS (bionic with EoL April 2028)
 	Ubuntu 19.04 (disco)
 	Ubuntu 19.10 (eoan)
 	Debian 8 (jessie) or later
[root@qidizi v8]# lsb
lsb_release  lsblk        
[root@qidizi v8]# lsb_release -a
LSB Version:	:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 7.7.1908 (Core)
Release:	7.7.1908
Codename:	Core
[root@qidizi v8]# 

到此,本插件暂时放弃,使用node -e 来代替

stream_context_create的坑

<?php

if (empty($_SERVER['REQUEST_URI']))
    exit('DOCUMENT_URI empty');

if (
!preg_match_all(
    '/^\/(https?)\/([^\/]+)\/(\d+)(\/.*)$/i',
    $_SERVER['REQUEST_URI'],
    $ma,
    PREG_SET_ORDER,
    0
)
)
    exit('DOCUMENT_URI invalid format');

$ma = $ma[0];
$url = "{$ma[1]}://{$ma[2]}:{$ma[3]}{$ma[4]}";
$data = [
    '_POST' => $_POST,
    'input' => file_get_contents('php://input'),
    '_COOKIE' => $_COOKIE,
    '_SERVER' => $_SERVER,
];
$data = http_build_query($data);
$data = [
    // 注意,请求https时,并不需要把这里的http修改成https,否则对方将收不到post;这个误解导致我试了好几个小时;php.net讨论区有这个提示;
    'http' => [
        'method' => 'POST',
        'content' => $data,
        'timeout' => 30,
        'header' => [
           // 'Connection: keep-alive',
          //  'Content-Length: '.strlen($data),
          //  'Accept: */*',
           // 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
           // 'Accept-Encoding: gzip, deflate, br',
            // 如果没有这句,nginx就不把它当做一个正常的请求,如post就会被丢掉;这个问题也让我尝试了几个小时,奇怪的是为什么php.net的
            // 例子总是不存在这个问题,可能是nginx认为它不是一个正常的post请求
            "Accept-Language: en-US,en;q=0.9",
        ]
    ]
];
$context = stream_context_create($data);
$result = file_get_contents($url, false, $context);

if ($result === FALSE)
    exit('get_contents===false');

echo $result;

发表于 2020.04.13 16:50:24

前篇:workerman心得

后篇:Mac Lookupviewservice