小编Mic*_*ael的帖子

为什么变量没有显示在PhpStorm的调试窗口中?

我有Xdebug,我可以停下来并逐步通过断点。但是它已经到达的变量不会显示在“变量”窗口中。看到图片-变量$test并且$test2不显示。

在此处输入图片说明

我在php.ini中的配置是

[XDebug]
zend_extension = /usr/lib/php/20170718/xdebug.so
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 10000
xdebug.remote_mode = req
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.idekey = "PHPSTORM"
Run Code Online (Sandbox Code Playgroud)

xdebug phpstorm

10
推荐指数
2
解决办法
1169
查看次数

限制或延迟 Google Places API 自动建议

Google Places API Web 服务对非计费帐户有每天 1000 个请求的配额限制。使用搜索框自动建议功能为每次按键提供多个位置时,将很快达到此限制。

<input id="pac-input" class="controls" type="text" placeholder="Search Box">
<div style="height:100%; width:100%;position:absolute;">
<div id="map"></div>
</div>
<script>
  window.onload = initAutocomplete;
  function initAutocomplete() {

            var my_position = new google.maps.LatLng(51.163375, 10.447683);
            var map = new google.maps.Map(document.getElementById('map'), {
              center: {lat: 51.163375, lng: 10.447683},
              disableDoubleClickZoom: true,
              zoom: 9,
              mapTypeId: 'roadmap'
            });

            // Create the search box and link it to the UI element.
            var input = document.getElementById('pac-input');

            var searchBox = new google.maps.places.SearchBox(input);
            map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);

            // Bias the SearchBox results towards current map's …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps google-maps-api-3

5
推荐指数
1
解决办法
2110
查看次数

在Ubuntu 14.04上为PHP 7.1安装phpredis

我的 php -v

PHP 7.1.15-1 + ubuntu14.04.1 + deb.sury.org + 2(cli)(内置:2018年3月6日11:51:39)(NTS)版权所有(c)1997-2018 PHP Group Zend Engine v3. 1.0,版权所有(c)1998-2018 Zend Technologies with Xdebug v2.6.0,Copyright(c)2002-2018,Derick Rethans with Zend OPcache v7.1.15-1 + ubuntu14.04.1 + deb.sury.org + 2,版权所有(c)1999-2018,Zend Technologies

我试过pecl方式

sudo pecl install redis
sudo service php7.1-fpm restart
Run Code Online (Sandbox Code Playgroud)

以及来自https://github.com/phpredis/phpredis的手动方式

phpize
./configure [--enable-redis-igbinary]
make && make install
Run Code Online (Sandbox Code Playgroud)

我确定放了

extension=/usr/lib/php/20170718/redis.so
Run Code Online (Sandbox Code Playgroud)

进入php.ini文件,如我运行时所示 echo phpinfo();

例如

/etc/php/7.1/cli/php.ini
Run Code Online (Sandbox Code Playgroud)

当我运行内置的Web服务器时,我得到了

PHP警告:PHP启动:无法加载动态库'/usr/lib/php/20170718/redis.so' - /usr/lib/php/20170718/redis.so:未定义符号:zend_empty_string在第0行的未知

奇怪的是,PHPStorm自动填充PHP Redis类,所以

$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
Run Code Online (Sandbox Code Playgroud)

我可以点击进入Redis类,看它是正确的.

我想知道它是否是版本差异?也许是因为我使用的是32位?

另一个奇怪的事情是,如果我只是把

extension=redis.so 
Run Code Online (Sandbox Code Playgroud)

php.ini,它似乎在寻找一个较旧的版本

PHP启动:无法加载动态库'/usr/lib/php/20160303/redis.so' …

php redis phpredis ubuntu-14.04

5
推荐指数
2
解决办法
5004
查看次数

如何在要求我在 phpunit.xml 中设置 KERNEL_DIR 的 PHPUnit 中解决此问题?

这是我的 phpunit.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<phpunit
        colors="true"
        convertErrorsToExceptions="true"
        convertNoticesToExceptions="true"
        convertWarningsToExceptions="true"
        stopOnFailure="true"
        strict="true"
        bootstrap="./vendor/autoload.php">
    <testsuites>
        <php>
            <server name="KERNEL_DIR" value="app" />
            <ini name="display_errors" value="true"/>
        </php>
        <testsuite name="Functional Tests">
            <directory>./tests/src/myApp/AppBundle/functional</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./src/</directory>
        </whitelist>
    </filter>
</phpunit>
Run Code Online (Sandbox Code Playgroud)

这是测试类

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class MyTest extends WebTestCase
{
    private $client;

    public function setUp()
    {
        $this->client = static::createClient();
    }
Run Code Online (Sandbox Code Playgroud)

运行测试时,我得到了 setUp 中的一行:

根据https://symfony.com/doc/current/book/testing.html#your-first-functional-test在 phpunit.xml 中设置 KERNEL_DIR 或覆盖 WebTestCase::createKernel() 方法

phpunit functional-testing symfony

4
推荐指数
1
解决办法
7017
查看次数

使用 node-stream-zip 提取 zip 文件时读取错误的文件描述符

我有一个 zip 文件,其中有一个文件夹

1234/pic1.png
1234/pic2.png
1234/data.xlsx
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用 node-stream-zip 提取电子表格(失败,所有文件)。

const StreamZip = require('node-stream-zip');
const zip = new StreamZip({
        file: path.join(downloadsDir, fileToFind),
        storeEntries: true
    });
zip.on('ready', () => {

    if(!fs.existsSync('extracted')) {
        fs.mkdirSync('extracted');
    }

    zip.extract('1234/', './extracted', err => {
        console.log(err);

    });
   zip.close();
});
Run Code Online (Sandbox Code Playgroud)

这产生

EBADF:错误的文件描述符,读取

在提取的文件夹中是 png 文件之一。但是,当按照指南仅提取 xlsx 文件时,似乎 xlsx 文件是导致此错误的原因。

   zip.extract('1234/data.xlsx', './extracted.xlsx', err => {
       console.log(err);       
    });      
Run Code Online (Sandbox Code Playgroud)

是xlsx文件的问题吗?我可以手动打开它。是否与权限有关?节点?这个特别的包?

zip node.js

2
推荐指数
1
解决办法
1105
查看次数