问题标签 [symfony-3.4]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
symfony - Symfony - composer update - Dependency Injection Configuration class not found
Our project is partly made of three bundles, two of them consist of a web backend application and an associated API consumed by our Customer's Frontend Single Page Application, the last one "CoreBundle" is where common resources live.
These bundles all have a DependencyInjection's (DI) bundle sub-directory but do not have Configuration class at all since none of them has any specific configuration. We use the DI component as suggested in the documentation, there is in theory no special case in this project that may influence the configuration loading mechanism.
This has been working well Until now (Symfony 3.3.2).
In an intent of updating symfony/symfony from 3.3.2 to 3.4, composer post-install script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache generates 2 exceptions:
In Consistency.php line 337: Class Bundle\CoreBundle\DependencyInjection\Configuration\Configuration not found
In Consistency.php line 285: Class Bundle\CoreBundle\DependencyInjection\Configuration\Configuration not found
Exception trace:
Adding a Configuration class, with its getConfigTreeBuilder()
method returning a new ("empty") Treebuilder instance, makes the exception point out another bundle. I did so for our three bundles and the exception now points out one of Sensio's own bundles instead.
In Consistency.php line 337: Class Sensio\Bundle\DistributionBundle\DependencyInjection\Configuration\Configuration not found …</p>
Here are a few Composer warnings spawning before the exception gets thrown:
Executing rm -rf var/cache/*
did not help.
Running only bin/console cache:clear
throws this same exception.
Now that our bundles implementation seem to not have anything to do with this issue, I have even less idea of what may be the root of the problem. That said, the line "spl_autoload_call() at n/a:n/a
" looks strange …
May be some Symfony dependencies should be forced to some versions … ? (By the way changelog did not provide helpful hint of a potential cause)
Thank you for your help.
php - 生成捆绑包后找不到模板
好的,这可能是一件非常奇怪的事情。这不是我第一次从事 symfony 项目,但是:
我使用了 symfony generate:bundle 命令,然后我创建了一个包。让我们称之为“犯罪捆绑”。
我看到它在 src/ 里面做了一个文件夹
它还自动生成了一个 DefaultController 和一个 index.html.twig 文件。
现在每当我使用:
它不起作用:我收到错误:
找不到模板“CrimeBundle:Default:index.html.twig”(查看:/Users/admin/sites/solve/app/Resources/views、/Users/admin/sites/solve/vendor/symfony/symfony/src /Symfony/Bridge/Twig/Resources/views/Form)。
但是,只要我使用命名空间的树枝路径,它就可以工作,例如:
我喜欢第一个选项,因为在我的其他项目中我也使用它。它们都不是相同的版本,目前我使用的是: 3.4.1 文件又在那里,因为它适用于命名空间的树枝路径。
我不明白为什么return $this->render('CrimeBundle:Default:index.html.twig');
不能在 symfony 生成此代码时工作。
php - 如何验证使用用户管理器创建的用户的密码?
我想知道如何根据定义的验证规则检查任意密码validation.xml
。我创建了一个管理员页面,管理员用户可以在其中创建其他管理员用户。/register
我想使用匿名用户在页面上注册自己的帐户时使用的相同规则来验证这些用户。据我所知,这些规则是在validation.xml
.
所以基本上我想做这样的事情:
甚至像这样直接在密码上调用函数:
我应该用什么来代替functionThatValidatesUserPassword
这里?
我认为验证器服务可能会起作用,但是当我尝试时
我只是得到一个空的错误列表。我原以为会看到“密码太短”的错误,如果您在/register
页面上注册一个具有相同密码的帐户,就会出现这种情况。
我在 Symfony 3.4 和 FosUserBundle 2.0 上。
在搜索我的问题的答案时,我发现以下两篇文章描述了如何覆盖validation.xml
文件中定义的规则。
我确实计划覆盖验证规则,但现在我只想使用 FosUserBundle 附带的内置规则来验证我的密码。
symfony - symfony 3.4“不推荐刷新已取消身份验证的用户”
在尝试将现有的 symfony 项目从 3.3.10 升级到应该是 LTS 的 3.4.x 时,我设法通过 composer 升级了组件。升级后一切正常,但单元测试显示弃用错误
一些谷歌搜索将我指向可能显示更改的提交 https://github.com/showpad/Symfony-Security/pull/1/commits/3663bbec5fc60565de476fc180f85e1121339072
所以我尝试解决它,在挖掘代码后,我将一个新设置放入 security.xml
这解决了弃用警告,但完全破坏了使用自定义实体的身份验证,用户根本没有经过身份验证,并且日志显示错误:
所以问题是“如何正确解决弃用问题”?
angularjs - Angular ng-click 事件侦听器在 $compile 后与 ng-click 相乘
你好 Stackoverflow 社区!
我正在使用 AngularJS 和 jQuery 开发 Symfony 3 项目。我创建了一个集合指令来与 Symfony 表单构建器交互,以添加和删除集合字段类型的行。该指令有一个独立的范围,它设置了一个名为prototypeControl的2路绑定变量。在 twig 模板站点上,我调用prototype-control="{{ form.vars.id|camel_case }}Prototype"
以获取集合字段的唯一 ID,因此这将与单个表单中的多个集合字段一起使用。奇怪的是,如果我在原型控制属性中将变量名设置为原型控制,一切正常。添加和删除按钮适用于加载时存在的集合行,删除按钮适用于动态添加的行。我需要它来使用自定义变量名称,以便我可以使用页面控制器中的隔离范围函数。
长话短说,当我使用带有表单 ID 的变量使其唯一时,我可以从 javscript 控制台触发这些功能,但是无论动态添加什么字段,删除按钮都没有任何影响。我可以让删除按钮工作的唯一方法是将 $compile 注入指令并编译 directvie 元素。
$compile(element.contents())(scope);
尝试使用和不使用 .contents() 方法。使用这种方法,一切看起来都很好,删除对现有元素和动态添加的元素都有效,添加按钮有效,但无论出于何种原因,添加按钮上的 ng-click 似乎每次都会增加监听器。所以下次我点击按钮时,它会添加两行,然后是四行,依此类推。
我尝试在 DOM 的不同级别上进行编译,但删除按钮永远不起作用。我尝试过的示例元素是删除按钮本身、存储在本地容器变量中的 DOM、原型 HTML 本身以及 .prototype-row。这些似乎都没有受到 $compile 的影响。只有编译元素变量似乎有效。
这是指令:
这是来自服务器端的集合的树枝模板块。
这是我正在测试的特定集合的实际模板。这是使用以下方法data-collection-prototype
动态添加到 DOM 的内容add()
:
我仍然会通过这个来寻找答案。如果我弄清楚了,我会在这里发帖。
希望外面有人遇到这种情况一次或两次。
谢谢!
php - 安装 Sonata ClassificationBundle 自动加载 ClassNotFound
我正在尝试在 symfony 3.4 中的项目上安装 Sonata ClassificationBundle。
但我无法正确安装它,我认为我遗漏了一些东西。
我已通过所有步骤,但我的应用程序显示此消息:
我尝试添加类以自动加载
没有结果同样的错误。
我的课是完美生成的。
我能怎么做 ?
谢谢
symfony - Symfony 3.4 记录器服务
当我调用logger
服务在日志文件中获取此信息消息时,它可以工作,但将此消息写入日志文件:
php.INFO: User Deprecated: "logger" 服务是私有的,从容器中获取它自 Symfony 3.2 以来已被弃用,并且将在 4.0 中失败。您应该将服务公开,或者直接停止使用容器并改用依赖注入。{"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"logger\" service is private, 从容器中获取它自 Symfony 3.2 以来已被弃用,并且将在 4.0 中失败。您应该服务公开,或者直接停止使用容器并使用依赖注入。在 /home/****/###/PROJECT/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:275 )"} []
我的 symfony 版本:3.4.1
php - Symfony Lock 组件没有锁定——如何解决?
我最近升级到 Symfony 3.4.x,由于弃用警告而重构 LockHandler 并陷入奇怪的行为。
重构前的命令代码:
它可以防止同时运行两个命令——第二个只是完成而不做工作。那很好。
但是在建议重构之后,它允许同时运行许多命令。这是失败的。如何防止执行?新代码:
NB #1:我不关心很多服务器,只关心一个应用程序实例。
NB #2:如果进程被杀死,那么新命令必须解锁并运行。
php - 弃用服务的公共使用
在更大的应用程序中,我有许多服务。使用 Symfony 2.x,我们将大部分服务公开并在控制器中使用:
过渡到 Symfony 3.4/4 我想反对公共使用服务。由于许多客户直接使用该服务,因此我必须将其公开。
但我想将服务的公共使用标记为“已弃用”。
我已经知道如何在 Symfony 中弃用服务定义(http://symfony.com/blog/new-in-symfony-2-8-deprecated-service-definitions)。
我只能以某种方式弃用公共使用吗?
php - Symfony 3.4 控制台命令定义无法识别
我正在将现有的 Symfony 3.3 应用程序升级到 Symfony 3.4。
尽管我已经在包的 services.yml 文件中定义了命令,但我收到了控制台命令自动注册警告。警告:
[2017-12-14 12:22:19] php.INFO: User Deprecated: Auto-registration of the command "Dplh\DplhIssuesBundle\Command\IssuesReportCommand" 自 Symfony 3.4 以来已被弃用,并且在 4.0 中不受支持。请改用基于 PSR-4 的服务发现。
Dplh/DplhIssuesBundle/Resources/config/services.yml 中的条目:
我肯定 Symfony 正在处理 services.yml 文件,因为如果我故意在其中创建语法错误,Symfony 会报告该文件包含无效的 YAML。