513 search results

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…

5:56
Users Need Passwords (plainPassword)

…little evil. Finally, in eraseCredentials(), add $this->plainPassword = null: Symfony calls this after logging in, and it's just a minor security measure to prevent the plain-text password from being accidentally saved anywhere. The User object is perfect. Let's add the listener.

3:32
The Form Type Class

…in the new GenusAdminController. To create a form, you'll add a class where you'll describe what the form looks like. In PhpStorm, select anywhere in your bundle and press command+N, or right click and select "New". Find "Form" and call it GenusFormType…

3:14
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…

3:24
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…

4:53
The All-Important HttpExceptionInterface

…error, unless that exception implements the HttpExceptionInterface: It has two functions: getStatusCode() and getHeaders(). The HttpException class we're throwing implements this. That means we can throw this from anywhere in our code, stop the flow, but control the status code of the response. Symfony…

4:44
Mad Test Debugging

…is really easy. The class that handles the styling is called ConsoleOutput, and you can use it directly from anywhere. Start by adding a private $output property that we'll use to avoid creating a bunch of these objects. Then down in printDebug(), say if…

3:03
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…

6:51
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…

1:44
Block Views & Block Definitions

…the newest first and limit to 3. Ok, if we "Publish and continue editing"... then refresh... whoa! It's cool that we can just put those anywhere now. Though, let's wrap that in a container. And... much better. So far, this is all easy…

4:48
Shared Layouts

…new layout, I'll choose my favorite layout 2 and call it "Recipes List Layout". To start, add a new block called "Full View"... and drag it anywhere onto the page, whoops! There we go. What is this "Full View". It's nothing special, in…

7:25
Item View Template

…our recipe item: Next, add recipes_app... with a little note to say that this key is not important: Unlike other things, such as latest_recipes, this internal key won't be used anywhere. Below, we need two important things. First, template - don't include…

6:27
Toast Notifications

…and add another review. This time... that's super cool! And it means that we can, from anywhere, render the _toast.html.twig template and it will activate this behavior. Though... the positioning isn't what I was imagining. Before it disappeared, it was open…

10:14
Ajax Element Reloading Controller

…an Ajax call to reload the product list area after a new product is successfully added. To be extra cool - cause we are extra cool - we're going to make this new controller generic so we can reuse it anywhere... like on the cart page…

6:23
Symfony UX & Chart.js

…I've already created that page at "/admin"... but it's not very interesting yet... and none of these links go anywhere. Ok: let's check out the docs for Symfony UX chartjs. Scroll down... Whoa. Stimulus and Chart.js are both pure JavaScript libraries…

7:48
Parameters

…the container. Invent a new one called, how about, cache_adapter set to cache.adapter.apcu: There should now be a new parameter in the container called cache_adapter. We're not using it anywhere... but it should exist. How do we use it? There…

7:59
Creating a Service

…which we will later. So how do we create our very own service? Start by creating a class anywhere in src/. It doesn't matter where but I'll create a new sub-directory called Service/, which I often use when I can't think…

5:03
FlattenException & Error Status Codes

…which will be a 412 and many more. Hmm, where's the IAmATeaPotHttpException? If you throw any of these exceptions from anywhere in your app, they will trigger an error page with the correct status code. This is a powerful thing to understand. Back in…

6:10
Sub Request Attributes

…argument. If we try, I want an exception to be thrown. By the way, it is actually possible to use the RequestStack from anywhere to get the "master" request: it has a getMasterRequest() method. But! If you're using HTTP caching with edge side includes…

9:05
Calling the Controller & View Event

…entity! You would return a "model". Then, you could write a listener to this event that transforms that Article entity into HTML by rendering the template. This event isn't used anywhere in Symfony's core, but it is used extensively inside API Platform. Internally…

5:20