Sylius Standard Edition

READ: https://sylius.com/download/
Make sure to use PHP 7.2
Download via composer and create a new app ‘sylius-app’

go to the app directory

Install!
NOTE: make sure the ‘timezone’ variable for PHP is already set! if not, You’d get this error ‘timezone | ERROR!’. Check the variable in /etc/php/7.2/cli/php.ini file. Set like this (for example): date.timezone = Asia/Jakarta
NOTE: Make sure to create a new file for override the default env. the new file is ‘.env.local’. (ref: https://docs.sylius.com/en/1.5/book/installation/installation.html)
I want this app stores file in ‘sylius_app’ database. So here is the file content

Change the parameters like username, password, etc to fit your system.
SORRY, ONLY ADMIN CAN SHOW THIS!
Then run the install command

My settings:
SORRY, ONLY ADMIN CAN SHOW THIS!

Install Assets

Then run gulp to build the frontend

Run the cli server

Open it on your browser: http://localhost:8000
Here is the screenshotsAdmin login: http://localhost:8000/admin/login

SORRY, ONLY ADMIN CAN SHOW THIS!
Here is the admin dashboardMODIFICATION
CREATE A NEW ROUTE AND CONTROLLER
READ: https://alanstorm.com/symfonys-service-container/
MODIFY THE ROUTE IN config/routes.yaml

THEN CREATE A CONTROLLER IN src/MyControllers/Advcha/HelloWorldController.php

 

Install Akeneo 3.1 Community Ed.

Ref: https://docs.akeneo.com/2.0/install_pim/installation_ce_archive.html
Download from https://www.akeneo.com/download/
Extract the files (composer.phar is included) in root web/akeneo31
Go to the dir

and run TO INSTALL DEPENDENCIES

Then install with ‘yarn’
NOTE:BUT MAKE SURE node version > 8.10.0

THEN INSTALL FRONTEND. CLEAR CACHE BUT GOT THIS:

SOLUTION:
READ: https://stackoverflow.com/questions/36129259/php7-with-apcu-call-to-undefined-function-apc-fetch
SO INSTALL php-apcu

THEN ENABLE THE EXTENSION. IF YOU CAN’T FIND THE APCU SETTING, PLS DO

SO ‘apc.enable_cli’ IS OFF. SO MODIFIED THE INI FILE

THEN ADD ONE LINE:

SAVE THEN RESTART THE SERVICES

CHECK AGAIN

THEN RUN AGAIN:

THEN CONTINUE TO RUN ‘php bin/console pim:installer:assets –symlink –clean –env=prod’

THEN THE INSTALLATION. BUT I GOT AN ERROR

SOLUTION:
READ https://docs.akeneo.com/2.0/install_pim/system_requirements/system_install_ubuntu_1604.html
Creating a MySQL database and a user for the application

THEN RUN AGAIN. BUT GOT ANOTHER ERROR:

SOLUTION:
INSTALL ELASTIC SEARCH FROM https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html#deb-key

START ELASTICSEARCH SERVICE

CHECK ON THE BROWSER: http://localhost:9200/
SHOULD SHOW

THEN RUN AGAIN. BUT GOT ANOTHER ERROR:

SETUP NGINX CONF

CONTENT

THEN

Then

Then

Then

 

 

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

Symfony 4 – Blog App

Ref: https://auth0.com/blog/symfony-tutorial-building-a-blog-part-1/
https://symfony.com/doc/current/setup.html

Install the latest Symfony 4 via Composer with the following command:

Update DotEnv File
In your root directory, there is a file called .env (usually this file is hidden. so set your system to show the hidden files), you should see something similar to the following:

Change to this:

run the following command

which will create a database with the value of your database name.
<!– START SKIP –>
IF YOU GOT ERROR LIKE MINE. IT’S BECAUSE MY PHP SETTING & APACHE2/NGINX SERVER DIDN’T WORK WELL. SKIP IT IF YOU DONT HAVE ANY ERROR LIKE THIS :

I NEED TO CHECK MY PHP VERSION. CLI ALREADY 7.2.

BUT THE SERVER STILL 7.0 (http://localhost/phpinfo.php). I ALREADY HAS 7.2 BUT SOME EXTENSIONS ARE MISSING. SO INSTALL THEM

TO ENABLE PHP 7.2 ON APACHE2 SERVER, PLS DO (MAKE SURE NGINX IS STOPPED IF IT’S RUNNING AND START APACHE2):

TEST: http://localhost/phpinfo.php

IF NEEDED TO CHANGE THE PHP SETTING, PLS EDIT:

TO ENABLE PHP 7.2 ON NGINX SERVER, PLS DO (MAKE SURE APACHE2 IS STOPPED IF IT’S RUNNING AND START NGINX):

THE NGINX MAIN CONFIG IN /etc/nginx/nginx.conf
THE DEFAULT VIRTUALHOST IN /etc/nginx/sites-available/default
EDIT IT TO ENABLE PARSING PHP FILE:

CHANGE THE CONTENT TO ENABLE PHP 7.2 FPM:

THEN CHANGE PHP7.2-FPM SETTING:

CHANGE THE CONTENT:

THEN RESTART PHP7.2-FPM SERVICE:

CHECK NGINX SYNTAX: sudo nginx -t
RESTART NGINX: sudo systemctl restart nginx
OPEN IT: http://localhost/phpinfo.php (NEED TO CLEAR THE BROWSER CACHE FIRST)
<!– END SKIP –>

OK. I FIXED THE CREATION DATABASE ERROR. RUN AGAIN

HERE IS THE WORKING RESULT:

Create the Blog Controller
Create new BlogController by running the following command

When it asks for The class name of the controller to create, type in: BlogController.

THEN CHANGE THE ROUTE IN src/Controller/BlogController.php
FROM:

TO:

THEN TEST IT VIA SYMFONY WEB SERVER. RUN:

OPEN IT ON YOUR BROWSER: http://127.0.0.1:8000
THEN you’ll be shown a Hello BlogController! page.

Creating a New Author Entity
Create new Author entity by running the following command:

OPEN A PHP FILE  src/Entity/Author.php, THEN REPLACE IT.
FROM:

TO:

Creating a New BlogPost Entity
Create new BlogPost entity by running the following command php

When it asks for The class name of the entity to create, type in: BlogPost.

Once the command has finished running, you’ll find a new file in src/Entity called BlogPost.php. Open this and configure it like so:

Although you have created these entities, your database still has no tables in there. Based off these entities, Doctrine can create the tables we’ve specified. In order to do this, all you have to do is run:

Install Doctrine-Fixtures
We want to just populate some data into the newly created tables as examples during the creation of the blog. So install doctrine-fixtures.

Create Author and BlogPost Fixtures
Create a new file (and the directories the file is stored in) under src/DataFixtures/ORM/Fixtures.php and insert the following into the file:

Running Fixtures
Let’s run the fixtures! php bin/console doctrine:fixtures:load

 

Symfony 4 Tutorial

From this:

CREATE SYMFONY 4 PROJECT
(ref: https://symfony.com/doc/current/setup.html –> DONT USE THE INSTRUCTION ‘symfony/website-skeleton’. USE ‘symfony/skeleton’ FROM https://knpuniversity.com/screencast/symfony/setup#play INSTEAD)
1. CREATE A NEW DIR ‘symfony4’ IN Documents/works/ DIR
2. GO INTO IT AND USE ‘composer’ TO CREATE THE PROJECT SKELETON:

TEST IT VIA INTERNAL PHP SERVER:

OPEN VIA BROWSER: http://127.0.0.1:8000/ –> WORKS

CREATE A VIRTUALHOST
1. CREATE A NEW conf FILE

HERE IS THE CONTENT:

2. Enable the site

3. Register the site in /etc/hosts

HERE IS THE CONTENT:

RESTART THE APACHE2 SERVER: sudo systemctl restart apache2
TEST IT VIA BROWSER: http://symfony4test.test/ –> WORKS

ROUTE AND CONTROLLER (ref: https://knpuniversity.com/screencast/symfony/route-controller#play)
Modify /config/routes.yaml FILE TO UNCOMMENT THE CONTENT AND CHANGE THE CONTROLLER AND THE ACTION:

CREATE THE CONTROLLER ‘ArticleController’  FILE AND CLASS. ALSO CREATE ‘homepage’ FUNCTION IN /src/Controller/ArticleController.php:

REFRESH THE BROWSER: http://symfony4test.test/
IT’D SHOW ‘Hello, This is my first page!’ TEXT!

USE ANNOTATION ROUTE (PREFERRED) INSTEAD OF MODIFYING /config/routes.yaml
USE COMPOSER TO INSTALL IT ‘composer require annotations’

BECAUSE WE DONT NEED routes.yaml, COMMENT THE CONTENT BACK (IN /config/routes.yaml):

MODIFY AGAIN /src/Controller/ArticleController.php AND ADD THE ANNOTATION

REFRESH THE BROWSER: http://symfony4test.test/
IT’D SHOW ‘Hello, This is my first page with annotations!’ TEXT!

FANCY WILDCARD ANNOTATION ROUTE
FOR EXAMPLE ADD THIS NEW ROUTE IN /src/Controller/ArticleController.php:

WE SHOULD OPEN IT ON BROWSER LIKE THIS: http://symfony4test.test/news/why-asteroids-taste-like-bacon
BUT I GOT ‘Not found’ ERROR.
OK. I NEED TO RUN ‘composer require apache-pack’

REFRESH BROWSER! –> STILL NOT WORKING
I NEED TO CREATE .htaccess FILE in /public/ DIR (ref: https://knpuniversity.com/screencast/symfony/route-controller#play
AND THE .htaccess CONTENT GOT FROM https://raw.githubusercontent.com/symfony/recipes-contrib/master/symfony/apache-pack/1.0/public/.htaccess):
/public/.htaccess

REFRESH BROWSER: http://symfony4test.test/news/why-asteroids-taste-like-bacon –> WORKS
IT’D PRINT ‘Future page to show one space article!’

USE ANNOTATION WITH PARAMETER
MODIFY /src/Controller/ArticleController.php:

REFRESH BROWSER: http://symfony4test.test/pages/test-page –> WORKS
IT’D PRINT ‘Here is the page “test-page” content!’