Skip to content

Commit fadb5de

Browse files
committed
Merge branch '2.3'
2 parents 8a0436f + e06ae48 commit fadb5de

File tree

7 files changed

+132
-8
lines changed

7 files changed

+132
-8
lines changed

core/angularjs-integration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ admin.addEntity(article);
9797
nga.configure(admin);
9898
```
9999

100-
You can look at what we have done as another exemple [api-platform/admin](https://github.com/api-platform/admin).
100+
You can look at what we have done as another example [api-platform/admin](https://github.com/api-platform/admin).

core/filters.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ final class UserFilter extends SQLFilter
896896
public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string
897897
{
898898
if (null === $this->reader) {
899-
return throw new \RuntimeException(sprintf('An annotation reader must be provided. Be sure to call "%s::setAnnotationReader()".', __CLASS__));
899+
throw new \RuntimeException(sprintf('An annotation reader must be provided. Be sure to call "%s::setAnnotationReader()".', __CLASS__));
900900
}
901901
902902
// The Doctrine filter is called for any query on any entity
@@ -965,7 +965,7 @@ namespace App\EventListener;
965965
966966
use Symfony\Component\Security\Core\User\UserInterface;
967967
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
968-
use Doctrine\Common\Persistence\ObjectManager;
968+
use Doctrine\Orm\EntityManagerInterface;
969969
use Doctrine\Common\Annotations\Reader;
970970
971971
final class UserFilterConfigurator
@@ -974,7 +974,7 @@ final class UserFilterConfigurator
974974
private $tokenStorage;
975975
private $reader;
976976
977-
public function __construct(ObjectManager $em, TokenStorageInterface $tokenStorage, Reader $reader)
977+
public function __construct(EntityManagerInterface $em, TokenStorageInterface $tokenStorage, Reader $reader)
978978
{
979979
$this->em = $em;
980980
$this->tokenStorage = $tokenStorage;

core/fosuser-bundle.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
5959
6060
/**
6161
* @ORM\Entity
62+
* @ORM\Table(name="fos_user")
6263
* @ApiResource(
6364
* normalizationContext={"groups"={"user", "user:read"}},
6465
* denormalizationContext={"groups"={"user", "user:write"}}

core/serialization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ In the following JSON document, the relation from a book to an author is represe
210210
```
211211

212212
However, for performance reasons, it is sometimes preferable to avoid forcing the client to issue extra HTTP requests.
213-
It is possible to embed related objects (in their entirity, or only some of their properties) directly in the parent
213+
It is possible to embed related objects (in their entirety, or only some of their properties) directly in the parent
214214
response through the use of serialization groups. By using the following serialization groups annotations (`@Groups`),
215215
a JSON representation of the author is embedded in the book response:
216216

deployment/traefik.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Implement Traefik Into API Platform Dockerized
2+
3+
## Basic Implementation
4+
5+
[Traefik](https://traefik.io) is a reverse proxy / load balancer that's easy, dynamic, automatic, fast, full-featured, open source, production proven, providing metrics, and integrating with every major cluster technology.
6+
7+
This tool will help you to define your own routes for your client, api and more generally for your containers.
8+
9+
Use this custom API Platform `docker-compose.yml` file which implements ready-to-use Traefik container configuration.
10+
Override ports and add labels to tell Traefik to listen the routes mentionned and redirect routes to specified container.
11+
12+
13+
`--api` Tell Traefik to generate a browser view to watch containers and IP/DNS associated easier
14+
`--docker` Tell Traefik to listen docker api
15+
`--docker.domain=localhost` The main DNS will be on localhost
16+
`labels:` Key for Traefik configuration into Docker integration
17+
```yaml
18+
services:
19+
# ...
20+
api:
21+
labels:
22+
- "traefik.frontend.rule=Host:api.localhost"
23+
```
24+
The api DNS will be specified with `traefik.frontend.rule=Host:your.host` (here api.localhost)
25+
26+
`--traefik.port=3000` Port specified to Traefik will be exopsed by container (here React app expose the 3000 port)
27+
28+
29+
```yaml
30+
version: '3.4'
31+
32+
services:
33+
reverse-proxy:
34+
image: traefik
35+
command: --api --docker --docker.domain=localhost
36+
ports:
37+
- "80:80" #All HTTP access will be caught by Traefik
38+
- "8080:8080" #Access Traefik webview
39+
volumes:
40+
- /var/run/docker.sock:/var/run/docker.sock
41+
42+
php:
43+
image: ${CONTAINER_REGISTRY_BASE}/php
44+
build:
45+
context: ./api
46+
depends_on:
47+
- db
48+
env_file:
49+
- ./api/.env
50+
# Comment out these volumes in production
51+
volumes:
52+
- ./api:/srv/api:rw,cached
53+
# If you develop on Linux, uncomment the following line to use a bind-mounted host directory instead
54+
# - ./api/var:/srv/api/var:rw
55+
56+
api:
57+
image: ${CONTAINER_REGISTRY_BASE}/nginx
58+
labels:
59+
- "traefik.frontend.rule=Host:api.localhost"
60+
build:
61+
context: ./api
62+
depends_on:
63+
- php
64+
# Comment out this volume in production
65+
volumes:
66+
- ./api/public:/srv/api/public:ro
67+
68+
db:
69+
# In production, you may want to use a managed database service
70+
image: postgres:9.6-alpine
71+
labels:
72+
- "traefik.frontend.rule=Host:db.localhost"
73+
environment:
74+
- POSTGRES_DB=api
75+
- POSTGRES_USER=api-platform
76+
# You should definitely change the password in production
77+
- POSTGRES_PASSWORD=!ChangeMe!
78+
volumes:
79+
- db-data:/var/lib/postgresql/data:rw
80+
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
81+
# - ./docker/db/data:/var/lib/postgresql/data:rw
82+
ports:
83+
- "5432:5432"
84+
85+
client:
86+
# Use a static website hosting service in production
87+
# See https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.mddeployment
88+
image: ${CONTAINER_REGISTRY_BASE}/client
89+
build:
90+
context: ./client
91+
env_file:
92+
- ./client/.env
93+
volumes:
94+
- ./client:/usr/src/client:rw,cached
95+
- /usr/src/client/node_modules
96+
expose:
97+
- 3000
98+
labels:
99+
- "traefik.port=3000"
100+
- "traefik.frontend.rule=Host:localhost"
101+
102+
volumes:
103+
db-data: {}
104+
```
105+
106+
Don't forget the db-data, then database won't work in this dockerized solution.
107+
108+
`localhost` is a reserved domain referred in your `/etc/hosts`.
109+
If you want to implement custom DNS such as production DNS in local, just put them at the end of your `/etc/host` file like that:
110+
111+
```
112+
# /etc/hosts
113+
# ...
114+
115+
127.0.0.1 your.domain.com
116+
```
117+
118+
If you do that, you'll have to update the `CORS_ALLOW_ORIGIN` environment variable `api/.env` to accept the specified URL.
119+
120+
## Known Issues
121+
122+
If your network is of type B, it may conflict with the traefik sub-network.

distribution/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ class Book
271271
*/
272272
public $reviews;
273273

274-
public function __construct() {
274+
public function __construct()
275+
{
275276
$this->reviews = new ArrayCollection();
276277
}
277278

schema-generator/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Example:
4141
types:
4242
Brand:
4343
properties:
44-
logo: { range: "ImageObject" } # Force the range of the logo propery to ImageObject (can also be URL according to Schema.org)
44+
logo: { range: "ImageObject" } # Force the range of the logo property to ImageObject (can also be URL according to Schema.org)
4545
4646
PostalAddress:
4747
properties:
@@ -375,7 +375,7 @@ doctrine:
375375
## Changing the Field Visibility
376376

377377
Generated fields have a `private` visibility and are exposed through getters and setters.
378-
The default visibility can be changed with the `fieldVisibility` otion.
378+
The default visibility can be changed with the `fieldVisibility` option.
379379

380380
Example:
381381

0 commit comments

Comments
 (0)