Setting up CORS

Depending on your server, there’s different stuff you need to do to setup CORS. I’ll show you how to set it up on nginx and Apache in this tutorial since those are the most common. Why do you need CORS set up? Before going into how to set it up, let’s discuss a little why you’d need CORS. The main reason why you need to set up CORS is because generally when building a web app with a separate backend and frontend, your backend will be on one url (ex. api.yoursite.com) and your frontend will be on another url (yoursite.com).

Continue reading

Creating a Web App with Symfony 4: Setting up Routes

This is a continuation from the previous post on Entity Services. If you haven’t read it yet, click here! We’re in the final stretch of our backend API! We have our entities and services created, now let’s work on creating the controllers for our app. Step 1: Creating an Address Endpoint As we did with the BaseEntityService, we can make a base controller that can work with most of our entities. We’ll create a base controller that has methods to do the basic CRUD (create, read, update, delete) operations. Then extend that base controller for each entity controller. Before we

Continue reading

Creating a Web App with Symfony 4: Entity Services

This is a continuation from the previous post. If you haven’t read it yet, click here! Now that we have our entities, we need to make some services that can handle managing them, similar to the UserService we have already. Since these entity services are going to mostly be doing the same thing (creating, validating and saving), we’re going to make a base class that handles that functionality. Then we’ll extend the base class for the individual entity services so there isn’t a ton of code duplication. So let’s get started! In the src/Service/Entity folder, create a new file called

Continue reading

Creating a Web App with Symfony 4: Doctrine Entities

In this tutorial we’re going to start building a resume builder web app. We’ll be building off of the code that we wrote in the previous tutorials. If you haven’t been following along and want to get a head start, you can download the starting code here. Though it’s recommended to start from the beginning if your completely new to Symfony. We’ll be using everything we learned in the previous tutorials to make this web app happen. First we will update our User entity to include some extra details that normally appear on a resume, like address, phone and name,

Continue reading

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

Making Ajax Calls in React – Part 2

If you haven’t already, take a look at Part 1 of this tutorial. It goes through the basics of setting up a React app and making GET requests to the dog.ceo API to pull pictures of random doggos! In this part of the tutorial we’ll make POST requests to save which pictures are our favorites! The Dog API doesn’t actually have this ability so I’ve built out a small API that you can use to practice on. Step 1. Updating our initial state Since our app now saves favorites, we need to update our state object to include this. So

Continue reading

How to come up with project ideas

Are you tired of building the same todo app every time you go to learn a new language or build on the skills you already have? If you are, hopefully these tips will help you in figuring out how to come up with project ideas. Tip #1 Don’t think so hard about it. You do not need to build something huge, and in fact it doesn’t even need to be a complete project. Your project can be as simple as a login form. The biggest thing is that you learn from it. Tip #2 Do you suck at design? Me

Continue reading

How to make Ajax calls in a React App

Want to start working with API’s and making ajax calls in your react apps? This tutorial will help get you started with using the Fetch API to do just that. It’s expected that you’ve done a few React tutorials before going through this one, but if you haven’t thats okay! I will explain everything as I go. But you should at least have create-react-app installed before starting. What will we be making? We will be using the Dog API from dog.ceo to pull random dog images to display on a web page. Simple, but hopefully it will get you comfortable

Continue reading