我有一个文件script.js.php.它包含PHP和JavaScript代码(js取决于php).它将作为js文件包含在页面中.
<script type="text/javascript" src="script.js.php"></script>
Run Code Online (Sandbox Code Playgroud)
script.js.php的示例
<?php
require_once 'functions.php'
?>
var vars = {
var1: 'value1',
var2: 'value2',
var2: '<?php echo phpFunction(); ?>'
}
Run Code Online (Sandbox Code Playgroud)
有谁知道,是否有可能PhpStorm在不使用script-tag的情况下在PHP文件中制作高亮的JavaScript代码?
也许有某种伪标签不会影响最终的html/js,但会使PhpStorm hightlight代码"正常",例如
<!-- <section language="javascript">-->
js goes here
<!-- </section> -->
Run Code Online (Sandbox Code Playgroud) 想测试IDE PhpStorm,但我已经陷入导入过程..我正在运行一个带有Zend Framework 2项目的开发服务器,我想通过ftp添加.
一切看起来都不错,我看到项目创建了我的应用程序的整个结构.当我打开文件时,该文件为空.我尝试在远程系统的菜单中点击"从此处下载"但我在传输控制台中收到以下消息.
(只有几个失败的文件)
[15-03-14 12:47] Failed to transfer file '/var/www/vhosts/dev.site.com/composer.json': could not read from "ftp://dev.site.com/composer.json" because it is a not a file.
[15-03-14 12:47] Failed to transfer file '/var/www/vhosts/dev.site.com/composer.lock': could not read from "ftp://dev.site.com/composer.lock" because it is a not a file.
[15-03-14 12:47] Failed to transfer file '/var/www/vhosts/dev.site.com/composer.phar': could not read from "ftp://dev.site.com/composer.phar" because it is a not a file.
Run Code Online (Sandbox Code Playgroud)
怎么了?似乎文件已下载但不是内容?权限等都很好,我可以在Aptana或Zend Studio中添加/编辑这个项目而没有任何问题.
我的项目中有一个流浪汉VM(我的项目已设置好vagrant-vm/sites/myproject)
我的测试在myproject/application/tests,我在phpstorm中设置了以下内容:
By Remote InterpreterPHPUnit配置设置为Path to phpunit.phar我的VM中的路径/home/vagrant/phpunit.phar但是当我运行我的PHPUnit运行配置(PHPUnit不是PHPUnit on Server)时,我得到以下日志:
vagrant://C:/Users/Hugo/Documents/Projects/vagrant-swappy/usr/bin/php /home/vagrant/.phpstorm_helpers/phpunit.php --no-configuration C:\Users\Hugo\Documents\Projects\vagrant-swappy\sites\swappy\application\tests
Testing started at 11:19 ...
PHPUnit 4.1.4 by Sebastian Bergmann.
bash: line 0: cd: C:/Users/Hugo/Documents/Projects/vagrant-swappy/sites/swappy/application/tests: No such file or directory
Cannot open file "C:UsersHugoDocumentsProjectsvagrant-swappysitesswappyapplicationtests.php".
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)
编辑:一些截图:
我使用tslint和默认配置tslint:recommended,我希望尽可能少地适应规则.
某些规则强制执行导入应按字母顺序排列:
src/core/task/TaskMockDecorator.ts[2, 1]: Import sources within a group must be alphabetized.
src/core/task/taskRunner.ts[1, 16]: Named imports must be alphabetized.
Run Code Online (Sandbox Code Playgroud)
我不想自己按字母顺序对输入进行排序.在我禁用linting之前:WebStorm/PhpStorm可以为我做这件事吗?
假设我们有这两种方法:
function superFunction($superhero,array $clothes){
if($superhero===CHUCK_NORRIS){
wear($clothes);
} else if($superhero===SUPERMAN) {
wear($clothes[1]);
}
}
function wear(array $clothes)
{
for($piece in $clothes){
echo "Wearing piece";
}
}
Run Code Online (Sandbox Code Playgroud)
所以我想要实现的是将 PhpStorm 中的断点放入函数中wear,但我想仅当$superhero变量具有我可以做到这一点的值时才被解雇CHUCK_NORRIS。想象一下,该函数superFunction被调用了无数次,并且F9一直按下去会适得其反。
当我在 PhpStorm 中打开一个新的 Laravel 项目时,我被要求运行npm install以安装项目依赖项。我假设 Laravel 有一些 node.js 依赖项,但在 Google 上搜索我找不到明确的答案。
我正在使用 Laravel 5.7
您可以Alt + Click在 PhpStorm 中设置多个光标,但如果您想快速创建一个像这样的列表的数组,那么单击的行太多了:(来自 Sublime Text 3 的示例)
在 Sublime Text 3 中,您只需选择所有行并点击Ctrl + Shift + L,它就会在每行的末尾设置光标,然后您可以点击Home按钮将光标设置在行首或其他位置。
我在文档中找不到任何内容...也许有人知道如何在 PHPStorm 中执行此操作,或者至少知道如何使用宏或其他东西创建一些键盘快捷键?
我刚刚在我的 OSX 上安装了 Xdebug v3.0.0beta1 并尝试在 PhpStorm 2020.1 上使用它,但我得到了这个:
Xdebug: [Config] 设置 'xdebug.remote_enable' 已重命名,请参阅https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_enable 上的升级指南 (请参阅:https : //xdebug.org/docs /errors#CFG-C-CHANGED ) Xdebug: [Config] 设置 'xdebug.remote_host' 已重命名,请参阅https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_host 上的升级指南 (请参阅: https://xdebug.org/docs/errors#CFG-C-CHANGED ) Xdebug: [Config] 设置“xdebug.remote_mode”已重命名,请参阅https://xdebug.org/docs/upgrade_guide 上的升级指南#changed-xdebug.remote_mode (参见:https : //xdebug.org/docs/errors#CFG-C-CHANGED) Xdebug: [Config] 设置 'xdebug.remote_port' 已重命名,请参阅https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_port 上的升级指南
提供的链接只会导致带有错误的图像。
我的问题是要设置的正确设置是什么以及在哪里实际更改它们,因为我的 php.ini 文件中没有关于 xdebug 的任何内容。
我在 GitHub 和 StackOverflow 上读了很多帖子,但没有找到答案。
我有带有 PHP 7.4 和 Xdebug 3 的 Docker 容器。IDE 是 PhpStorm。当我在浏览器中使用 Xdebug 时,Xdebug 工作正常。但是当我在容器中使用 PHP CLI 时,Xdebug 不起作用。
xdebug.ini:
zend_extension=xdebug.so
[xdebug]
xdebug.mode = debug
xdebug.client_port = 9003
xdebug.discover_client_host = 1
xdebug.remote_log=/var/log/xdebug.log
Run Code Online (Sandbox Code Playgroud)
我从容器连接 bash:docker exec -it CONTAINER_NAME bash
并运行例如:bin/console my:command(Symfony)。没有结果,当我添加到配置时xdebug.start_with_request = yes,我可以看到警告:
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(
Run Code Online (Sandbox Code Playgroud)
看起来容器无法与我的主机系统连接,其中 PhpStorm 开放了 9003 端口。但是当在网络服务器上使用相同的配置时它可以工作......
root@31aab3e484e1:/var/www/symfony# php -v
PHP 7.4.13 (cli) (built: …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的 PhpStorm 调试器与 PHPUnit 连接。我正在使用 Docker env,并且 docker PHPUnit 内部工作正常。问题是当我单击“测试”目录 PPM -> 运行测试时
我懂了:
[docker://environment_php_8_fpm:latest/]:php /opt/.phpstorm_helpers/phpunit.php --no-configuration /opt/project/src/tests
Testing started at 16:19 ...
The value of autoloader is specified, but file doesn't exist '/home/kuba/Work/CodeProjects/advertisement-crawler/src/vendor/autoload.php'
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)
我试图在谷歌中找到解决方案,但很难找到有用的东西。
@edit此外,我提供了新路径,在单击刷新新路径后我得到了这个路径是:/opt/project/src/vendor/autoload.php

现在,在 phpstorm 中运行此命令后,我收到了新的错误消息
[docker://environment_php_8_fpm:latest/]:php /opt/.phpstorm_helpers/phpunit.php --configuration /opt/project/src/phpunit.xml
Testing started at 18:48 ...
Fatal error: Uncaught Error: Class "PHPUnit_TextUI_ResultPrinter" not found in /opt/.phpstorm_helpers/phpunit.php on line 231
Error: Class "PHPUnit_TextUI_ResultPrinter" not found in /opt/.phpstorm_helpers/phpunit.php on line 231
Call Stack:
0.0006 …Run Code Online (Sandbox Code Playgroud)