Login Success & the Session
…may make it less secure. As a general
rule, while you can use API tokens in your JavaScript, you should never store
them anywhere - like local storage of cookies due to security. That makes using
API tokens in JavaScript... tricky.
So... if we're not…
Context Builder & Service Decoration
…it talks about changing the serialization context dynamically
and gives an example. Steal this BookContextBuilder code. This class
can live anywhere in src/, but to follow the docs, let's create a Serializer/
directory and a new PHP class inside of that called AdminGroupsContextBuilder...
because…
Assets: CSS & JavaScript
…inside the stylesheets block?
Is that important? Well, technically... it doesn't matter: a link tag can live
anywhere in head. But later, we might want to add additional CSS files on specific
pages. By putting the link tags inside this block, we'll have…
JavaScript & Page-Specific Assets
…page,
it will appear too early - before even jQuery is included!
To add our new file at the bottom, we can override the javascripts block.
Anywhere in show.html.twig, add {% block javascripts %} and {% endblock %}:
Add the script tag with src="", start typing article_show…
Asset Versioning & Cache Busting
… Open config/packages/framework.yaml. Anywhere,
but I'll do it at the bottom, add assets: then json_manifest_path set to
%kernel.project_dir%/public/build/manifest.json:
This is a built-in feature that tells Symfony to look for a JSON file at…
PHPUnit: Secure the Park
…failed asserting that false is true on
DinosaurTest line 11.
Ok, let's talk about the basic rules of writing a PHPUnit test. First, you can
technically put your test classes anywhere... but.. you've gotta admit that
tests/ is a pretty good place. Actually…
Installation and First Admin
…which we need
to import. Copy the routing import lines, find our app/config/routing.yml and
paste anywhere:
Since we already have some pages that live under /admin, let's change the prefix
to /easyadmin:
Finally, one last step: run the assets:install command…
Child Component
…answer that, there is technically another option: we could just
move the highlightedRowId state into the RepLogList component. And, technically,
this would work! Look closely: RepLogApp isn't using that data anywhere else! So
if we moved the state, everything would work!
But... for a…
AppBundle, Routing and Annotations
…some comments to make things really small. This includes the normal
autoloader, then adds an extra thing for annotations. Now, in index.php - or anywhere
else you need to autoload - require this file instead:
Refresh! Very nice! Let's count the files: 1, 2, 3…
dotenv: Environmental Variables
…Because of config.yml,
this should turn the toolbar off. Change the environment to prod too - that's not
being used anywhere yet, but it may avoid a temporary cache error:
Try it out: no web debug toolbar.
Add .env to the .gitignore file - this…
ApiProblemException and Exception Handling
…notice that the status code
is still 400. Our new exception class extends HttpException, so we
really have the same behavior as before.
When an exception is thrown anywhere in our app, Silex catches it and gives
us an opportunity to process it. In fact…
Handling 404 Errors
…JsonResponse and set the application/problem+json Content-Type
header on it. Now, if an exception is thrown from anywhere in the system
for a URL beginning with /api, the client will get back an API problem
response. It took a little bit of work…
Exposing more Error Details
…Look back at our exception-handling
function. The NotFoundHttpException is not an instance of ApiProblemException,
so we fall into the situation where we create the ApiProblem by hand.
We’re not using the exception’s message anywhere, so it makes sense we don’t
see…
Deployment
…under a branch called episode4-finish.
Let’s clone this repository:
git clone
Move into the directory. If your code lives anywhere other than the master
branch, you’ll need to switch to that branch:
git checkout -b episode4-finish origin/episode4-finish
GitHub might…
Remember Me Functionality
…our session cookie to make sure it’s working. When I refresh,
my session is gone but I’m still logged in. Nice! Click anywhere on the web
debug toolbar to get into the profiler. Next, click on the “Logs” tab. If
you look closely…
Downloading & Configuration
…that didn't work. So let's try pasting the command instead. If you
have PHP 5.4 installed, run this anywhere: we'll use PHP's built-in web server.
If you don't, get with it! PHP 5.3 is ancient. But anyways…
Routing: The URLs of the World
…pull it in. So, even though Symfony only reads this one
routing file, we can pull in routes from anywhere.
So what's up with the @EventBundle magic? The resource should just
point to the path of another file, relative to this one. But if…
Gherkin
…while vacationing thousands of miles away.
Feature: Remote fence control API
In order to control fence security from anywhere
As an API user
I need to be able to POST JSON instructions that turn fences on/off
The person benefiting in this case is our…
The Query Builder
…accidentally remove something
you added earlier. So, always use andWhere(). Doctrine is smart enough to figure
out that, because this is the first WHERE, it doesn't actually need to add the
AND.
Inside of andWhere(), pass mix.genre =... but don't put the…
Search, the Request Object & OR Query Logic
…I'll show you what
I mean when we see the final query. The point is that if you need an OR in a
WHERE statement, you should still use andWhere(). Yup, we can say:
answer.content LIKE :searchTerm OR and then pass another expression…
x
511