What Block Am I In?

Trying to remove a block from a layout and it won’t go away? A trick to figure out where you are working is to use $block->getNameInLayout() and that should tell you what block you need to remove.

Did you create a module, does it load after or before a core module that might be putting your block back in? Did you set the core module as a dependency in both composer.json and module.xml in your module? If not, add that in, and setup:upgrade module:disable your module and setup:upgrade module:enable your module to force the dependency order to get reset.

Ubuntu on Windows 10 for Magento Development

Find the Ubuntu App in the Windows App Store and install it.

Run the bash shell – click the app icon to run it. You will be logged in to your Ubuntu machine.

Now, you need apache, mysql, and phpmyadmin, at a bare minimum in order to start your localhost web server. You probably also want to use multiple versions of php since you will have different web sites with different production environments.

Ubuntu will give you php 7.0 by default. We will add 5.6, 7.1, and 7.2 also.

  1. Install apache 2.
    $ sudo apt-get install apache2 libapache2-mod-fcgid

    You will be prompted to type Y to complete the installation.

  2. Start the apache service.
    $ sudo service apache2 start

    if you are prompted for a password, this is your password for the windows user account you are using windows under presently. You may see an error message when you start the service that looks like the below. You can safely ignore this message.

    At this point, you should be able to find your localhost in a browser.

  3. Set up MySQL Server (or mariadb)
    $ sudo apt-get install mysql-server

    Again, you will be prompted to type Y to complete the installation

  4. Start MySQL Server
    $ sudo service mysql start

  5. Verify MySQL is running.
    $ mysql -u root -p 
     
  6. Set up PHP. We need multiple versions of PHP since we work on multiple versions of Magento: 5.6 for m1, 7.1 for 2.2, and 7.2 for 2.3. We will have 7.0 from the default Ubuntu also.
    $ sudo apt-get install php libapache2-mod-php php-xml php-gd php-mcrypt php-mysql php-intl php-curl
    Answer Y to complete the installation.
  7. Validate that php is running.
    $ a2query -m php7.0
    If it is not running, enable it:
    $ sudo a2enmod php7.0
    and restart apache:
    $ sudo service apache2 restart
    Navigate to your webroot (/var/www/html) and create an index.php file
    Type
    sudo vi index.php
    then when the editor opens, type i to begin inserting text. When you are finished typing, escape, and type wq<enter> to write and quit the editor.
    Browse to your index.php file – you should see php info in your localhost now.
  8. PhpMyAdmin
    sudo apt-get install phpmyadmin

    When the first prompt appears, press Space, Tab, and then Enter to select Apache. Select yes when asked to use dbconfig-common to set up the database. Provide your MariaDB root password Choose a password for the phpMyAdmin application itself.

    Enable the necessary PHP extensions:

    sudo phpenmod mcrypt
    sudo phpenmod mbstring

    Add this line to the bottom of /etc/apache2/apache2.conf

    Include /etc/phpmyadmin/apache.conf

    Restart Apache:

    sudo service apache2 restart
    Now you can access phpMyAdmin on the following URL: http://localhost/phpmyadmin/
    You can login using the root username and the root password you set up during the MariaDB installation.
     
  9. Alternate PHP Versions
    For the installation of PHP versions, we use the PPA maintained here. Use the below couple of commands to add the PPA to your system. You will be prompted to type Y to confirm and continue the installation.
    $ sudo apt install python-software-properties
    $ sudo add-apt-repository ppa:ondrej/php
    $ sudo add-apt-repository ppa:ondrej/apache2
    For this tutorial, we are using the PHP 5.6, PHP 7.1 and PHP 7.2 to configure with Apache web server. To use the multiple PHP versions, we will use PHP FPM and FastCGI. Let’s install the following packages on your system. You will be prompted to type Y to continue after each php install.
    $ sudo apt update
    $ sudo apt install php5.6 php5.6-fpm php5.6-xml php5.6-gd php5.6-mcrypt php5.6-intl php5.6-mysql php5.6-curl
    $ sudo apt install php7.1 php7.1-fpm php7.1-xml php7.1-gd php7.1-mcrypt php7.1-intl php7.1-mysql php7.1-curl
    $ sudo apt install php7.2 php7.2-fpm php7.2-xml php7.2-gd php7.2-mcrypt php7.2-intl php7.2-mysql php7.2-curl
    After installation, php-fpm services will not be started automatically. Use the following commands to make sure all versions of php are installed.
    $ sudo update-alternatives --config php
    and these commands to start a specific service
    $ sudo service php5.6-fpm start
    $ sudo service php7.2-fpm start
    Edit the php.ini file to enable pdo – look for the line “extension=php_pdo_mysql.dll” and remove the ; at the front of it. Do this for each version of php-fpm you installed. The files are in /etc/php/*/fpm/php.ini where * is the php version number.

    Activate fcgid
    $ sudo a2enmod actions fcgid alias proxy_fcgi
     
  10. Make a symbolic link from one of your website project files to your webroot. Your webroot is in /var/www/html in the ubuntu shell.
    $ ln -s full-path-to-web-files-on-your-pc directory-name-for-site
    I am going to add a site that needs 5.6 and one that needs 7.2
  11. Add apache config for each new vhost
    You can add a new file for each host or just add to the default 000-default.conf file. Be sure to symlink sites-available to sites-enabled. The FilesMatch directive is used to set the php version for the site.
            
    <FilesMatch>
        SetHandler "proxy:unix:/var/run/php/php5.6-fpm.sock|fcgi://localhost/"
    </FilesMatch>
        
  12. Restart Apache
  13. Edit your hosts file

Next Steps

Add SSL – https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-ubuntu-16-04 (skip firewall step)

https://medium.com/@thomas.schmidt.0001/how-to-use-ubuntu-bash-on-windows-10-as-the-intellij-idea-terminal-334fd9a10d8c

https://getcomposer.org/download/

https:// tecadmin . net/install-redis-ubuntu/

https:// tecadmin . net/install-memcached-with-php-on-ubuntu/