Chapters
26 Chapters
|
2:18:26
|
This course is archived!
This tutorial uses a deprecated micro-framework called Silex. The fundamentals of REST are still ?valid, but the code we use can't be used in a real application.
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
22.
Collections: The HAL Way
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial uses a deprecated micro-framework called Silex. The fundamentals of REST are still ?valid, but the code we use can't be used in a real application.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"silex/silex": "~1.0", // v1.3.2
"symfony/twig-bridge": "~2.1", // v2.7.3
"symfony/security": "~2.4", // v2.7.3
"doctrine/dbal": "^2.5.4", // v2.5.4
"monolog/monolog": "~1.7.0", // 1.7.0
"symfony/validator": "~2.4", // v2.7.3
"symfony/expression-language": "~2.4", // v2.7.3
"jms/serializer": "~0.16", // 0.16.0
"willdurand/hateoas": "~2.3" // v2.3.0
},
"require-dev": {
"behat/mink": "~1.5", // v1.5.0
"behat/mink-goutte-driver": "~1.0.9", // v1.0.9
"behat/mink-selenium2-driver": "~1.1.1", // v1.1.1
"behat/behat": "~2.5", // v2.5.5
"behat/mink-extension": "~1.2.0", // v1.2.0
"phpunit/phpunit": "~5.7.0", // 5.7.27
"guzzle/guzzle": "~3.7" // v3.9.3
}
}
11 Comments
My hal.js file was blowing up. I had to change line 16 to, because it was expecting _links on the top level and we weren't providing any.
if ( HAL.currentDocument._links ) var curies = HAL.currentDocument._links.curies;
Hey GDIBass!
Hmm, thanks for sharing! I'm not sure why you needed this and we didn't - that code isn't new in hal.js (I just checked). But, no worries :). We may have fixed this later in chapter 24 when we added the Api homepage. But either way, I'm glad you figured it out. And yea, we should have _links on each resource.
Cheers!
Collections have been updated in Hateoas 3 and the current method of declaring the _embedded names does not work. Any solutions to this?
Hey @Sym!
Sorry for the slow reply :). I believe the idea in Hateoas 3 is this: instead of using the built-in CollectionRepresentation from the library, you're supposed to create your *own* class. Basically, you're supposed to copy CollectionRepresentation (https://github.com/willdura..., put it into your code, and customize it. For example, you might have a ProgrammerCollectionRepresentation where you customize the annotation on top, if you want to take control of the _embedded names.
I hope this helps!
Cheers!
Hi there! I had problem when i tried viewing with HALbrowser - /api/progrmmers or any route that didn't have _links outside _embedded items. its caused by hal.js line 16. "HAL.._links..undefined" look at your inspector console. I just commented that line(probably i should do something more sophisticated) and everything seems to work fine, even when the are _links. I hope this helps someone.
Hey emm!
Thanks for sharing - in case it helps anyone else :). I personally couldn't repeat the error - I updated to the latest Hal Browser (and used the version in the screencast) - but when I go to /api/programmers (where I have no _links)... it works ok! I'm not sure why - but not big deal either way :).
Cheers!
I agree with you its not a big deal because behat tests are passing.
So your answer may help someone else by saying its not a big deal :).
cheers to y'all!
I had the same problem but it works with the epic-rewrite branch from 2013.
Thanks looking into that A Maria.
Whats with the flashing screen in this tutorial...
Hey Thao L.,
Could you please point me in which second is that flash ?
I couldn't find it :)
Have a nice day!
"Houston: no signs of life"
Start the conversation!