Topic: PHP

Running php 5 and php 7 on same environment (Ubuntu) 0

Why we need php 5 and php 7 on same PC?

Recent releases of Magento 2 mentioned that they have officially started to support php 7 and they are heading more towards it. Many of us including myself working on several projects which includes Magento v1 and v2. So time to time we are required to switch between projects. The question arises when we try to switch from Magento 1 project to Magento 2. Some functions of the Magento 1 doesn’t work properly or gives errors when running on php 7. So it’ll be convenient to run Magento 1 with php 5. Magento 2 could run on php 5.6 however if we are able to run it on php 7, Then that would be great. This solution comes in handy when addressing both these problems.

There are some issues when using this via CLI and that is also addressed in one of the below sections. (more…)

Install and Upgrade Scripts in Magento 1.x Vs. 2.x 0

When we start writing Magento modules (in both versions 1.x or 2.x) sooner or later, we will need to change database schema and/or data. Magento provides a way to do this by using Install and Upgrade scripts. Using these scripts, we can

  1. Install or Upgrade the Database Schema
  2. Install or Upgrade data

In a self sustainable way while keep tracking of the changes done to the system.

File Resolving in Magento 2 (Static, Template, Script, …) : Clues for Debugging 0

When Magento 2 wants to find a view file from the filesystem, it uses a fallback mechanism with a file resolving method. Unlike when a Class file is missing (where it gives an error) sometimes Magento 2 doesn’t provide an error message or so (even if error display is enforced).

I came up with a typo in the filename, which I didn’t notice, I got empty content area on frontend. No error messages. After a few debug sessions, found some clues on few interesting places to look on such a scenario.

Installing and configuring Magento 2 on Window 7 0

Installing Magento 2 on Windows need some extra work since windows have some issues. Below video describes the step by step guide how to install Magento 2 on windows, what are the issues and how to fix those issues.
Install Magento 2
Creating new theme
Installing and configuring Grunt
Updating css

Magento 2 enable MySQL query logging 2

– In app/etc/di.xml file locate

<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\Quiet"/>

and change it to

<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\File"/>

– Pass constructor arguments like below. Check Magento\Framework\DB\Logger\File for more configuration options.

<type name="Magento\Framework\DB\Logger\File">
        <argument name="logAllQueries" xsi:type="boolean">true</argument>
        <argument name="debugFile" xsi:type="string">query.log</argument>

– Find log files under var directory