1. Introduction: Creating a Blog Application with Laravel
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, meaning that the project was installed in this location and can be found easily.
Before progressing with the development of the blog application, I thought it would be beneficial to set up the necessary Apache permissions early on. Apache needs access to the storage and bootstrap/cache directories. The commands below were run to update the Apache permissions, giving the www-data user access to the required directories:
cd ~/sooperblog
sudo chown -R ubuntu:www-data storage
sudo chown -R ubuntu:www-data bootstrap/cache
chmod -R 775 storage
chmod -R 775 bootstrap/cache
I decided to stick with Laravel UI to manage my application scaffolding, as opposed to the JetStream and Livewire stack. I personally found using JetStream and Livewire to be too much of a learning curve while still new to Laravel. I installed the Laravel UI package via Composer (a PHP package management tool) by running the following command:
composer require laravel/ui
I then wanted to create a scaffolded application which included an authentication system. The scaffolded application would include registration, login and password recovery forms, as well as the back-end functionality to enable these features. To work with a familiar technology, I opted to create my scaffolded application with Bootstrap, a popular HTML, CSS and JS library. The command below generates the Bootstrap-based scaffolding and includes authentication through the inclusion of the --auth flag:
php artisan ui bootstrap --auth
At this point, it was necessary for me to install the Node (Node.js) packages, however, I did not have npm (Node Package Manager) installed yet. To install npm, the following command was run:
sudo apt install npm
After installing npm, I could then install the Node packages and compile my newly created, scaffolded application. This was achieved by running the following command:
npm install && npm run dev
I then decided to alter my Apache configuration, adjusting the document root and creating a directory directive for the new project. Making these changes early, allowed me to quickly begin testing my application in my browser using the Apache server, instead of having to use the php artisan serve command. The Apache server was configured as follows:
DocumentRoot /home/ubuntu/sooperblog/public
<Directory /home/ubuntu/sooperblog/public>
AllowOverride All
Require all granted
</Directory>
For the changes to take effect, I then restarted the Apache server:
sudo systemctl restart apache2
My next step involved creating a new database in phpMyAdmin named 'sooperblog'. To make the application work with this newly created database, I had to update the user environment variables file, commonly known as a .env file (see below). This file was updated to include the database name and the username and password credentials. Afterwards, I was able to successfully migrate the databases from the scaffolded application - which included the users and passwords_resets tables. This was achieved by running:
php artisan migrate
At this point, I was able to view the newly created application in my browser using localhost/127.0.0.1, as well as my dynamic DNS domain: acaws.duckdns.org. I was able to register a new user and log in/log out with the new user's credentials. I also decided to setup a database connection using Table Plus, which offers a slightly cleaner UI than phpMyAdmin. This was achieved by using the connection details below:
Good Job! I will refer the people to the best IT Solutions providers click the below link:
ReplyDeleteIT Consulting Melbourne
affordable seo packages
ppc company australia
content marketing agency melbourne
social media marketing company
web development australia
app development melbourne
seo packages
social media marketing packages
Cre8tivebot