Symfony 4 Blog

Ref: http://tutorials.mustangx.org/tutorials/create-advanced-blog-symfony-4-p1-2/

Getting Started with Symfony 4.x
There has been a lot of changes made for Symfony 4, seems to be ok though. I was quite confused, mainly the file structure of Symfony 3 is what I was used to. Then I discovered a nice and quick tutorial with the title Beginners Symfony 4 Tutorial.

The file structure has change if you are developing a web application. There are many, many changes that I may not catch as we move through this.

Step 1 – Symfony Website Skeleton
I am not going to detail this part, if you need that go to the link above.

Step 2 – Change into your new directory:

Step 3 – Install the Symfony Web Server Bundle: (NO NEED)

Step 4 – Now let’s fire up the web server

OR CAN USE PHP SERVER CLI : php bin/console server:run

That command will start the server and this one will stop it.

Note: You do not need to have any other server running. It may cause problems.

Create an .htaccess file (FOR APACHE WEBSERVER)
Mein is like this. Test it out and see if it works for you.

Now COPY & PASTE the following:

Setup the DB (MySql)
Inside the .env file (probably hidden) find this line

replace ‘db_user’, ‘db_password’ and ‘db_name’ according to  your database credential.
SORRY, ONLY ADMIN CAN SHOW THIS!
Once that’s done, we need to do this (make sure you have the correct db info added first):

If you already have the database, it’d show this error:

Auto Versioning setup
Get the auto versioning setup first.
NOTE: This has changed and is easier to install thanks to Flex.

The version is automatically updated with Composer and available in your application.

Console commands
There are two available console commands. The app:version:bump command is automatically called by Composer on every install and update.

Go ahead and test those two commands and see what it outputs.

Create an Advanced Blog with Symfony 4 – part3 (FrontController)
Last Updated On March 28, 2018
Introduction
This part of the tutorial will concentrate on getting a basic Homepage/Frontpage structure setup. I opted for a typical blog look.
We will remove files and folders as well add new ones. The Controller for the homepage will be created and the basic page should be viewable at the end.

Get Twitter Bootstrap Layout
I want to have a different look this time, so we will be using some premade templates from the Startbootstrap website. The one we want is released with an MIT license.

First create the PageController
It is easy to do with Symfony 4.

Let’s see what got created for us. We have a PageController.php file in our src/Controllers folder and inside of the templates folder we have a new folder and a new file, page/index.html.twig

Now that was all I discovered. Run the server: php bin/console s:r
then open the page on http://localhost:8000/page

Leave a Reply

Your email address will not be published. Required fields are marked *