我遵循带注释的过滤器的实现,只加载一个用户关注的源。非常有用,正常工作。
https://api-platform.com/docs/core/filters/#using-doctrine-filters
但是:我想在我的实体中用多对多关系做同样的事情,而不是像这样的多对一:
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
use App\Annotation\UserAware;
/**
*
* @ApiResource(routePrefix="/api")
* @ORM\Entity
* @ORM\Table(name="albums")
* @UserAware(userFieldName="user_owner")
* @UserAware(userFieldName="album_access_user")
*/
class Album
{
//...
/**
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(nullable=false, name="user_owner", referencedColumnName="id")
*/
public $userOwner;
/**
* @ORM\ManyToMany(targetEntity="User", inversedBy="albums")
* @ORM\JoinTable(name="album_access")
* @ORM\JoinTable(
* name="album_access",
* joinColumns={
* @ORM\JoinColumn(name="album_access_album", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="album_access_user", referencedColumnName="id")
* }
* )
*/
private $accesses; …Run Code Online (Sandbox Code Playgroud) 我正在windows 10 + wamp + php 7 + Symfony 3.3下开发应用程序
我正在尝试使用内置服务器:
php bin/console server:run
[OK] Server listening on http://127.0.0.1:8000
// Quit the server with CONTROL-C.
Run Code Online (Sandbox Code Playgroud)
当我转到http:// localhost:8000/app_dev.php /或http://127.0.0.1:8000/app_dev.php
我收到此错误:
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'C:\wamp\www\myproject\vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle/Resources/router.php' (include_path='.;C:\php\pear') in Unknown on line 0
Run Code Online (Sandbox Code Playgroud)
每条路线下的错误相同.我的路线是正确的,在内置服务器之外工作正常......
你能帮我解决这个问题吗?