我尝试从集合中删除实体,但它不起作用.
我想我某处有错,但我不知道在哪里.
这里是我的代码updateAction:
$em = $this->getDoctrine()->getEntityManager();
$entity = new Person();
if (!$entity) {
throw $this->createNotFoundException('Unable to find Person entity.');
}
$editForm = $this->createForm(new PersonType(), $entity);
$deleteForm = $this->createDeleteForm($id);
$request = $this->getRequest();
$editForm->bindRequest($request);
if ($editForm->isValid()) {
$entity = $editForm->getData();
$em->persist($entity);
foreach($entity->getAddresses() as $address)
{
$em->persist($address);
}
$em->flush();
return $this->redirect($this->generateUrl('person_show', array('id' => $id)));
}
return $this->render('AppPersonBundle:Person:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
Run Code Online (Sandbox Code Playgroud)
请注意,要删除我的实体,我从html中删除div.
我的意思是我删除<div id="myapp_personbundle_persontype_address_4">了例如.
这是正确的方法吗?
我在Cucumber中运行功能时遇到问题,这个功能非常基础,因为它来自教程.
它没有定义,如下:
Feature: Proof that my concept works
Scenario: My first test
Given this is my first step
When this is my second step
Then this is my final step
Run Code Online (Sandbox Code Playgroud)
我的Cucumber跑步者课程如下:
package cucumber;
import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@Cucumber.Options(
format = {"pretty", "json:target/"},
features = {"src/cucumber/"}
)
public class CucumberRunner {
}
Run Code Online (Sandbox Code Playgroud)
.jar我在项目中的外部文件如下:

我得到的例外是:
线程"main"中的异常cucumber.runtime.CucumberException:无法使用[cucumber.runtime.io.MultiLoader@75d837b6]实例化公共cucumber.runtime.java.JavaBackend(cucumber.runtime.io.ResourceLoader)
我试图在网上寻找解决这个问题的方法,但没有运气.
我也讨论了教程的OP,我还在等待反馈,但已经有一段时间了.
这是我的 PhpUnit 测试类:
<?php
namespace tests\AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class SendEmailControllerTest extends WebTestCase
{
public function testMailIsSentAndContentIsCorrect()
{
$client = static:: createClient();
...
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试运行它时,我得到了一个错误,其跟踪是:
Unable to guess the Kernel directory.
C:\myProject\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\KernelTestCase.php:62
C:\myProject\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\KernelTestCase.php:138
C:\myProject\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\KernelTestCase.php:184
C:\myProject\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\KernelTestCase.php:165
C:\myProject\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\WebTestCase.php:33
C:\myProject\tests\AppBundle\Controller\SendEmailControllerTest.php:12
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Remaining deprecation notices (3)
1x: Using the KERNEL_DIR environment variable or the automatic guessing based on the phpunit.xml / phpunit.xml.dist file location is deprecated since Symfony 3.4. Set the KERNEL_CLASS environment variable to the fully-qualified class …Run Code Online (Sandbox Code Playgroud) 
在上面的图像中,B类继承了A类.如果B继承了所有A的方法,箭头不应该从A到B吗?在我看来,如果箭头是从A到B,那将更有意义.
有没有理由说箭头的方向是这样而不是相反?我很乐意听到这个解释.谢谢.
编辑:我知道这是UML的设计方式,根据UML的规则,上图是真的,但我的问题是为什么 UML使箭头走这条路.
我刚刚听说过这个umbraco,并在官方网站上观看了这个演示.那么可以用它来维护我的wordpress博客吗?我目前正在使用windows live writer,我可以下载帖子,编辑它们,然后上传回来.是否可以这样做?
谢谢
我想拒绝目录中的所有文件,但是index.php(作为默认页面).
该解决方案几乎可以工
Deny from all
<Files index.php>
Order Allow,Deny
Allow from all
</Files>
Run Code Online (Sandbox Code Playgroud)
唯一的问题是:'upload/index.php'现在可以访问,但'/ upload /'不是.如何使用htaccess允许默认页面?
我正在使用OptionsResolver组件在类中设置我的默认设置.由于我有大量的参数,我创建了一个多维数组:
<?php
$resolver = new OptionsResolver();
$resolver->setDefaults([
'db' => [
'hostname' => 'localhost',
'username' => 'root'
]
]);
?>
Run Code Online (Sandbox Code Playgroud)
现在我想要否决用户名,而不是主机名.如果我做
$resolver->resolve(['db' => ['username' => 'test']);
Run Code Online (Sandbox Code Playgroud)
该hostname参数是消失了.
我可以使用OptionsResolver组件的多维数组吗?
我在使用 Mercure 的 Apache 服务器上有一个 Symfony 项目,并且我尝试在生产中设置 Mercure hub。
为了在生产中运行 Mercure hub,我将存档 Mercure_0.6.2_Linux_x86_64.tar.gz ( https://github.com/dunglas/mercure/releases ) 提取到项目根目录下的子文件夹 Mercure 中。
然后我运行命令:
JWT_KEY='myJWTKey' ACME_HOSTS='example.com' ./mercure
Run Code Online (Sandbox Code Playgroud)
与我的信息
但集线器无法运行并出现以下错误:
FATA[0000] 监听 tcp:443:绑定:权限被拒绝
我看到了类似的问题(How to run Mercure in production),但建议的答案使用 ADDR 来更改端口,并且根据文档,“Let's Encrypt 仅支持默认端口:要使用 Let's Encrypt,请勿设置此变量。” 。
如何在生产环境中运行 Mercure?
我正在使用 来Symfony Finder获取具有特定扩展名的所有文件以及特定目录中的所有目录。
\n protected function getDirectoryContent(string $directory): array\n {\n $finder = Finder::create()\n ->in($directory)\n ->depth(0)\n ->name(['*.json', '*.php'])\n ->sortByName();\n\n return iterator_to_array($finder, true);\n }\n\nRun Code Online (Sandbox Code Playgroud)\n这样,该方法只返回所有具有扩展名.php或.json在某个目录内的文件。例如,我正在查看的目录结构如下:
/my/directory/\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 A\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 A.JSON\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 anotherfile.kas\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file0.ds\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file1.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file2.php\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file3.php\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 B\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 C\nRun Code Online (Sandbox Code Playgroud)\nA、B和C是目录。
当我将上面的内容directory path作为$directory参数传递到上面所示的方法中时,我得到一个包含以下元素的数组:
file1.json\nfile2.php\nfile3.php\nRun Code Online (Sandbox Code Playgroud)\n太棒了!但我的问题是,我怎样才能将所有这些添加directories到结果数组中?我的期望是得到一个如下所示的数组:
A\nB\nC\nfile1.json\nfile2.php\nfile3.php\nRun Code Online (Sandbox Code Playgroud)\n 我将 Webpack Encore 与Dotenv-webpack一起使用,但收到此错误:
编译失败。
定义插件
“process.env”的值存在冲突
我的 webpack.config.js:
const Dotenv = require('dotenv-webpack')
const Encore = require('@symfony/webpack-encore')
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev')
}
Encore
// ...
.addPlugin(new Dotenv({
path: './.env.local'
}))
module.exports = Encore.getWebpackConfig();
Run Code Online (Sandbox Code Playgroud)
使用的版本:
"devDependencies": {
"@symfony/webpack-encore": "^1.2.0",
"dotenv-webpack": "^7.0.2",
}
Run Code Online (Sandbox Code Playgroud)
我发现了类似的问题,但我并不真正理解解决方案,因此无法将此解决方案与 Symfony Encore 一起使用。
造成此问题的原因是什么以及如何解决此问题?