小编Ben*_*Ben的帖子

Symfony 4 - 服务被删除或内联,虽然它是公开的

我正在尝试使用新的目录结构和所有内容将SF 3.3应用程序迁移到SF 4.

我在这个例外上苦苦挣扎:

编译容器时,"simplethings_entityaudit.reader"服务或别名已被删除或内联.您应该将其公开,或者直接停止使用容器并改为使用依赖注入.

(此服务来自/ vendor中的外部包).

然而,当我bin/console debug:container simplethings_entityaudit.reader看到服务存在并且是公开的时候:

Information for Service "simplethings_entityaudit.reader"
=========================================================

 ----------------- -------------------------------------- 
  Option            Value                                 
 ----------------- -------------------------------------- 
  Service ID        simplethings_entityaudit.reader       
  Class             SimpleThings\EntityAudit\AuditReader  
  Tags              -                                     
  Public            yes                                   
  Synthetic         no                                    
  Lazy              no                                    
  Shared            yes                                   
  Abstract          no                                    
  Autowired         no                                    
  Autoconfigured    no                                    
  Factory Service   simplethings_entityaudit.manager      
  Factory Method    createAuditReader                     
 ----------------- -------------------------------------- 

此服务目前在我自己的一个中调用$this->container->get('simplethings_entityaudit.reader').

我也尝试注入SimpleThings\EntityAudit\AuditReader我的服务构造函数,但这是我得到的:

方法"__construct()"的参数"$ auditReader"引用类"SimpleThings\EntityAudit\AuditReader"但不存在此类服务.它无法自动注册,因为它来自不同的根命名空间.

当我将services.yaml它添加到我的工作中时,我不应该这样做:

SimpleThings\EntityAudit\AuditReader:
    alias: simplethings_entityaudit.reader
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

dependency-injection symfony symfony-flex symfony4

10
推荐指数
4
解决办法
6203
查看次数

为什么composer会删除我对部署的依赖?

我和作曲家有问题.我在当地环境中使用git.我是唯一一个开发人员.

当我需要更多依赖项(或需要更改某些版本)时,我编辑composer.json并在composer install本地运行.

一切安好.

然后,当一切都在本地工作时,我提交我的更改(包括composer.jsoncomposer.lock)并推送到我的生产服务器.

一个后收到-脚本更新的来源和运行composer install在远程服务器上.

预期结果:

  • Composer应根据composer.lock文件安装新的依赖项.
  • 我应该感到高兴.

怎么了 :

  • 作曲家很生气:

警告:锁定文件与composer.json中的最新更改不是最新的.您可能会过时的依赖项.运行更新以更新它们.

  • Composer 删除所有依赖项.
  • 我的作品被打破了.
  • 我心脏病发作
  • 我必须通过ssh登录我的服务器并运行一个composer update以使工作正常,但我知道composer update在生产服务器上不建议使用a.

这是收发后作曲家部分的输出:

composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You …
Run Code Online (Sandbox Code Playgroud)

php git deployment composer-php

8
推荐指数
1
解决办法
343
查看次数

Chrome Headless无法在Ubuntu 16.04上运行

我拼命想让Chrome Headless在我的生产服务器(Ubuntu 16.04)上运行.

当我运行以下命令时:

google-chrome --headless --disable-gpu --dump-dom http://www.example.org/

该DOM会,当我运行它只能倾倒root--no-sandbox标志.与其他用户一起运行时,输出如下:

[0312/110057.072748:ERROR:gpu_process_transport_factory.cc(1019)] Lost UI shared context.
<html><head></head><body></body></html>
Run Code Online (Sandbox Code Playgroud)

我曾尝试与google-chrome-stablechromium-browser,同样的结果:它只能作为root--no-sandbox标志.

我不认为这是一个依赖问题,因为它作为root正常工作.

我已经设置了一个Ubuntu 16.04虚拟机,可以让它与任何用户一起工作,我只是在我的生产服务器上没有成功.

有任何想法吗?

ubuntu chromium google-chrome-headless

7
推荐指数
0
解决办法
1011
查看次数

Api-Platform:在SF 4中使用Yaml配置而不是注释

我想在Api-Platform中使用YAML而不是注释.

我没有使用Api-Platform发行版,而是将api-pack添加到我现有的Symfony Flex项目中(composer req api).

文档说YAML文件应该在,/config/api_platform/resources.yaml但我的实体没有被发现.

我应该在其他地方配置什么?

谢谢你,本

api-platform.com symfony4

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

Symfony 4 - 3rd-party bundle commands are no longer automatically discovered

According to the documentation, a command class must extend Command or ContainerAwareCommand to be automatically discovered and registered (provided its bundle is registered in the Kernel, of course).

Since Symfony 4+, this discovery doesn't work as expected.

Try this:

composer create-project symfony/skeleton test-maxmind-sf4
cd test-maxmind-sf4
composer req cravler/maxmind-geoip-bundle dev-master
php bin/console list
Run Code Online (Sandbox Code Playgroud)

You will notice that:

  • cravler:maxmind:geoip-update is not registered (nothing under a "cravler" namespace
  • Cravler\MaxMindGeoIpBundle\Command\UpdateDatabaseCommand extends ContainerAwareCommand
  • Bundle Cravler\MaxMindGeoIpBundle\CravlerMaxMindGeoIpBundle is registered in config/bundles.php for all environments (auto-generated recipe) …

symfony symfony-console symfony-flex symfony4

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

收集操作的额外数据

有人知道如何在集合上添加额外数据吗?\n该文档详细介绍了如何在项目上添加额外数据,这转化为装饰 ItemNormalizer 服务,并且效果非常好。

\n\n

但是当涉及到在实体集合上添加一些数据时,我\xe2\x80\x99m 努力寻找要装饰的规范化器。额外的数据可以是任何内容:当前登录的用户、详细的寻呼机、一些调试参数……与特定实体无关,而是与请求本身相关。

\n\n

目前唯一可行的解​​决方案是挂钩内核事件,但这绝对不是我喜欢编写的代码:

\n\n
use ApiPlatform\\Core\\EventListener\\EventPriorities;\nuse Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\nuse Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent;\nuse Symfony\\Component\\HttpKernel\\KernelEvents;\nuse Symfony\\Component\\Security\\Core\\Security;\nuse Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface;\n\nfinal class SerializeListener implements EventSubscriberInterface\n{\n    /**\n     * @var Security\n     */\n    private $security;\n\n    /**\n     * @var NormalizerInterface\n     */\n    private $normalizer;\n\n    public function __construct(\n        Security $security,\n        NormalizerInterface $normalizer\n    ) {\n        $this->security = $security;\n        $this->normalizer = $normalizer;\n    }\n\n    public function addCurrentUser(GetResponseForControllerResultEvent $event)\n    {\n        $request = $event->getRequest();\n        if ($request->attributes->has(\'_api_respond\')) {\n            $serialized = $event->getControllerResult();\n            $data = json_decode($serialized, true);\n            $data[\'hydra:user\'] = $this->normalizer->normalize(\n                $this->security->getUser(),\n                $request->attributes->get(\'_format\'),\n                $request->attributes->get(\'_api_normalization_context\')\n            );\n            $event->setControllerResult(json_encode($data));\n …
Run Code Online (Sandbox Code Playgroud)

api-platform.com

0
推荐指数
1
解决办法
1380
查看次数