30
loading...
This website collects cookies to deliver better user experience
psysh
をそのまま使ってもいいのですが、今回は psysh-bundle
を利用します。$ ddev composer require --dev theofidry/psysh-bundle:v3.5.1
v3.5.1
を利用しているのは、mautic の 3.3 branch は symfony のバージョンが 3 系のためです。app/AppKernel.php
の修正をするのですが、以下のように 3.3 の branch ではコメントアウト状態ですでに入っています。// Removed temporarily for https://github.com/mautic/mautic/pull/9602, can be re-added in Mautic 4+
// $bundles[] = new Fidry\PsyshBundle\PsyshBundle();
feature
branch でもまだコメントアウトされたままです$ ddev ssh
# ここからはコンテナ内
$ bin/console --env=dev psysh
Psy Shell v0.9.12 (PHP 7.4.20 — cli) by Justin Hileman
New version is available (current: v0.9.12, latest: v0.10.8)
>>>
AppKernel
の修正箇所を見てもらうと分かりますが、 dev
, test
の環境でのみ有効にしているので、コンソールも dev
環境で起動します。(深追いしてないのですが ddev で起動するとデフォルトが prod
になっていたため)>>> ls
Variables: $container, $kernel, $parameters, $self
ls
すると、利用可能な変数が一覧できます。>>> $em = $container->get('doctrine')->getManager();
=> Doctrine\ORM\EntityManager {#625}
>>> $em->getRepository('MauticPluginBundle:Plugin')->findAll();
=> [
Mautic\PluginBundle\Entity\Plugin {#4861},
Mautic\PluginBundle\Entity\Plugin {#4822},
Mautic\PluginBundle\Entity\Plugin {#4825},
Mautic\PluginBundle\Entity\Plugin {#4828},
Mautic\PluginBundle\Entity\Plugin {#4831},
Mautic\PluginBundle\Entity\Plugin {#4834},
Mautic\PluginBundle\Entity\Plugin {#4837},
Mautic\PluginBundle\Entity\Plugin {#4858},
Mautic\PluginBundle\Entity\Plugin {#4855},
Mautic\PluginBundle\Entity\Plugin {#4852},
Mautic\PluginBundle\Entity\Plugin {#4849},
Mautic\PluginBundle\Entity\Plugin {#4846},
]
dump
するとオブジェクトの内容を確認できます。>>> $plugin = $em->getRepository('MauticPluginBundle:Plugin')->find(1);
>>> dump($plugin)
Mautic\PluginBundle\Entity\Plugin {#4861
-id: 1
-name: "Outlook"
-description: "Enables integrations with Outlook for email tracking"
-primaryDescription: null
-secondaryDescription: null
-isMissing: false
-bundle: "MauticOutlookBundle"
-version: "1.0"
-author: "Mautic"
-integrations: Doctrine\ORM\PersistentCollection {#4860
-snapshot: []
-owner: Mautic\PluginBundle\Entity\Plugin {#4861}
-association: array:16 [ …16]
-em: Doctrine\ORM\EntityManager {#625 …11}
-backRefFieldName: "plugin"
-typeClass: Doctrine\ORM\Mapping\ClassMetadata {#2146 …}
-isDirty: false
#collection: Doctrine\Common\Collections\ArrayCollection {#4821
-elements: []
}
#initialized: false
}
#changes: []
#pastChanges: []
}
=> Mautic\PluginBundle\Entity\Plugin {#4861}
>>> $kernel->getBundles();
=> [
"FrameworkBundle" => Symfony\Bundle\FrameworkBundle\FrameworkBundle {#541},
"SecurityBundle" => Symfony\Bundle\SecurityBundle\SecurityBundle {#546},
"MonologBundle" => Symfony\Bundle\MonologBundle\MonologBundle {#550},
"SwiftmailerBundle" => Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle {#27},
"DoctrineBundle" => Doctrine\Bundle\DoctrineBundle\DoctrineBundle {#74},
"DoctrineCacheBundle" => Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle {#549},
....
30