Working with Services in Symfony 4

In Symfony, Service classes generally are used to hold code that performs repeatable tasks. For example, say you needed to format a phone number. You would make a service class with a method that formats the phone number as opposed to copying and pasting the same bit of code around each time you needed to format a phone number. Services are also a good place to store your business logic code. Code that doesn’t really belong in your controller, entity or repository classes. So far we’ve built out an API which lets a user register, login and see their account

Continue reading

Building a JWT Authenticator in Symfony 4

This tutorial is a continuation of last week’s post on creating a backend API with Symfony. Today we will be implementing authentication with a JWT. JWT stands for JSON Web Token. In practice, a JWT is generally used as a way of storing the user’s session off of the server. That way, your API can stay stateless. If you followed along from the last tutorial, currently after we login, the session is stored on the server. That’s perfectly fine to do, and it’s how a lot of websites store sessions. However, by making your API stateless you remove the extra

Continue reading

Backend API Authentication with Symfony 4

This will be the first of a series of posts where you will learn how to create a full blown web app from scratch with Symfony 4 and VueJS. In today’s post we will go over setting up your environment and creating the registration, login and logout endpoints. Before we begin this tutorial, there are some prerequisites: You should be comfortable with PHP You should have access to a web server that supports PHP 7.2 and MySQL 5.7 You need to have composer installed on your server You will need Postman or some way to make requests to the API

Continue reading