01.
Start Securing the App!
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.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
8 Comments
Hey! Is the lexik jwt implementation done in a different way between Symfony 3 and 4? I'm building my api with Symfony 4 and i'm not sure if some things should be done differently.
Hey @alex
Mainly everything will be the same, but of course there are some changes in configuration, class and variable names Lixik JWT has good UPGRADE documents which show differences between versions, And you can follow them to build everything in right way!
Cheers!
I have downloaded the course code and done the setup on PHP 7.1 (It doesn't work on 7.2) . I'm running into a weird issue. When I try to run the tests with the filter, it says so tests executed. If I run tests without the filter, it says everything passed, but I'm not confident that it's actually running the tests in ProgrammerTestController because I've put in die statements or actual parsing errors, and the tests pass without a filter. I've made no modifications to the code other than to put in the very first test, which should fail.
I'm stumped on this one. Any thoughts?
Yay! I figured it out. The tests moved since the last tutorial. The are in /tests now, not the ones in /src/AppBundle/Tests . I strongly suspect the people below had the same issue. Maybe you all should remove the copy from the old location?
Hey Amy anuszewski
Sorry for the confusion and thanks for sharing your findings :)
We will discuss about your suggestion because we really want to avoid this kind of problems to others
Cheers!
Architecture question!
In a traditional Symfony web app a user would click on a link, a request is sent to the server, and then the server sends back the html for the browser to display.
With a REST application it seems there needs to be (at least) 2 end points for any page that has data from a database. Here is my flow.
1. User sends request i.e. /app
2. Server sends back HTLML for page
3. Data is required so a javascript file calls an end point to retrieve this i.e. /app/api/posts
4. Javasctipt receives JSON and adds the data to the page.
Have i got this right or am i missing something?
Loving this course BTW!
Hey Shaun T.!
Architecture! Woo! :)
The answer to your question is.... sort of? But kinda no.... ;). Let me explain. There are 3 types of applications:
1) 100% traditional HTML web apps: the user's browser sends a request to /app & gets back HTML. There is NO AJAX, every page is a full refresh This is 0% API
2) 100% single-page application. In this model, there is literally 1 HTML file that the user gets when they access "/", and this is probably mostly an empty page with a div on it and some JavaScript. Then, 100% of all other requests are AJAX/API requests, which are used to build everything for your application.
3) A mixture :). And this is still the most common (though single-page apps, SPAs, are becoming more and more common). This site is a good example of a "mixed" app. When your browser makes a request to "/", you get a traditional HTML page, and there is no AJAX. But, if you go to, for example, a challenge page (https://knpuniversity.com/screencast/php-namespaces-in-120-seconds/namespaces/activity/307), this returns HTML... but the original HTML is actually mostly empty. We then make several AJAX requests in order to build the page. Whenever you change a file in the editor, more AJAX/API requests are made.
So yes, there is ALWAYS at least one HTML response. But, once that HTML responses is received, you could build a JavaScript app that makes many API requests. Or, (and I think this really gets to your question) if you really only need to print some data on your page, you can just use the data to print all of the HMTL you need and return it. In that case, there is no need to make any API request: your page is fully loaded and ready to go. Heck, even if you DO want to get some JSON data in order to use with JavaScript, you can (if you want) avoid an AJAX request by making that data available inside your HTML - e.g. https://knpuniversity.com/screencast/javascript/data-attribute, or simply by setting your data to a global variable, like:
I hope that helps!
Thanks for such a detailed explanation weaverryan , this has made the subject loads clearer for me, I really appreciate it!
"Houston: no signs of life"
Start the conversation!