Posts

Showing posts from January, 2021

1. Introduction: Creating a Blog Application with Laravel

Image
This project will involve the development of a blog application, built with the PHP framework Laravel. The purpose of this project is to demonstrate an understanding of PHP, Laravel, authentication, authorisation and CRUD functionality by developing a blog application that fulfils these requirements. The blog will facilitate guest users, registered users and admin users - each with varying levels of authorisation which will permit certain actions to be carried out, such as the creation of a new blog, deleting another user's blog post, etc. I'll begin this blog with a natural starting point - where I create a new Laravel project named 'SooperBlog'. This blog will have CRUD (create, read, update and delete) functionality including file uploads, as well as both authentication and authorisation. To create a new Laravel project, the following command was run: laravel new sooperblog I chose to run this command in the home directory of my AWS EC2 Ubuntu Server 20 instance, mea...

2. Backing-Up the Project: FTP and GitHub

Image
As an AWS Educate account is being used, there are limited free options available to back-up the instance or project code. Also, there is likely to be less support when it comes to troubleshooting issues with instances. I'm going to use two different methods to keep my project backed-up: Storing a copy of the project files on my own PC via FTP (FileZilla) Pushing my code to a GitHub repository FileZilla To make a copy of the project files on my local PC I'm using an FTP client named FileZilla. Using FileZilla, I'm able to connect to my remote AWS EC2 instance, find the appropriate project folder and pull the folder and its contents onto my PC. This is a fairly slow process, as all of the PHP and JavaScript packages installed with Composer and npm were included in the local back-up. However, it is good to have a full copy of the project which includes every file. See the FileZilla and local back-up copy in the screen capture below. GitHub I also wanted to push my code to a n...

3. Creating a Post Model, Controller and Migration

Image
I started my SooperBlog application by creating a Post model, as well as a controller and a migration. All three of these files are quickly generated by running the following command: php artisan make:model Post -mc The make:model command generates a Post model, stored in the app/Models directory. The -mc flag generates a migration and a controller, located in the database/migrations and app/Http/Controllers directories respectively. At this point, I can begin adding code to each of these files. I find it easiest to start with the migration setup. I know that I want a post to comprise of a heading, a subheading and some body text, so I can add these table columns to the migration and keep the default columns (the id and timestamps). I also know that each post should belong to a certain user and so I need to reflect this with a foreign key relationship. Below is my posts table migration, with the heading, subheading and body columns, as well as the foreign key relationship, where user_i...