为 eZ Publish 5+ 应用提供的交互式调试 shell。使用 PsySH。

v2.0 2017-07-12 20:38 UTC

This package is auto-updated.

Last update: 2024-09-07 04:00:37 UTC


README

eZ Debug Shell 是 eZ Platform 的交互式 CLI 调试器。它建立在 PsySH 之上,因此充当了一个 读取-评估-打印循环 (简称 repl)

它允许你在 eZ Publish 应用的上下文中调试实时代码,避免创建 CLI 命令。

安装

全局安装(推荐)

composer global require lolautruche/ezsh:^2.0

v1.0 与 eZ Publish 5.3+ 兼容,而 v2.0 仅与 eZ Platform 兼容。

这将把 ezsh 可执行文件安装到 ~/.composer/vendor/bin 文件夹中。

为了使 ezsh 正常工作而无需麻烦,请确保你在 $PATH 中有 ~.composer/vendor/bin

export PATH=~/.composer/vendor/bin

项目安装

你可以使用 Composer 在你的 eZ 项目中安装 ezsh 二进制文件

composer require lolautruche/ezsh:^2.0

使用方法

Usage:
  ezsh [--siteaccess=<siteaccess_name>] [--env=<env>] [--debug] [--version] [--help] [user_login]

Options:
  --siteaccess    -s SiteAccess to use (e.g. ezdemo_site). If not provided, fallbacks to configured default SiteAccess.
  --env           -e Environment to use (defaults to "dev").
  --debug         -d Use debugging if provided. Debug is always on with "dev" environment.
  --help          -h Display this help message.
  --version       -v Display the PsySH version.
  --config        -c Use an alternate PsySH config file location.
  
  user_login      User login (i.e. username) to use to authenticate against the repository. If not provided, anonymous user will be used.

重要:要使用 ezsh首先需要你位于 eZ 项目根目录

cd /my/ezpublish/root
ezsh --siteaccess=my_siteaccess

这将显示类似以下的内容

Debugging eZ Publish using 'my_siteaccess' SiteAccess, in 'dev' environment.
Psy Shell v0.8.9 (PHP 7.0.19 — cli) by Justin Hileman
>>>

从这里开始,你将能够在项目的上下文中评估任何类型的代码。

可用变量

一些变量已经为你设置好了,例如服务容器、ConfigResolver 和存储库

示例

从调试 shell 中,你可以定义任何类型的函数、循环、条件...
更多信息请参阅 PsySH 文档

Debugging eZ Platform using 'default' SiteAccess, in 'dev' environment.

Psy Shell v0.1.12 (PHP 5.5.15 — cli) by Justin Hileman
>>> $repository
=> <eZPublishCoreSignalSlotRepository_000000001c2171540000000109a6622a #000000005890a1640000000113a69e24> {}
>>> $contentInfo = $contentService->loadContentInfo(2926);
=> <eZ\Publish\API\Repository\Values\Content\ContentInfo #2926, Wheelchair Barleywine {
       id: 2926,
       contentTypeId: 40,
       name: "Wheelchair Barleywine",
       sectionId: 1,
       currentVersionNo: 1,
       published: true,
       ownerId: 14,
       modificationDate: <DateTime #00000000588e6c020000000142ceef3a> {
           date: "2014-08-28 10:32:44.000000",
           timezone_type: 3,
           timezone: "Europe/Paris"
       },
       publishedDate: <DateTime #00000000588e6c0c0000000142ceef3a> {
           date: "2014-08-28 10:32:44.000000",
           timezone_type: 3,
           timezone: "Europe/Paris"
       },
       alwaysAvailable: 0,
       remoteId: "beer-d7nEsv",
       mainLanguageCode: "eng-GB",
       mainLocationId: "2928"
   }

>>> $configResolver->getParameter('languages');
=> [
       "eng-GB"
   ]