maalls / jmdict-bundle
v1.5.1
2018-10-08 10:37 UTC
Requires
- maalls/heisig-bundle: ^1.0.1
README
需要您设置一个 symfony 4.2. 项目。
安装
将仓库添加到您的 composer.json 文件中。
"repositories": [
{ "type": "vcs", "url": "https://github.com/maalls/jmdictbundle" }
],
运行 composer 命令。
composer require maalls/jmdict-bundle @dev
确保 JMDictBundle 已存在,并将 HeisigBundle 添加到 config/bundles.php
return [ ... Maalls\JMDictBundle\JMDictBundle::class => ['all' => true], Maalls\HeisigBundle\HeisigBundle::class => ['all' => true], ... ];
创建数据库表。
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
将数据加载到数据库中。
php bin/console maalls:jmdict:load-database
如果您已安装 mecab,请将以下内容添加到 config/routing.yml,然后访问 /jmdict/search 以查看可以执行的操作。
maalls_jmdict_bundle:
# loads routes from the YAML or XML files found in some bundle directory
resource: '@JMDictBundle/Controller/'
type: annotation
prefix: /jmdict
示例
获取一个日语单词的英文释义
// returns all the elements matching 世界 $words = $em->getRepository(\Maalls\JMDictBundle\Entity\Word::class)->findBy(["value" => "世界"]); $word = $words[0]; // get all the glossaries related to an element. $senseWords = $word->getSenseWords(); $senseWord = $senseWords[0]; $senseWord->getSense()->getSenseGlossaries();