Get support for dunglas/demo-vulcain-api-platform
If you're new to LTH, please see our FAQ for more information on what it is we do.
Support Options
Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:
View Open IssuesTake a look to see if anyone else has experienced the same issue as you and if they managed to solve it.
Open an IssueMake sure to read any relevant guidelines for opening issues on this repo before posting a new issue.
Sponsor directlyCheck out the page and see if there are any options to sponsor this project or it's developers directly.
dunglas/demo-vulcain-api-platform
API Platform X Vulcain
This is a demo project using API Platform, Vulcain and Varnish all together! It adds Vulcain support to the API that I created during SymfonyCon 2018.
To start the API, Varnish and Vulcain, download this project and run:
$ docker-compose -f docker-compose.prod.yml up
The API is now available on https://localhost:8443
.
To execute the JavaScript benchmarks, go to:
* https://localhost:8443/test-min-waterfall.html (maximum waterfall effect)
* https://localhost:8443/test-max-waterfall.html (as fast as possible)
Results will appear in the console! These files are stored in the api/public/
directory.
A benchmark using Symfony HTTP Client is also available, but you need to edit a line in the vendor
directory (to fix a bug)
to make it working, see the comment at the top of test-http-client.php
!
$ php test-http-client.php
To reproduce this project in a raw API Platform project, follow this guide!
Install API Platform + Vulcain
$ curl -L https://github.com/api-platform/api-platform/archive/master.tar.gz -o api-platform-master.tar.gz
$ tar xzvf api-platform-master.tar.gz
$ cd api-platform-master
# Master version has optimizations for Vulcain
$ docker-compose exec php composer req api-platform/core:dev-master
Configure the API to be Fully Normalized
# api/config/packages/api_platform.yaml
api_platform:
defaults:
normalization_context:
iri_only: true
# ...
Generate the Entities
Conference
-
name
(string
, not nullable)docker-compose exec php bin/console make:entity --api-resource Conference
New property name (press to stop adding fields):
name
[select the default answer for all other questions]
Session
-
conference
(to-one relation withConference
, not nullable) -
author
(text
, not nullable) -
title
(string
, not nullable) -
summary
(text
)docker-compose exec php bin/console make:entity Session --api-resource
New property name (press to stop adding fields):
title
Add another property? Enter the property name (or press to stop adding fields):
summary
Field type (enter ? to see all types) [string]:
text
Can this field be null in the database (nullable) (yes/no) [no]:
yes
Add another property? Enter the property name (or press to stop adding fields):
author
Add another property? Enter the property name (or press to stop adding fields):
conference
Field type (enter ? to see all types) [string]:
ManyToOne
What class should this entity be related to?:
Conference
Is the Session.conference property allowed to be null (nullable)? (yes/no) [yes]:
no
A new property will also be added to the Conference class so that you can access the related Session objects from it.
New field name inside Conference [sessions]:
sessions
Feedback
-
session
(to-one relation withSession
, not nullable) -
comment
(text
, not nullable) -
rating
(smallint
, not nullable)docker-compose exec php bin/console make:entity Feedback --api-resource
New property name (press to stop adding fields):
comment
Field type (enter ? to see all types) [string]:
text
Add another property? Enter the property name (or press to stop adding fields):
rating
Field type (enter ? to see all types) [string]:
smallint
Add another property? Enter the property name (or press to stop adding fields):
session
Field type (enter ? to see all types) [string]:
ManyToOne
What class should this entity be related to?:
Session
Is the Feedback.session property allowed to be null (nullable)? (yes/no) [yes]:
no
Update the DB
docker-compose exec php bin/console doctrine:schema:update --force
Add Fixtures
docker-compose exec php composer req --dev alice
# api/fixtures/data.yaml
App\Entity\Conference:
conference_{1..10}:
name: '<catchPhrase()>'
App\Entity\Session:
session_{1..100}:
conference: '@conference_*'
title: '<catchPhrase()>'
summary: '<sentences(3, true)>'
author: '<name()>'
App\Entity\Feedback:
feedback_{1..100}:
session: '@session_*'
comment: '<sentences(3, true)>'
rating: '<numberBetween(0, 5)>'
docker-compose exec php bin/console hautelook:fixtures:load
The JS!
See api/public/test-max-waterfall.html
and api/public/test-min-waterfall.html
.
Setting Up the Prod Mode
See docker-compose.prod.yml
.
Credits
Created by Kévin Dunglas.
Our Mission
We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.
From the Blog
Interesting Articles
-
Generating income from open source
Jun 23 • 8 min read
-
2023 State of OSS
Apr 23 • 45 min read ★
-
A funding experiment...
Aug 19 • 10 min read
-
But You Said I could
Aug 19 • 2 min read
Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated
p-e622a1a2